diff --git a/asllib/Parser0.mly b/asllib/Parser0.mly index a9dd3140c..031b02770 100644 --- a/asllib/Parser0.mly +++ b/asllib/Parser0.mly @@ -348,7 +348,7 @@ let binop_expr(e, b) == | ~=e; DOT; ~=bracketed(clist(ident)); < AST.E_GetFields > | ~=e; ~=bracketed(clist(slice)); < AST.E_Slice > | ~=bracketed(clist(expr)); < AST.E_Concat > - | ~=e; IN; ~=pattern; < AST.E_Pattern > + | ~=e; IN; ~=bpattern; < AST.E_Pattern > | ~=annotated(ty_non_tuple); UNKNOWN; < AST.E_Unknown > (* | ~=e; LT; ~=clist(slice); GT; < AST.E_Slice > @@ -645,6 +645,7 @@ let otherwise == annotated (OTHERWISE; possibly_empty_block) let pattern_list == ~=nclist(pattern); < AST.Pattern_Any > let pattern == + | bpattern | MINUS; { AST.Pattern_All } | ~=MASK_LIT; < AST.Pattern_Mask > @@ -653,8 +654,7 @@ let pattern == | ~=qualident; < AST.E_Var > ); < AST.Pattern_Single > - | braced(apattern_list) - +let bpattern == braced(apattern_list) let apattern_list == ~=nclist(apattern); < AST.Pattern_Any > let apattern == | ~=expr; < AST.Pattern_Single > diff --git a/asllib/tests/regressions.t/asl0-patterns.asl b/asllib/tests/regressions.t/asl0-patterns.asl new file mode 100644 index 000000000..9d34a388b --- /dev/null +++ b/asllib/tests/regressions.t/asl0-patterns.asl @@ -0,0 +1,6 @@ +integer main() + bits(64) x = Zeros(64); + y = x[1+:10]; // this would be invalid ASL0, but we use it in the XML + if x[0+:4] IN '10x1' then + z = 1; + return 1; diff --git a/asllib/tests/regressions.t/run.t b/asllib/tests/regressions.t/run.t index ba0d65514..c8f2256c1 100644 --- a/asllib/tests/regressions.t/run.t +++ b/asllib/tests/regressions.t/run.t @@ -301,6 +301,10 @@ Required tests: $ aslref array-with-enums.asl $ aslref array.asl $ aslref -0 assign-v0.asl + $ aslref -0 asl0-patterns.asl + File asl0-patterns.asl, line 4, characters 25 to 29: + ASL Error: Cannot parse. + [1] $ aslref assign1.asl $ aslref big-ints.asl $ aslref bitfields.asl