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

Consider simplifying parenthesized_expression #144

Open
DavisVaughan opened this issue Sep 17, 2024 · 1 comment
Open

Consider simplifying parenthesized_expression #144

DavisVaughan opened this issue Sep 17, 2024 · 1 comment

Comments

@DavisVaughan
Copy link
Member

DavisVaughan commented Sep 17, 2024

tree-sitter-r/grammar.js

Lines 282 to 286 in 4279b69

parenthesized_expression: $ => withPrec(PREC.BLOCK, seq(
field("open", $._open_parenthesis),
repeat(field("body", choice($._expression, $._newline))),
field("close", $._close_parenthesis)
)),

  • I don't think the $._newline is doing anything. The external scanner consumes newlines proactively when you are within () (unlike { for braced_expression, where it is needed)
  • I think we should also limit it to exactly 1 field("body", $._expression), rather than allowing for multiple, since R doesn't actually allow this for parenthesized expressions (note, not optional()! see Kevin's comments below)
@kevinushey
Copy link
Collaborator

In addition, () alone is technically a parser error -- R requires there to be exactly one expression within the parentheses. The original definition was motivated by the "permissive" style parser but it sounds like we're moving away from that.

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

No branches or pull requests

2 participants