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

"source_file" allows "BLANK" to follow "_top_level_declaration" #46

Closed
berchn opened this issue May 10, 2021 · 1 comment · Fixed by #120
Closed

"source_file" allows "BLANK" to follow "_top_level_declaration" #46

berchn opened this issue May 10, 2021 · 1 comment · Fixed by #120

Comments

@berchn
Copy link

berchn commented May 10, 2021

source_file allows BLANK to follow _top_level_declaration in src/grammar.json. This is resulting in an AST that doesn't appear to be valid. The following code parses without error or the addition of any zero-width tokens, but it does not compile:

package a package b package c package d

This is due to the optional(terminator) in the relevant section of the source_file rule in grammar.js. Is this intended?

@adonovan
Copy link
Contributor

adonovan commented Mar 22, 2022

The optionality should be removed here, but I think it might require additional handling to ensure that EOF inserts a final newline (terminator):

seq($._top_level_declaration, optional(terminator)),

I suspect in practice it's less trouble to make the parsers overgenerous in what they accept than to have to analyze the dark corners perfectly (where compilers often have bugs too).

@amaanq amaanq mentioned this issue May 22, 2023
5 tasks
@amaanq amaanq mentioned this issue Jun 5, 2023
5 tasks
@aryx aryx closed this as completed in #120 Jun 6, 2023
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 a pull request may close this issue.

2 participants