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 semicolon in AirScript #353

Merged
merged 8 commits into from
Aug 12, 2024

Conversation

sydhds
Copy link

@sydhds sydhds commented Aug 7, 2024

No description provided.

@bobbinth bobbinth requested a review from bitwalker August 8, 2024 05:36
@@ -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>
Copy link
Contributor

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 StatementBlocks 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.

Copy link
Contributor

@bitwalker bitwalker left a 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];
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

@bobbinth bobbinth left a 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.

Comment on lines 3 to 14
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];
}
Copy link
Contributor

@bobbinth bobbinth Aug 9, 2024

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed :)

@bitwalker
Copy link
Contributor

@sydhds I've fixed the clippy warnings in next, so once you rebase your changes, the build should be green again. There may be some conflicts due to the function implementation, but shouldn't be anything major, mostly just the fact that we likely touched the same files and tests, but I think the actual changes are pretty disjoint.

@sydhds
Copy link
Author

sydhds commented Aug 9, 2024

@sydhds I've fixed the clippy warnings in next, so once you rebase your changes, the build should be green again. There may be some conflicts due to the function implementation, but shouldn't be anything major, mostly just the fact that we likely touched the same files and tests, but I think the actual changes are pretty disjoint.

Rebase done so I think it should be all good :)

@sydhds sydhds requested review from bitwalker and bobbinth August 9, 2024 15:51
Copy link
Contributor

@bitwalker bitwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @sydhds!

Copy link
Contributor

@bobbinth bobbinth left a 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.

Comment on lines 29 to +32
enf match {
case s[1] & s[2]: is_unchanged([clk, s[0]])
case !s[1] & !s[2]: next_is_one([clk])
}
};
Copy link
Contributor

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]),
};

Copy link
Author

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?

Copy link
Contributor

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.

Comment on lines 183 to +186
enf match {
case s[1] & s[2]: is_unchanged([clk, s[0]])
case !s[1] & !s[2]: next_is_one([clk])
}
};
Copy link
Contributor

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.

@bobbinth bobbinth merged commit ea582d4 into 0xPolygonMiden:next Aug 12, 2024
4 checks passed
Leo-Besancon pushed a commit to massalabs/air-script that referenced this pull request Aug 22, 2024
Leo-Besancon added a commit to massalabs/air-script that referenced this pull request Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants