mirror of https://github.com/zachjs/sv2v.git
coalesce tokens across nested macros
This commit is contained in:
parent
37355920e0
commit
fea5ff44eb
|
|
@ -540,7 +540,9 @@ lexFile includePaths env path = do
|
||||||
(show $ length $ lsSpecStack finalState)
|
(show $ length $ lsSpecStack finalState)
|
||||||
else
|
else
|
||||||
Right (finalToks, lsEnv finalState)
|
Right (finalToks, lsEnv finalState)
|
||||||
where finalToks = coalesce $ reverse $ lsToks finalState
|
where
|
||||||
|
finalToks = coalesce $ combineBoundaries $
|
||||||
|
reverse $ lsToks finalState
|
||||||
where
|
where
|
||||||
setEnv = do
|
setEnv = do
|
||||||
modify $ \s -> s
|
modify $ \s -> s
|
||||||
|
|
@ -569,6 +571,12 @@ coalesce (Token t1 str1 pn1 : Token MacroBoundary _ _ : Token t2 str2 pn2 : rest
|
||||||
immediatelyFollows = apn2 == foldl alexMove apn1 str1
|
immediatelyFollows = apn2 == foldl alexMove apn1 str1
|
||||||
coalesce (x : xs) = x : coalesce xs
|
coalesce (x : xs) = x : coalesce xs
|
||||||
|
|
||||||
|
combineBoundaries :: [Token] -> [Token]
|
||||||
|
combineBoundaries [] = []
|
||||||
|
combineBoundaries (Token MacroBoundary s p : Token MacroBoundary _ _ : rest) =
|
||||||
|
combineBoundaries $ Token MacroBoundary s p : rest
|
||||||
|
combineBoundaries (x : xs) = x : combineBoundaries xs
|
||||||
|
|
||||||
-- invoked by alexMonadScan
|
-- invoked by alexMonadScan
|
||||||
alexEOF :: Alex ()
|
alexEOF :: Alex ()
|
||||||
alexEOF = return ()
|
alexEOF = return ()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
`define SIZE 4
|
`define SIZE 4
|
||||||
|
`define NESTED_SIZE `SIZE
|
||||||
`define NAME op
|
`define NAME op
|
||||||
module t`NAME;
|
module t`NAME;
|
||||||
initial $display(`SIZE'ha);
|
initial $display(`SIZE'ha);
|
||||||
|
initial $display(`NESTED_SIZE'ha);
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue