Skip to content

Commit

Permalink
[asl0] Forbid use of direct masks with IN
Browse files Browse the repository at this point in the history
  • Loading branch information
HadrienRenaud committed Oct 23, 2024
1 parent 3d88878 commit 2d1f5f4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions asllib/Parser0.mly
Original file line number Diff line number Diff line change
Expand Up @@ -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 >
Expand Down Expand Up @@ -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 >

Expand All @@ -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 >
Expand Down
6 changes: 6 additions & 0 deletions asllib/tests/regressions.t/asl0-patterns.asl
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 4 additions & 0 deletions asllib/tests/regressions.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d1f5f4

Please sign in to comment.