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

ParserRuleContext.stop is null with all optional rule? #4531

Open
neon12345 opened this issue Feb 17, 2024 · 3 comments
Open

ParserRuleContext.stop is null with all optional rule? #4531

neon12345 opened this issue Feb 17, 2024 · 3 comments

Comments

@neon12345
Copy link

There is

functionQualifiers : 'const'? 'async'? 'unsafe'? ('extern' abi?)? ;

in the rust grammar from grammars-v4. This seems to give an empty stop on the FunctionQualifiersContext. Is this intentional?

@KvanTTT
Copy link
Member

KvanTTT commented Feb 17, 2024

You probably would like to raise the issue in grammars-v4 repository?

@neon12345
Copy link
Author

You probably would like to raise the issue in grammars-v4 repository?

It seems this is true for every grammar with a similar rule as the first in a file. This is an antlr implementation detail/edge case I have not seen so far. I assume a null check on ParserRuleContext.stop is mandatory?

@jimidle
Copy link
Collaborator

jimidle commented Feb 17, 2024

This is poorly specified but empty rules can be useful. I cannot remember if Rust requires a specific order but generally I woudl do something like this:

fundef: fq+=funQual* .... ; // named is not required - personal preference

funQual: const | async | unsafe | extern abi? ;

Then you test fq in your tree walk/visit

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

3 participants