antlr / antlr/antlr4

[Python3] TokenStreamRewriter: Interval missing start and stop fields

Open
#2,020 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
19k
Forks
3.5k
PR merge metrics
No merged PRs in 30d

Description

In TokenStreamRewriter, the function getText() tries to access fields start and stop of provided interval argument
```
start = interval.start
stop = interval.stop

```
However, it seems that interval is an ordinary tuple. Therefore, what works is

```
start = interval[0]
stop = interval[1]

```

I also checked in the rest of the codebase, and the suggested fix was done in e.g. BufferedTokenStream.
Does this change make sense?

Contributor guide

Open the contributing guide

Research direction

Start in the Python3 TokenStreamRewriter implementation and inspect getText(), then compare its interval handling with BufferedTokenStream, where tuple indexing is already used. Verify that getText() accepts ordinary tuple intervals and that the relevant existing tests, if located, still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.