Skip to content

Commit 643b9b6

Browse files
committed
[ fixed #46 ] give proper error when no lexing rules
The new error file.x contains no lexer rules can be tested with file.x containing :- <0> { } The previous error was (Array.!): undefined array element (I did not find a testsuite testing for error messages Alex gives, thus, no test case with this commit.)
1 parent 0198f73 commit 643b9b6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Main.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ parseScript file prg =
113113
Left (Nothing, err) ->
114114
die (file ++ ": " ++ err ++ "\n")
115115

116-
Right script -> return script
116+
Right script@(_, _, scanner, _) -> do
117+
-- issue 46: give proper error when lexer definition is empty
118+
when (null $ scannerTokens scanner) $
119+
dieAlex $ file ++ " contains no lexer rules\n"
120+
return script
117121

118122
alex :: [CLIFlags]
119123
-> FilePath

0 commit comments

Comments
 (0)