-
Notifications
You must be signed in to change notification settings - Fork 260
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
[BUG] Compound assignment chosen over postfix operator #388
Comments
Thanks. It's max munch... Distilling even slightly further:
That should clearly be compound assignment [edit: and semantically illegal since we can't multiply-assign pointers] even without the whitespace, I think... what do you think? |
Thank you. I'll have to study this. |
I should distill even further:
|
Maybe later. I remembered what should be the source of this parsing terminology. Translation phase 3 tokenizes before phase 7 reads the sequence according to the grammar. |
The max much rule must come from
|
Is it safe to say that https://eel.is/c++draft/lex#digraph doesn't apply to Cpp2, and |
Right, Cpp2 eliminates all the things on this cppreference page as special features... no digraphs or trigraphs as they aren't among the specified tokens, and no alternative operator macro names which were reclaimed for normal use in #328. |
Title: Compound assignment chosen over postfix operator
This seems at odds with
https://github.com/hsutter/cppfront/wiki/Design-note:-Unambiguous-parsing,
https://github.com/hsutter/cppfront/wiki/Design-note%3A-Postfix-operators, and
https://github.com/hsutter/cppfront/wiki/Design-note%3A-Postfix-unary-operators-vs-binary-operators.
Minimal reproducer (https://godbolt.org/z/PYEnvh6Px):
Commands:
cppfront x.cpp2 clang++17 -std=c++2b -stdlib=libc++ -I $CPPFRONT_INCLUDE_DIR x.cpp
Expected result:
*&v0 = 1
to be generated instead of&v0 *= 1
,because
v0&*
can be parsed as a postfix-expressionbecause
v0&
can be parsed as a postfix-expressionbecause
v0
can be parsed as a postfix-expressionand those match first,
before
assignment-expression assignment-operator logical-or-expression
has a chance to use
*=
as an assignment-operator,and because the leftover
= 1
can match thatassignment-operator logical-or-expression
.Actual result and error:
Generated Cpp1.
The text was updated successfully, but these errors were encountered: