Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MassaLabs: add comma in match/case statement #356

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading