mirror of https://github.com/zachjs/sv2v.git
fix handling of macros at EOF (resolves #62)
This commit is contained in:
parent
bbd072d41d
commit
ad98c14547
|
|
@ -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
|
||||||
"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
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
`include "no_newline.vh"
|
||||||
|
module top;
|
||||||
|
`ifdef A
|
||||||
|
initial $display("A is defined!");
|
||||||
|
`endif
|
||||||
|
endmodule
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
`include "no_newline.vh"
|
||||||
|
module top;
|
||||||
|
`ifdef A
|
||||||
|
initial $display("A is defined!");
|
||||||
|
`endif
|
||||||
|
endmodule
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
`define A
|
||||||
Loading…
Reference in New Issue