Lexer semantic pred ignores fail option
- Dominant language
- Java
- Stars
- 19k
- Forks
- 3.5k
- PR merge metrics
- No merged PRs in 30d
Description
In the following grammar, the exact same .java lexer is generated, whether or not the fail option is present on the semantic predicate. It makes logical sense that no message is generated when the lexer rule fails; however, we should warn the programmer that they are trying to accomplish something that is impossible when they include the fail option.
``` antlr
grammar CharExperiment_02;
stat : 'start' CharacterLiteral 'end' EOF;
// Lexer
CharacterLiteral
: '\'' SingleCharacter '\''
| '\'' {false}? //
;
fragment SingleCharacter : ~['\\\r\n] ;
WS : [ \r\t\n]+ -> skip ;
```
Contributor guide
Research direction
Start by generating the .java lexer from the supplied CharExperiment_02 grammar twice, once with the semantic predicate's fail option and once without it, then compare the results. Done means the generator warns when fail is used on a lexer semantic predicate whose rule can fail without producing a message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100