Skip to content

Commit

Permalink
Merge pull request #356 from massalabs/add-case-comma
Browse files Browse the repository at this point in the history
MassaLabs: add comma in match/case statement
  • Loading branch information
bitwalker authored Sep 4, 2024
2 parents ea582d4 + 433711c commit e9ad231
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions air-script/tests/selectors/selectors.air
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ boundary_constraints {
integrity_constraints {
enf clk' = 0 when s[0] & !s[1];
enf match {
case s[0] & s[1] & s[2]: clk' = clk
case !s[1] & !s[2]: clk' = 1
case s[0] & s[1] & s[2]: clk' = clk,
case !s[1] & !s[2]: clk' = 1,
};
}
4 changes: 2 additions & 2 deletions air-script/tests/selectors/selectors_with_evaluators.air
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ boundary_constraints {
integrity_constraints {
enf next_is_zero([clk]) when s[0] & !s[1];
enf match {
case s[1] & s[2]: is_unchanged([clk, s[0]])
case !s[1] & !s[2]: next_is_one([clk])
case s[1] & s[2]: is_unchanged([clk, s[0]]),
case !s[1] & !s[2]: next_is_one([clk]),
};
}
8 changes: 4 additions & 4 deletions ir/src/tests/selectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ fn multiconstraint_selectors() {
integrity_constraints {
enf clk' = 0 when s[0] & !s[1];
enf match {
case s[0] & s[1]: clk' = clk
case !s[0] & !s[1]: clk' = 1
case s[0] & s[1]: clk' = clk,
case !s[0] & !s[1]: clk' = 1,
};
}";

Expand Down Expand Up @@ -181,8 +181,8 @@ fn selectors_inside_match() {
integrity_constraints {
enf next_is_zero([clk]) when s[0] & !s[1];
enf match {
case s[1] & s[2]: is_unchanged([clk, s[0]])
case !s[1] & !s[2]: next_is_one([clk])
case s[1] & s[2]: is_unchanged([clk, s[0]]),
case !s[1] & !s[2]: next_is_one([clk]),
};
}";

Expand Down
2 changes: 1 addition & 1 deletion parser/src/parser/grammar.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ ReturnStatement: Expr = {
}

MatchArm: Statement = {
<l:@L> "case" <selector:ScalarExpr> ":" <constraint:ScalarConstraintExpr> <r:@R> => {
<l:@L> "case" <selector:ScalarExpr> ":" <constraint:ScalarConstraintExpr> "," <r:@R> => {
let generated_name = format!("%{}", *next_var);
*next_var += 1;
let generated_binding = Identifier::new(SourceSpan::UNKNOWN, Symbol::intern(generated_name));
Expand Down
4 changes: 2 additions & 2 deletions parser/src/parser/tests/inlining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,8 @@ fn test_repro_issue340() {
enf instruction_word = word_sum;
enf match {
case s: imm_reconstruction([instruction_bits, immediate])
case !s: immediate = 0
case s: imm_reconstruction([instruction_bits, immediate]),
case !s: immediate = 0,
};
}
Expand Down
4 changes: 2 additions & 2 deletions parser/src/parser/tests/integrity_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,8 @@ fn ic_match_constraint() {
integrity_constraints {
enf match {
case s[0] & s[1]: is_binary([c[0]])
case s[0]: c[1] = c[2]
case s[0] & s[1]: is_binary([c[0]]),
case s[0]: c[1] = c[2],
};
}";

Expand Down

0 comments on commit e9ad231

Please sign in to comment.