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
77b2f8b6
Commit
77b2f8b6
authored
Mar 05, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve for decl error messaging
parent
da076196
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
8 deletions
+14
-8
src/Convert/ForDecl.hs
+2
-7
src/Language/SystemVerilog/Parser/ParseDecl.hs
+6
-1
test/error/for_loop_decl_no_init.sv
+6
-0
No files found.
src/Convert/ForDecl.hs
View file @
77b2f8b6
...
@@ -19,8 +19,6 @@ convert =
...
@@ -19,8 +19,6 @@ convert =
traverseStmts
convertStmt
traverseStmts
convertStmt
convertStmt
::
Stmt
->
Stmt
convertStmt
::
Stmt
->
Stmt
convertStmt
(
For
(
Left
[]
)
cc
asgns
stmt
)
=
convertStmt
$
For
(
Right
[]
)
cc
asgns
stmt
convertStmt
(
For
(
Right
[]
)
cc
asgns
stmt
)
=
convertStmt
(
For
(
Right
[]
)
cc
asgns
stmt
)
=
convertStmt
$
For
inits
cc
asgns
stmt
convertStmt
$
For
inits
cc
asgns
stmt
where
inits
=
Left
[
dummyDecl
$
RawNum
0
]
where
inits
=
Left
[
dummyDecl
$
RawNum
0
]
...
@@ -47,12 +45,9 @@ convertStmt (For (Right origPairs) cc asgns stmt) =
...
@@ -47,12 +45,9 @@ convertStmt (For (Right origPairs) cc asgns stmt) =
convertStmt
other
=
other
convertStmt
other
=
other
splitDecl
::
Decl
->
(
Decl
,
(
LHS
,
Expr
))
splitDecl
::
Decl
->
(
Decl
,
(
LHS
,
Expr
))
splitDecl
(
decl
@
(
Variable
_
_
_
_
Nil
))
=
error
$
"invalid for loop decl: "
++
show
decl
splitDecl
(
Variable
d
t
ident
a
e
)
=
(
Variable
d
t
ident
a
Nil
,
(
LHSIdent
ident
,
e
))
splitDecl
decl
=
splitDecl
decl
=
error
$
"invalid for loop decl: "
++
show
decl
(
Variable
d
t
ident
a
Nil
,
(
LHSIdent
ident
,
e
))
where
Variable
d
t
ident
a
e
=
decl
isComment
::
Decl
->
Bool
isComment
::
Decl
->
Bool
isComment
CommentDecl
{}
=
True
isComment
CommentDecl
{}
=
True
...
...
src/Language/SystemVerilog/Parser/ParseDecl.hs
View file @
77b2f8b6
...
@@ -287,7 +287,7 @@ parseDTsAsDeclsOrAsgns tokens =
...
@@ -287,7 +287,7 @@ parseDTsAsDeclsOrAsgns tokens =
forbidNonEqAsgn
tokens
$
forbidNonEqAsgn
tokens
$
if
hasLeadingAsgn
||
tripLookahead
tokens
if
hasLeadingAsgn
||
tripLookahead
tokens
then
Right
$
parseDTsAsAsgns
tokens
then
Right
$
parseDTsAsAsgns
tokens
else
Left
$
parseDTsAsDecls
tokens
else
Left
$
map
checkDecl
$
parseDTsAsDecls
tokens
where
where
hasLeadingAsgn
=
hasLeadingAsgn
=
-- if there is an asgn token before the next comma
-- if there is an asgn token before the next comma
...
@@ -295,6 +295,11 @@ parseDTsAsDeclsOrAsgns tokens =
...
@@ -295,6 +295,11 @@ parseDTsAsDeclsOrAsgns tokens =
(
Just
a
,
Just
b
)
->
a
>
b
(
Just
a
,
Just
b
)
->
a
>
b
(
Nothing
,
Just
_
)
->
True
(
Nothing
,
Just
_
)
->
True
_
->
False
_
->
False
checkDecl
::
Decl
->
Decl
checkDecl
(
decl
@
(
Variable
_
_
_
_
Nil
))
=
error
$
"for loop declaration missing initialization: "
++
init
(
show
decl
)
checkDecl
decl
=
decl
-- internal parser for basic assignment lists
-- internal parser for basic assignment lists
parseDTsAsAsgns
::
[
DeclToken
]
->
[(
LHS
,
Expr
)]
parseDTsAsAsgns
::
[
DeclToken
]
->
[(
LHS
,
Expr
)]
...
...
test/error/for_loop_decl_no_init.sv
0 → 100644
View file @
77b2f8b6
// pattern: for loop declaration missing initialization
module
top
;
initial
for
(
integer
x
;
x
<
3
;
x
=
x
+
1
)
;
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