enterXXX for alt label never gets called
- Dominant language
- Java
- Stars
- 19k
- Forks
- 3.5k
- PR merge metrics
- No merged PRs in 30d
Description
The test case below prints:
```
exiting alt1
```
but I'd expect it to print:
```
entering alt1
exiting alt1
```
```
grammar Test;
a
: 'b' #alt1
| 'c' #alt2
;
```
``` java
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.misc.NotNull;
public class Main
{
public static void main(String[] args)
{
TestParser parser = new TestParser(new CommonTokenStream(new TestLexer(new ANTLRInputStream("b"))));
parser.addParseListener(new TestBaseListener() {
@Override
public void enterAlt1(@NotNull TestParser.Alt1Context ctx)
{
System.out.println("entering alt1");
}
@Override
public void exitAlt1(@NotNull TestParser.Alt1Context ctx)
{
System.out.println("exiting alt1");
}
});
parser.a();
}
}
```
Contributor guide
Research direction
Start with the Test grammar and the Java listener reproduction, then inspect how the generated parser and TestBaseListener dispatch callbacks for the labeled alternative in parser.a(). Done means running the example prints "entering alt1" before "exiting alt1".
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
- 35/100