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
ad21277e
Commit
ad21277e
authored
Feb 16, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support macro names comprised of macro args and macros
parent
9af38e78
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
1 deletions
+54
-1
src/Language/SystemVerilog/Parser/Preprocess.hs
+28
-1
test/lex/macro_macro.sv
+19
-0
test/lex/macro_macro.v
+7
-0
No files found.
src/Language/SystemVerilog/Parser/Preprocess.hs
View file @
ad21277e
...
@@ -154,8 +154,35 @@ takeIdentifier = do
...
@@ -154,8 +154,35 @@ takeIdentifier = do
str
<-
getInput
str
<-
getInput
let
(
ident
,
rest
)
=
span
isIdentChar
str
let
(
ident
,
rest
)
=
span
isIdentChar
str
advancePositions
ident
advancePositions
ident
macroStack
<-
getMacroStack
setInput
rest
setInput
rest
return
ident
if
null
macroStack
then
return
ident
else
do
identFollow
<-
takeIdentifierFollow
return
$
ident
++
identFollow
takeIdentifierFollow
::
PPS
String
takeIdentifierFollow
=
do
str
<-
getInput
case
str
of
'`'
:
'`'
:
'`'
:
_
->
process
$
handleDirective
True
'`'
:
'`'
:
_
->
process
consumeWithSubstitution
_
->
return
""
where
process
::
(
PPS
()
)
->
PPS
String
process
action
=
do
'`'
<-
takeChar
'`'
<-
takeChar
outputFollow
<-
getOutput
setOutput
[]
()
<-
action
outputIdent
<-
getOutput
setOutput
outputFollow
let
ident
=
reverse
$
map
fst
outputIdent
identFollow
<-
takeIdentifierFollow
return
$
ident
++
identFollow
-- read tokens after the name until the first (un-escaped) newline
-- read tokens after the name until the first (un-escaped) newline
takeUntilNewline
::
PPS
String
takeUntilNewline
::
PPS
String
...
...
test/lex/macro_macro.sv
0 → 100644
View file @
ad21277e
`define
SUFFIX
_
MAGIC
`define
CHOICE_FOO 1
`define
CHOICE_BAR 2
`define
CHOICE_FOO_MAGIC 3
`define
CHOICE_BAR_MAGIC 4
`define
CHOICE__MAGIC 5
`define
MACRO1
(
A
,
B
)
\
`
CHOICE_
``
A
,
`
CHOICE_
``
B
`define
MACRO2
(
A
,
B
)
\
`
CHOICE_
``
A
```
SUFFIX
,
`
CHOICE_
``
B
```
SUFFIX
`define
MACRO3 \
`
CHOICE_
```
SUFFIX
,
`
CHOICE_
```
SUFFIX
module
top
;
initial
begin
$
display
(
`MACRO1
(
FOO
,
BAR
))
;
$
display
(
`MACRO2
(
FOO
,
BAR
))
;
$
display
(
`MACRO3
)
;
end
endmodule
test/lex/macro_macro.v
0 → 100644
View file @
ad21277e
module
top
;
initial
begin
$
display
(
1
,
2
)
;
$
display
(
3
,
4
)
;
$
display
(
5
,
5
)
;
end
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