-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DFA minimization used to crash on tokens of the form c* which produce automata with only accepting states. Considering the empty set of non-accepting states as an equivalence class caused minimization to crash with exception Prelude.head: empty list Now, DFA minimization succeeds. There is still a problem with nullable tokens like c*. Alex produces an infinite token sequence at the end of the input.
- Loading branch information
1 parent
6d57118
commit 70cc112
Showing
4 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
-- Issue #71 | ||
-- reported 2015-10-20 by Ian Duncan | ||
-- fixed 2020-01-22 by Andreas Abel | ||
-- | ||
-- Problem was: | ||
-- DFA minimization crashed with "Prelude head: empty list" because | ||
-- empty set of non-accepting states was treated as empty equivalence | ||
-- class of states. | ||
|
||
module Main (main) where | ||
|
||
import System.Exit | ||
} | ||
|
||
%wrapper "posn" | ||
%token "Token" | ||
|
||
$whitespace = [\ \n\t] | ||
@whitespaces = $whitespace* | ||
|
||
:- | ||
|
||
@whitespaces { \ _ _ -> Whitespaces } | ||
"a" { \ _ _ -> A } | ||
|
||
{ | ||
data Token = Whitespaces | A | ||
deriving (Eq, Show) | ||
|
||
input = "aa \n\taa \t \n a" | ||
expected_result = [A,A,Whitespaces,A,A,Whitespaces,A] | ||
|
||
main :: IO () | ||
main | ||
-- Since the whitespaces token is nullable, Alex | ||
-- will recognize an infinite number of those | ||
-- at the end of file. This behavior is problematic, | ||
-- but we don't fix it here. | ||
-- We just test here whether the expected result | ||
-- is a prefix of the produced result. | ||
| take (length expected_result) result == expected_result = do | ||
exitWith ExitSuccess | ||
| otherwise = do | ||
print $ take 20 result | ||
exitFailure | ||
where | ||
result = alexScanTokens input | ||
} |