Commit ad98c145 by Zachary Snow

fix handling of macros at EOF (resolves #62)

parent bbd072d4
...@@ -787,6 +787,11 @@ peekChar = do ...@@ -787,6 +787,11 @@ peekChar = do
then lexicalError "unexpected end of input" then lexicalError "unexpected end of input"
else return $head str else return $head str
atEOF :: Alex Bool
atEOF = do
(_, _, _, str) <- alexGetInput
return $ null str
takeMacroDefinition :: Alex (String, [(String, Maybe String)]) takeMacroDefinition :: Alex (String, [(String, Maybe String)])
takeMacroDefinition = do takeMacroDefinition = do
leadCh <- peekChar leadCh <- peekChar
...@@ -1068,7 +1073,11 @@ handleDirective (posOrig, _, _, strOrig) len = do ...@@ -1068,7 +1073,11 @@ handleDirective (posOrig, _, _, strOrig) len = do
"define" -> do "define" -> do
dropSpaces dropSpaces
name <- takeString name <- takeString
defn <- takeMacroDefinition defn <- do
eof <- atEOF
if eof
then return ("", [])
else takeMacroDefinition
modify $ \s -> s { lsEnv = Map.insert name defn env } modify $ \s -> s { lsEnv = Map.insert name defn env }
alexMonadScan alexMonadScan
"undef" -> do "undef" -> do
......
`include "no_newline.vh"
module top;
`ifdef A
initial $display("A is defined!");
`endif
endmodule
`include "no_newline.vh"
module top;
`ifdef A
initial $display("A is defined!");
`endif
endmodule
`define A
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment