Commit e4efb480 by Zachary Snow

fix broken for inits parsing; beefed up relong test script to catch such mistakes

parent ef42fc04
...@@ -195,13 +195,16 @@ parseDTsAsDeclOrAsgn tokens = ...@@ -195,13 +195,16 @@ parseDTsAsDeclOrAsgn tokens =
parseDTsAsDeclsAndAsgns :: [DeclToken] -> [Either Decl (LHS, Expr)] parseDTsAsDeclsAndAsgns :: [DeclToken] -> [Either Decl (LHS, Expr)]
parseDTsAsDeclsAndAsgns [] = [] parseDTsAsDeclsAndAsgns [] = []
parseDTsAsDeclsAndAsgns tokens = parseDTsAsDeclsAndAsgns tokens =
if hasLeadingAsgn if hasLeadingAsgn || tripLookahead tokens
then then
let (lhsToks, l0) = break isAsgnToken tokens let (lhsToks, l0) = break isDTAsgn tokens
lhs = takeLHS lhsToks lhs = takeLHS lhsToks
DTAsgnNBlk Nothing expr : l1 = l0 DTAsgn AsgnOpEq expr : l1 = l0
DTComma : remaining = l1 asgn = Right (lhs, expr)
in Right (lhs, expr) : parseDTsAsDeclsAndAsgns remaining in case l1 of
DTComma : remaining -> asgn : parseDTsAsDeclsAndAsgns remaining
[] -> [asgn]
_ -> error $ "bad decls and asgns tokens: " ++ show tokens
else else
let (component, remaining) = parseDTsAsComponent tokens let (component, remaining) = parseDTsAsComponent tokens
decls = finalize component decls = finalize component
...@@ -213,6 +216,9 @@ parseDTsAsDeclsAndAsgns tokens = ...@@ -213,6 +216,9 @@ parseDTsAsDeclsAndAsgns tokens =
(Just a, Just b) -> a > b (Just a, Just b) -> a > b
(Nothing, Just _) -> True (Nothing, Just _) -> True
_ -> False _ -> False
isDTAsgn :: DeclToken -> Bool
isDTAsgn (DTAsgn _ _) = True
isDTAsgn _ = False
isAsgnToken :: DeclToken -> Bool isAsgnToken :: DeclToken -> Bool
isAsgnToken (DTBit _) = True isAsgnToken (DTBit _) = True
......
#!/bin/sh #!/bin/sh
SV2V=../../bin/sv2v
assertExists() { assertExists() {
file=$1 file=$1
[ -f "$file" ] [ -f "$file" ]
...@@ -28,6 +30,15 @@ simulate() { ...@@ -28,6 +30,15 @@ simulate() {
sed -i.orig -e "1,3d" "$sim_outfile" sed -i.orig -e "1,3d" "$sim_outfile"
} }
assertConverts() {
ac_file="$1"
ac_temp="$SHUNIT_TMPDIR/ac-conv-temp.v"
$SV2V "$ac_file" 2> /dev/null > "$ac_temp"
assertTrue "1st conversion of $ac_file failed" $?
$SV2V "$ac_temp" 2> /dev/null > /dev/null
assertTrue "2nd conversion of $ac_file failed" $?
}
runTest() { runTest() {
test=$1 test=$1
assertNotNull "test not specified" $test assertNotNull "test not specified" $test
...@@ -38,11 +49,15 @@ runTest() { ...@@ -38,11 +49,15 @@ runTest() {
assertExists $sv assertExists $sv
assertExists $ve assertExists $ve
assertExists $sv assertExists $tb
assertConverts "$sv"
assertConverts "$ve"
assertConverts "$tb"
# convert the SystemVerilog source file # convert the SystemVerilog source file
cv="$SHUNIT_TMPDIR/conv-$test.v" cv="$SHUNIT_TMPDIR/conv-$test.v"
../../bin/sv2v $sv 2> /dev/null > $cv $SV2V $sv 2> /dev/null > $cv
assertTrue "conversion failed" $? assertTrue "conversion failed" $?
assertExists $cv assertExists $cv
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment