-
Notifications
You must be signed in to change notification settings - Fork 162
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
Changes made to ensure that '=>' token is parsed properly #3292
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks @sriganeshres for contributing!! Could you add a testcase to your PR to ensure we don't introduce a regression on this in the future?
b86ad1a
to
62abc58
Compare
Working on that. I have ran Thank You. |
5aca0e5
to
7897d6e
Compare
gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_expr): Updated parsing logic to stop on encountering '=>' or ',' while having restrictions.stop_on_token turned on. (Parser::left_denotations): Updated to stop parsing on the special tokens mentioned above. (Parser::null_denotation): Updated to stop parsing on the special tokens mentioned above. * parse/rust-parse.h (struct ParseRestrictions): Added a field stop_on_token (default false) to maintain the above functionality.
7897d6e
to
e7e7360
Compare
You could write a test from the snippet given in the fixed issue, it would pass with your changes |
* rust/compile/issue-3099.rs: Added a new test for issue-3099 to parse '=>' properly.
@@ -89,6 +89,8 @@ struct ParseRestrictions | |||
bool entered_from_unary = false; | |||
bool expr_can_be_null = false; | |||
bool expr_can_be_stmt = false; | |||
bool stop_on_token | |||
= false; // This is for stopping parsing at a specific token |
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.
What does this mean? It seems like a hack
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.
This doesnt seem correct to me the stop_on_token doesn't seem to be set to true anywhere so to me this doesn't seem to solve anything
gcc/rust/ChangeLog:
Fixes #3099
Here is a checklist to help you with your PR.
make check-rust
passes locallyclang-format
gcc/testsuite/rust/
Parser::parse_expr
,Parser::left_denotations
,Parser::null_denotation
So that they stop on special token like=>
and,
. They would terminate the parsing to allow exatract expression.