-
Notifications
You must be signed in to change notification settings - Fork 16
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 semicolon in AirScript #353
Conversation
@@ -290,7 +290,7 @@ StatementBlock: Vec<Statement> = { | |||
} | |||
|
|||
Let: Let = { | |||
<l:@L> "let" <name: Identifier> "=" <value: Expr> <r:@R> <body: StatementBlock> | |||
<l:@L> "let" <name: Identifier> "=" <value: Expr> ";" <r:@R> <body: StatementBlock> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we have a proper IR to lower the AST into, we should be able to simplify the grammar by flattening it, i.e. we won't need to nest StatementBlock
s inside Let
.
For now, it's necessary because we're using the AST both as a syntax tree and as an intermediate representation, so keeping the language structure expression-oriented simplifies aspects of that. One upside of having that limitation, if I had to pick one, is that it forces us to avoid syntax that would require execution semantics we can't or don't want to support, but that's something we can still accomplish by sticking to functional-immutable semantics.
Anyway, nothing actionable here, just wanted to provide some context on this, since I'm sure it seems weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, looks great! If you could fix the clippy errors so the build passes, that's the only real blocker.
I would like to get @bobbinth's input on whether semicolons are the right choice for internal declarations of trace_columns
and the like, but even if we're not convinced that it's the best choice of syntax, we can always address it later, so we don't need to hold up merging this on that aspect.
@@ -11,11 +11,11 @@ const BASE_MODULE: &str = r#" | |||
def test | |||
|
|||
trace_columns { | |||
main: [clk] | |||
main: [clk]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bobbinth Perhaps it would make more sense to use ,
with these top-level definitions? Semicolons feels a bit bizarre in what amounts to a data structure definition.
In statement blocks and stuff, it feels pretty natural, but less so here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - in declarations like these, commas would be a more natural choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thank you! I don't have much additional comments besides @bitwalker 's suggestion to use commas in the "declarative" sections. Once this is addressed, we can merge.
air-script/tests/bitwise/bitwise.air
Outdated
public_inputs { | ||
stack_inputs: [16] | ||
stack_inputs: [16]; | ||
} | ||
|
||
trace_columns { | ||
main: [s, a, b, a0, a1, a2, a3, b0, b1, b2, b3, zp, z, dummy] | ||
main: [s, a, b, a0, a1, a2, a3, b0, b1, b2, b3, zp, z, dummy]; | ||
} | ||
|
||
periodic_columns { | ||
k0: [1, 0, 0, 0, 0, 0, 0, 0] | ||
k1: [1, 1, 1, 1, 1, 1, 1, 0] | ||
k0: [1, 0, 0, 0, 0, 0, 0, 0]; | ||
k1: [1, 1, 1, 1, 1, 1, 1, 0]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following @bitwalker 's comment, I think in these sections, we should use commas - e.g., they would look like so:
public_inputs {
stack_inputs: [16],
}
trace_columns {
main: [s, a, b, a0, a1, a2, a3, b0, b1, b2, b3, zp, z, dummy],
}
periodic_columns {
k0: [1, 0, 0, 0, 0, 0, 0, 0],
k1: [1, 1, 1, 1, 1, 1, 1, 0],
}
boundary_constraints
and integrity_constraints
sections below look good as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed :)
@sydhds I've fixed the clippy warnings in |
…_columns & random_values
…colums, periodic_columns & random_values
Rebase done so I think it should be all good :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks @sydhds!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you! I left a couple of comments inline about adding commas to separate clauses of the match
statement. But if that's difficult to do - we can do that in a separate PR.
enf match { | ||
case s[1] & s[2]: is_unchanged([clk, s[0]]) | ||
case !s[1] & !s[2]: next_is_one([clk]) | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add commas to the end of each case
clause? For example, something like this:
enf match {
case s[1] & s[2]: is_unchanged([clk, s[0]]),
case !s[1] & !s[2]: next_is_one([clk]),
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning to add that in another PR but let me know if you want in this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A follow-up PR is fine! I'll merge this one now then.
enf match { | ||
case s[1] & s[2]: is_unchanged([clk, s[0]]) | ||
case !s[1] & !s[2]: next_is_one([clk]) | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment as the one above here.
Fix example.air after 0xPolygonMiden#353
No description provided.