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
e471d37e
Commit
e471d37e
authored
Nov 27, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preprocessor batch consumption
parent
a7874e1b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
5 deletions
+22
-5
src/Language/SystemVerilog/Parser/Preprocess.hs
+22
-5
No files found.
src/Language/SystemVerilog/Parser/Preprocess.hs
View file @
e471d37e
...
...
@@ -96,10 +96,6 @@ annotate _ env path = do
else
loadFile
path
let
positions
=
scanl
advance
(
Position
path
1
1
)
contents
return
$
Right
(
zip
contents
positions
,
env
)
where
advance
::
Position
->
Char
->
Position
advance
(
Position
f
l
_
)
'
\n
'
=
Position
f
(
l
+
1
)
1
advance
(
Position
f
l
c
)
_
=
Position
f
l
(
c
+
1
)
-- read in the given file
loadFile
::
FilePath
->
IO
String
...
...
@@ -500,7 +496,11 @@ preprocessInput = do
'`'
<-
takeChar
return
()
'`'
:
_
->
handleDirective
False
_
:
_
->
consumeWithSubstitution
_
:
_
->
do
condStack
<-
getCondStack
if
null
macroStack
&&
all
(
==
CurrentlyTrue
)
condStack
then
consumeMany
else
consumeWithSubstitution
[]
->
return
()
if
str
==
[]
then
return
()
...
...
@@ -539,6 +539,18 @@ consume = do
setInput
chs
pushChar
ch
pos
-- consumeMany processes chars in a batch until a potential delimiter is reached
consumeMany
::
PPS
()
consumeMany
=
do
consume
-- always consume first character
(
str
,
pos
)
<-
getBuffer
let
(
content
,
rest
)
=
break
(
flip
elem
stopChars
)
str
let
positions
=
scanl
advance
pos
content
output
<-
getOutput
setOutput
$
(
reverse
$
zip
content
positions
)
++
output
setBuffer
(
rest
,
last
positions
)
where
stopChars
=
[
'`'
,
'"'
,
'/'
]
-- preprocess a leading string literal; this routine is largely necessary to
-- avoid doing any macro or directive related manipulations within standard
-- string literals; it also handles escaped newlines in the string
...
...
@@ -839,6 +851,11 @@ advancePositions str = do
_
<-
mapM
advancePosition
str
return
()
-- update the given position based on the movement of the given character
advance
::
Position
->
Char
->
Position
advance
(
Position
f
l
_
)
'
\n
'
=
Position
f
(
l
+
1
)
1
advance
(
Position
f
l
c
)
_
=
Position
f
l
(
c
+
1
)
-- adds a character (and its position) to the output state
pushChar
::
Char
->
Position
->
PPS
()
pushChar
c
p
=
do
...
...
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