Commit ad98c145 by Zachary Snow

fix handling of macros at EOF (resolves #62)

parent bbd072d4
......@@ -787,6 +787,11 @@ peekChar = do
then lexicalError "unexpected end of input"
else return $head str
atEOF :: Alex Bool
atEOF = do
(_, _, _, str) <- alexGetInput
return $ null str
takeMacroDefinition :: Alex (String, [(String, Maybe String)])
takeMacroDefinition = do
leadCh <- peekChar
......@@ -1068,7 +1073,11 @@ handleDirective (posOrig, _, _, strOrig) len = do
"define" -> do
dropSpaces
name <- takeString
defn <- takeMacroDefinition
defn <- do
eof <- atEOF
if eof
then return ("", [])
else takeMacroDefinition
modify $ \s -> s { lsEnv = Map.insert name defn env }
alexMonadScan
"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