-
Notifications
You must be signed in to change notification settings - Fork 429
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
Fix SHARPOP precedence #2050
Fix SHARPOP precedence #2050
Conversation
A potential problem might be: $ echo 'foo#= bar[0]' | ./_build/install/default/bin/refmt -p ml
;;(foo #= bar).(0) I don't think this is right, but we can special case it in the lexer. |
Just fixed the issue pointed out in my last comment with the latest commit. |
src/reason-parser/reason_parser.mly
Outdated
@@ -1209,6 +1209,7 @@ let package_type_of_module_type pmty = | |||
%token SEMISEMI | |||
%token SHARP | |||
%token <string> SHARPOP | |||
%token SHARPOP_WITH_EQUAL |
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.
can you rename this to SHARPEQUAL
? SHARPOP_WITH_EQUAL
conveys # with =
, if you look at the other token names.
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.
definitely
src/reason-parser/reason_lexer.mll
Outdated
} | ||
| "#" operator_chars+ | ||
{ SHARPOP(lexeme_operator lexbuf) } | ||
{ let l = lexeme_operator lexbuf in | ||
if l = "#=" then |
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 wonder if we should add | "#=" { SHARPEQUAL }
for clarity in the lexer. No hard opinions 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.
I think that's better too, will incorporate.
Just pushed the suggested changes. |
M-m-merged! |
…ce, parens unnecessary on the right side
…ce, parens unnecessary on the right side
…ce, parens unnecessary on the right side
…ce, parens unnecessary on the right side
…ce, parens unnecessary on the right side
…ce, parens unnecessary on the right side
…ce, parens unnecessary on the right side
* Syntax sugar `["literal_string"]` for SHARPOPs `##` and `#=` * rebase on master after #2050, parse `#=` with higher precedence, parens unnecessary on the right side * array, string and bigarray get also get `#=` -> `=` * rebase on fast pipe fix * small refactor * Fix printer after rebase (caused by earlier refactor) * fix tests after rebase * Fixes after rebase
fixes #1507 #774
Not really sure how to write tests for this one.
I verified the following expressions manually: