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
071d56a1
Commit
071d56a1
authored
Mar 18, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more accurate handling of tagged blocks
parent
35d8644f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
src/Convert/Traverse.hs
+9
-4
src/Language/SystemVerilog/Parser/Parse.y
+10
-4
No files found.
src/Convert/Traverse.hs
View file @
071d56a1
...
...
@@ -452,10 +452,12 @@ traverseNestedGenItemsM :: Monad m => MapperM m GenItem -> MapperM m GenItem
traverseNestedGenItemsM
mapper
=
fullMapper
where
fullMapper
genItem
=
gim
genItem
>>=
mapper
gim
(
GenBlock
x
subItems
)
=
mapM
fullMapper
subItems
>>=
return
.
GenBlock
x
gim
(
GenFor
a
b
c
d
subItems
)
=
mapM
fullMapper
subItems
>>=
return
.
GenFor
a
b
c
d
gim
(
GenBlock
x
subItems
)
=
do
subItems'
<-
mapM
fullMapper
subItems
return
$
GenBlock
x
(
concatMap
flattenBlocks
subItems'
)
gim
(
GenFor
a
b
c
d
subItems
)
=
do
subItems'
<-
mapM
fullMapper
subItems
return
$
GenFor
a
b
c
d
(
concatMap
flattenBlocks
subItems'
)
gim
(
GenIf
e
i1
i2
)
=
do
i1'
<-
fullMapper
i1
i2'
<-
fullMapper
i2
...
...
@@ -468,6 +470,9 @@ traverseNestedGenItemsM mapper = fullMapper
gim
(
GenModuleItem
moduleItem
)
=
return
$
GenModuleItem
moduleItem
gim
(
GenNull
)
=
return
GenNull
flattenBlocks
::
GenItem
->
[
GenItem
]
flattenBlocks
(
GenBlock
Nothing
items
)
=
items
flattenBlocks
other
=
[
other
]
traverseAsgnsM
::
Monad
m
=>
MapperM
m
(
LHS
,
Expr
)
->
MapperM
m
ModuleItem
traverseAsgnsM
mapper
=
moduleItemMapper
...
...
src/Language/SystemVerilog/Parser/Parse.y
View file @
071d56a1
...
...
@@ -425,8 +425,7 @@ Stmt :: { Stmt }
| Identifier ";" { Subroutine $1 [] }
StmtNonAsgn :: { Stmt }
: ";" { Null }
| "begin" DeclsAndStmts "end" opt(Tag) { Block Nothing (fst $2) (snd $2) }
| "begin" ":" Identifier DeclsAndStmts "end" opt(Tag) { Block (Just $3) (fst $4) (snd $4) }
| "begin" opt(Tag) DeclsAndStmts "end" opt(Tag) { Block (combineTags $2 $5) (fst $3) (snd $3) }
| "if" "(" Expr ")" Stmt "else" Stmt { If $3 $5 $7 }
| "if" "(" Expr ")" Stmt %prec NoElse { If $3 $5 Null }
| "for" "(" Identifier "=" Expr ";" Expr ";" Identifier "=" Expr ")" Stmt { For ($3, $5) $7 ($9, $11) $13 }
...
...
@@ -588,8 +587,7 @@ GenItem :: { GenItem }
| ModuleItem { genItemsToGenItem $ map GenModuleItem $1 }
GenBlock :: { (Maybe Identifier, [GenItem]) }
: "begin" GenItems "end" opt(Tag) { (Nothing, $2) }
| "begin" ":" Identifier GenItems "end" opt(Tag) { (Just $3, $4) }
: "begin" opt(Tag) GenItems "end" opt(Tag) { (combineTags $2 $5, $3) }
GenCases :: { [GenCase] }
: {- empty -} { [] }
...
...
@@ -649,4 +647,12 @@ defaultFuncInput (Variable Input (Implicit rs) x a me) =
Variable Input (Logic rs) x a me
defaultFuncInput other = other
combineTags :: Maybe Identifier -> Maybe Identifier -> Maybe Identifier
combineTags (Just a) (Just b) =
if a == b
then Just a
else error $ "tag mismatch: " ++ show (a, b)
combineTags Nothing other = other
combineTags other _ = other
}
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