Skip to content

Avoid ambiguities#63

Open
sharwell wants to merge 3 commits intodaniellansun:masterfrom
sharwell:avoid-ambiguities
Open

Avoid ambiguities#63
sharwell wants to merge 3 commits intodaniellansun:masterfrom
sharwell:avoid-ambiguities

Conversation

@sharwell
Copy link
Copy Markdown
Contributor

Addresses some specific ambiguities I observed.

Comment on lines +258 to +266
: LBRACE
(
/* Only enum can have enum constants */
{ 2 == $t }?
enumConstants? sep?
nls enumConstants
|

)
classBodyDeclaration[$t]? (sep classBodyDeclaration[$t])* sep? RBRACE
sep?
(classBodyDeclaration[$t] (sep classBodyDeclaration[$t])*)? sep? RBRACE
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

📝 This change falls out from the following in the original rule:

classBodyDeclaration[$t]? (sep classBodyDeclaration[$t])*

While it was perhaps not intentional, one interpretation of this is:

(sep classBodyDeclaration[$t])+

Which means sep can appear before the first classBodyDeclaration for enum types or any other type. This allowed me to extract the sep? from the enum-specific alternative, and leverage that for the nls following LBRACE in non-enum types.

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.

1 participant