Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sv2v
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
sv2v
Commits
fea5ff44
Commit
fea5ff44
authored
Oct 11, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coalesce tokens across nested macros
parent
37355920
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletions
+11
-1
src/Language/SystemVerilog/Parser/Lex.x
+9
-1
test/lex/macro_boundary.sv
+2
-0
No files found.
src/Language/SystemVerilog/Parser/Lex.x
View file @
fea5ff44
...
@@ -540,7 +540,9 @@ lexFile includePaths env path = do
...
@@ -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
...
@@ -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 ()
...
...
test/lex/macro_boundary.sv
View file @
fea5ff44
`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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment