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

add conescutive math operator diagnostic to the parser #6392

Merged
merged 1 commit into from
Sep 22, 2024

Conversation

dean-starkware
Copy link
Collaborator

@dean-starkware dean-starkware commented Sep 19, 2024

This change is Reviewable

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on @dean-starkware and @gilbens-starkware)


crates/cairo-lang-parser/src/parser.rs line 1101 at r1 (raw file):

    /// # Returns:
    /// `true` if the token is a relational or equality operator, otherwise `false`.
    fn is_math_operator(&self, kind: SyntaxKind) -> bool {

rename method.

    • / * are all math operators as well.

crates/cairo-lang-parser/src/parser.rs line 1109 at r1 (raw file):

                    | SyntaxKind::TerminalGE   // >=
                    | SyntaxKind::TerminalEqEq // ==
                    | SyntaxKind::TerminalNeq // !=

properly align doc.

Code quote:

                    | SyntaxKind::TerminalGT   // >
                    | SyntaxKind::TerminalLE   // <=
                    | SyntaxKind::TerminalGE   // >=
                    | SyntaxKind::TerminalEqEq // ==
                    | SyntaxKind::TerminalNeq // !=

crates/cairo-lang-parser/src/parser_test_data/partial_trees/expr line 63 at r1 (raw file):

//! > ==========================================================================

//! > Test precedence between unary and binary operators1231233

?

Code quote:

1231233

@dean-starkware dean-starkware force-pushed the dean/consecutive_math_operators_in_parser branch 3 times, most recently from 153f2a7 to 0931d0a Compare September 19, 2024 13:31
Copy link
Collaborator Author

@dean-starkware dean-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 4 files reviewed, 3 unresolved discussions (waiting on @gilbens-starkware and @orizi)


crates/cairo-lang-parser/src/parser.rs line 1101 at r1 (raw file):

Previously, orizi wrote…

rename method.

    • / * are all math operators as well.

Done.


crates/cairo-lang-parser/src/parser.rs line 1109 at r1 (raw file):

Previously, orizi wrote…

properly align doc.

Done.


crates/cairo-lang-parser/src/parser_test_data/partial_trees/expr line 63 at r1 (raw file):

Previously, orizi wrote…

?

Done.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 3 files at r1, all commit messages.
Reviewable status: 1 of 4 files reviewed, 2 unresolved discussions (waiting on @dean-starkware and @gilbens-starkware)


crates/cairo-lang-parser/src/diagnostic.rs line 42 at r3 (raw file):

    AttributesWithoutStatement,
    DisallowedTrailingSeparatorOr,
    ConsecutiveMathOperators { first_op: SyntaxKind, second_op: SyntaxKind },

here as well.


crates/cairo-lang-parser/src/parser_test_data/full_trees/test1 line 875 at r3 (raw file):

error: Consecutive math operators are not allowed: 'TerminalEqEq' followed by 'TerminalEqEq'
 --> src/parser_test_data/cairo_test_files/test1.cairo:15:20
    let z = if 0 + x == y {

this doesn't seem right.

Code quote:

 let z = if 0 + x == y {

Copy link
Collaborator Author

@dean-starkware dean-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 4 files reviewed, 2 unresolved discussions (waiting on @gilbens-starkware and @orizi)


crates/cairo-lang-parser/src/diagnostic.rs line 42 at r3 (raw file):

Previously, orizi wrote…

here as well.

Please elaborate. It seems fine to me.

@dean-starkware dean-starkware force-pushed the dean/consecutive_math_operators_in_parser branch 3 times, most recently from 99de629 to cee3908 Compare September 19, 2024 14:23
Copy link
Collaborator Author

@dean-starkware dean-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 4 files reviewed, 2 unresolved discussions (waiting on @gilbens-starkware and @orizi)


crates/cairo-lang-parser/src/parser_test_data/full_trees/test1 line 875 at r3 (raw file):

Previously, orizi wrote…

this doesn't seem right.

Done.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 1 of 4 files reviewed, 2 unresolved discussions (waiting on @dean-starkware and @gilbens-starkware)


crates/cairo-lang-parser/src/parser.rs line 1109 at r4 (raw file):

                    | SyntaxKind::TerminalGE    // >=
                    | SyntaxKind::TerminalEqEq  // ==
                    | SyntaxKind::TerminalNeq // !=

i think you can just drop the comments here - the original names are clear enough.

Suggestion:

            SyntaxKind::TerminalLT
                    | SyntaxKind::TerminalGT
                    | SyntaxKind::TerminalLE
                    | SyntaxKind::TerminalGE
                    | SyntaxKind::TerminalEqEq
                    | SyntaxKind::TerminalNeq

crates/cairo-lang-parser/src/parser_test_data/full_trees/test1 line 875 at r3 (raw file):

Previously, dean-starkware wrote…

Done.

still doesn't seem right.

@dean-starkware dean-starkware force-pushed the dean/consecutive_math_operators_in_parser branch 3 times, most recently from 8ba7601 to f973604 Compare September 20, 2024 11:52
Copy link
Collaborator Author

@dean-starkware dean-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 4 files reviewed, 2 unresolved discussions (waiting on @gilbens-starkware and @orizi)


crates/cairo-lang-parser/src/parser.rs line 1109 at r4 (raw file):

Previously, orizi wrote…

i think you can just drop the comments here - the original names are clear enough.

Done.


crates/cairo-lang-parser/src/parser_test_data/full_trees/test1 line 875 at r3 (raw file):

Previously, orizi wrote…

still doesn't seem right.

I think it's fine now.
All tests are successfull now:
https://github.com/starkware-libs/cairo/actions/runs/10958733543

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r3, 3 of 5 files at r5.
Reviewable status: 4 of 6 files reviewed, 2 unresolved discussions (waiting on @dean-starkware and @gilbens-starkware)


crates/cairo-lang-parser/src/parser.rs line 1101 at r5 (raw file):

    /// # Returns:
    /// `true` if the token is a relational or equality operator, otherwise `false`.
    fn is_comperison_operator(&self, kind: SyntaxKind) -> bool {

Suggestion:

    fn is_comparison_operator(&self, kind: SyntaxKind) -> bool {

crates/cairo-lang-parser/src/parser.rs line 1154 at r5 (raw file):

                    }
                }
                child_op = Some(self.peek().kind);

Suggestion:

                child_op = Some(current_op);

Copy link
Collaborator Author

@dean-starkware dean-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 4 of 6 files reviewed, 2 unresolved discussions (waiting on @gilbens-starkware and @orizi)


crates/cairo-lang-parser/src/parser.rs line 1101 at r5 (raw file):

    /// # Returns:
    /// `true` if the token is a relational or equality operator, otherwise `false`.
    fn is_comperison_operator(&self, kind: SyntaxKind) -> bool {

Done.


crates/cairo-lang-parser/src/parser.rs line 1154 at r5 (raw file):

                    }
                }
                child_op = Some(self.peek().kind);

Done.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 5 files at r5, 1 of 1 files at r6.
Reviewable status: all files reviewed (commit messages unreviewed), 1 unresolved discussion (waiting on @dean-starkware and @gilbens-starkware)


crates/cairo-lang-parser/src/parser_test_data/partial_trees/expr line 79 at r5 (raw file):


//! > expected_diagnostics
error: Consecutive math operators are not allowed: 'TerminalLT' followed by 'TerminalGT'

Should be comparison

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed (commit messages unreviewed), 2 unresolved discussions (waiting on @dean-starkware and @gilbens-starkware)


crates/cairo-lang-parser/src/parser_test_data/partial_trees/expr line 79 at r5 (raw file):


//! > expected_diagnostics
error: Consecutive math operators are not allowed: 'TerminalLT' followed by 'TerminalGT'

Also, can you print the actual operators instead, or.only the names are possible?

@dean-starkware dean-starkware force-pushed the dean/consecutive_math_operators_in_parser branch 2 times, most recently from 30d3ef5 to f21bc0c Compare September 20, 2024 14:00
@dean-starkware dean-starkware force-pushed the dean/consecutive_math_operators_in_parser branch 2 times, most recently from 4c92135 to 10bf8ee Compare September 20, 2024 14:11
@piotmag769 piotmag769 removed their request for review September 20, 2024 15:50
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 8 files at r8, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Arcticae, @dean-starkware, @Draggu, @gilbens-starkware, and @mkaput)

@dean-starkware dean-starkware force-pushed the dean/consecutive_math_operators_in_parser branch from 10bf8ee to 7813ad2 Compare September 21, 2024 09:50
Copy link
Collaborator Author

@dean-starkware dean-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Arcticae, @Draggu, @gilbens-starkware, @mkaput, and @orizi)


crates/cairo-lang-parser/src/parser_test_data/partial_trees/expr line 79 at r5 (raw file):

Previously, orizi wrote…

Also, can you print the actual operators instead, or.only the names are possible?

Done.


crates/cairo-lang-parser/src/parser_test_data/partial_trees/expr line 79 at r5 (raw file):

Previously, orizi wrote…

Should be comparison

Done.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 4 files at r9, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Arcticae, @Draggu, @gilbens-starkware, and @mkaput)

Copy link
Collaborator Author

@dean-starkware dean-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Arcticae, @Draggu, @gilbens-starkware, and @mkaput)

@dean-starkware dean-starkware added this pull request to the merge queue Sep 22, 2024
Merged via the queue into main with commit b20acc4 Sep 22, 2024
43 checks passed
@orizi orizi deleted the dean/consecutive_math_operators_in_parser branch September 22, 2024 12:40
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