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
c59334ce
Commit
c59334ce
authored
May 03, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow preproc idents to begin with macro arguments
parent
10b30d7d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
15 deletions
+37
-15
src/Language/SystemVerilog/Parser/Preprocess.hs
+18
-15
test/lex/macro_arg_invoke.sv
+11
-0
test/lex/macro_arg_invoke.v
+8
-0
No files found.
src/Language/SystemVerilog/Parser/Preprocess.hs
View file @
c59334ce
...
...
@@ -218,36 +218,39 @@ isIdentChar ch =
takeIdentifier
::
PPS
String
takeIdentifier
=
do
str
<-
getInput
let
(
ident
,
rest
)
=
span
isIdentChar
str
advancePositions
ident
macroStack
<-
getMacroStack
setInput
rest
if
null
macroStack
then
return
ident
else
do
identFollow
<-
takeIdentifierFollow
return
$
ident
++
identFollow
takeIdentifierFollow
::
PPS
String
takeIdentifierFollow
=
do
then
do
let
(
ident
,
rest
)
=
span
isIdentChar
str
advancePositions
ident
setInput
rest
return
ident
else
takeIdentifierFollow
True
takeIdentifierFollow
::
Bool
->
PPS
String
takeIdentifierFollow
firstPass
=
do
str
<-
getInput
case
str
of
'`'
:
'`'
:
'`'
:
_
->
'`'
:
'`'
:
'`'
:
_
->
do
'`'
<-
takeChar
'`'
<-
takeChar
process
$
handleDirective
True
'`'
:
'`'
:
_
->
'`'
:
'`'
:
_
->
do
'`'
<-
takeChar
'`'
<-
takeChar
process
consumeWithSubstitution
_
->
return
""
_
->
if
firstPass
then
process
consumeWithSubstitution
else
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
identFollow
<-
takeIdentifierFollow
False
return
$
ident
++
identFollow
-- read tokens after the name until the first (un-escaped) newline
...
...
test/lex/macro_arg_invoke.sv
0 → 100644
View file @
c59334ce
module
top
;
endmodule
`define
MODULE
(
str
)
module str
;
initial
$
display
(`"
hello str
`")
;
endmodule
`define
MACRO_A
(
inv
,
str
)
`
inv
(
str
)
`define
MACRO_B
(
inv
,
str
)
```
inv
(
str
)
`define
MACRO_C
(
inv1
,
inv2
,
str
)
`
inv1
``
inv2
(
str
)
`MODULE
(
example1
)
`MACRO_A
(
MODULE
,
example2
)
`MACRO_B
(
MODULE
,
example3
)
`MACRO_C
(
MOD
,
ULE
,
example4
)
`MACRO_C
(
M
,
ODULE
,
example5
)
`MACRO_C
(
,
MODULE
,
example6
)
test/lex/macro_arg_invoke.v
0 → 100644
View file @
c59334ce
module
top
;
endmodule
`define
MODULE
(
str
)
module str
;
initial
$
display
(`"
hello str
`")
;
endmodule
`MODULE
(
example1
)
`MODULE
(
example2
)
`MODULE
(
example3
)
`MODULE
(
example4
)
`MODULE
(
example5
)
`MODULE
(
example6
)
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