antlr4
antlr4 copied to clipboard
ParserRuleContext.stop is null with all optional rule?
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?
You probably would like to raise the issue in grammars-v4 repository?
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?
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