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
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
14 deletions
+36
-14
src/Language/SystemVerilog/Parser/Preprocess.hs
+17
-14
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 =
...
@@ -218,36 +218,39 @@ isIdentChar ch =
takeIdentifier
::
PPS
String
takeIdentifier
::
PPS
String
takeIdentifier
=
do
takeIdentifier
=
do
str
<-
getInput
str
<-
getInput
macroStack
<-
getMacroStack
if
null
macroStack
then
do
let
(
ident
,
rest
)
=
span
isIdentChar
str
let
(
ident
,
rest
)
=
span
isIdentChar
str
advancePositions
ident
advancePositions
ident
macroStack
<-
getMacroStack
setInput
rest
setInput
rest
if
null
macroStack
return
ident
then
return
ident
else
takeIdentifierFollow
True
else
do
takeIdentifierFollow
::
Bool
->
PPS
String
identFollow
<-
takeIdentifierFollow
takeIdentifierFollow
firstPass
=
do
return
$
ident
++
identFollow
takeIdentifierFollow
::
PPS
String
takeIdentifierFollow
=
do
str
<-
getInput
str
<-
getInput
case
str
of
case
str
of
'`'
:
'`'
:
'`'
:
_
->
'`'
:
'`'
:
'`'
:
_
->
do
'`'
<-
takeChar
'`'
<-
takeChar
process
$
handleDirective
True
process
$
handleDirective
True
'`'
:
'`'
:
_
->
'`'
:
'`'
:
_
->
do
'`'
<-
takeChar
'`'
<-
takeChar
process
consumeWithSubstitution
process
consumeWithSubstitution
_
->
return
""
_
->
if
firstPass
then
process
consumeWithSubstitution
else
return
""
where
where
process
::
(
PPS
()
)
->
PPS
String
process
::
(
PPS
()
)
->
PPS
String
process
action
=
do
process
action
=
do
'`'
<-
takeChar
'`'
<-
takeChar
outputFollow
<-
getOutput
outputFollow
<-
getOutput
setOutput
[]
setOutput
[]
()
<-
action
()
<-
action
outputIdent
<-
getOutput
outputIdent
<-
getOutput
setOutput
outputFollow
setOutput
outputFollow
let
ident
=
reverse
$
map
fst
outputIdent
let
ident
=
reverse
$
map
fst
outputIdent
identFollow
<-
takeIdentifierFollow
identFollow
<-
takeIdentifierFollow
False
return
$
ident
++
identFollow
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
...
...
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