mirror of https://github.com/zachjs/sv2v.git
allow newlines before left paren of macro arguments
This commit is contained in:
parent
81f5fb500f
commit
89e4f2a248
|
|
@ -485,35 +485,29 @@ takeChar = do
|
||||||
-- drop spaces in the input until a non-space is reached or EOF
|
-- drop spaces in the input until a non-space is reached or EOF
|
||||||
dropSpaces :: Alex ()
|
dropSpaces :: Alex ()
|
||||||
dropSpaces = do
|
dropSpaces = do
|
||||||
(_, _, _, str) <- alexGetInput
|
(pos, _, _, str) <- alexGetInput
|
||||||
if null str || head str /= ' '
|
case str of
|
||||||
then return ()
|
' ' : rest -> do
|
||||||
else dropSpace >> dropSpaces
|
alexSetInput (alexMove pos ' ', ' ', [], rest)
|
||||||
where
|
dropSpaces
|
||||||
dropSpace :: Alex ()
|
[] -> return ()
|
||||||
dropSpace = do
|
_ -> return ()
|
||||||
(pos, _, _, str) <- alexGetInput
|
|
||||||
case str of
|
|
||||||
[] -> return ()
|
|
||||||
' ' : rest -> alexSetInput (alexMove pos ' ', ' ', [], rest)
|
|
||||||
ch : _ -> lexicalError $ "expected ' ', but found: " ++ show ch
|
|
||||||
|
|
||||||
isWhitespaceChar :: Char -> Bool
|
isWhitespaceChar :: Char -> Bool
|
||||||
isWhitespaceChar ch = elem ch [' ', '\t', '\n']
|
isWhitespaceChar ch = elem ch [' ', '\t', '\n']
|
||||||
|
|
||||||
-- drop leading whitespace in the input
|
-- drop all leading whitespace in the input
|
||||||
dropWhitespace :: Alex ()
|
dropWhitespace :: Alex ()
|
||||||
dropWhitespace = do
|
dropWhitespace = do
|
||||||
(_, _, _, str) <- alexGetInput
|
(pos, _, _, str) <- alexGetInput
|
||||||
if null str || not (isWhitespaceChar $ head str)
|
case str of
|
||||||
then return ()
|
ch : chs ->
|
||||||
else dropChar >> dropWhitespace
|
if isWhitespaceChar ch
|
||||||
where
|
then do
|
||||||
dropChar :: Alex ()
|
alexSetInput (alexMove pos ch, ch, [], chs)
|
||||||
dropChar = do
|
dropWhitespace
|
||||||
(pos, _, _, chs) <- alexGetInput
|
else return()
|
||||||
let ch : rest = chs
|
[] -> return ()
|
||||||
alexSetInput (alexMove pos ch, ch, [], rest)
|
|
||||||
|
|
||||||
-- removes and returns a quoted string such as <foo.bar> or "foo.bar"
|
-- removes and returns a quoted string such as <foo.bar> or "foo.bar"
|
||||||
takeQuotedString :: Alex String
|
takeQuotedString :: Alex String
|
||||||
|
|
@ -572,7 +566,7 @@ takeMacroDefinition = do
|
||||||
-- "", except to delimit arguments or end the list of arguments; see 22.5.1
|
-- "", except to delimit arguments or end the list of arguments; see 22.5.1
|
||||||
takeMacroArguments :: Alex [String]
|
takeMacroArguments :: Alex [String]
|
||||||
takeMacroArguments = do
|
takeMacroArguments = do
|
||||||
dropSpaces
|
dropWhitespace
|
||||||
leadCh <- takeChar
|
leadCh <- takeChar
|
||||||
if leadCh == '('
|
if leadCh == '('
|
||||||
then argLoop
|
then argLoop
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
`define FOO(a, b) ((a)+(b))
|
||||||
|
|
||||||
|
module top;
|
||||||
|
initial begin
|
||||||
|
$display(`FOO
|
||||||
|
(
|
||||||
|
1
|
||||||
|
,
|
||||||
|
2
|
||||||
|
));
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
`include "macro_whitespace.sv"
|
||||||
Loading…
Reference in New Issue