setUnknownTokenBoundaries() sets wrong token boundaries
- Dominant language
- Java
- Stars
- 253
- Forks
- 178
- PR merge metrics
- No merged PRs in 30d
Description
[`CommonTree.setUnknownTokenBoundaries()`](https://github.com/antlr/antlr3/blob/7c46aa9aebc9a5e6999c82d530bb8af566c0823e/runtime/Java/src/main/java/org/antlr/runtime/tree/CommonTree.java#L148) updates token boundaries of an AST node by using the boundaries of the node's first and last child. This seems to assume that the children of the AST are ordered by the token order. However, such an ordering is not enforced when constructing ASTs.
`setUnknownTokenBoundaries()` should be updated to pick the min/max among all of the children instead of just using the first and last child.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in runtime/Java/src/main/java/org/antlr/runtime/tree/CommonTree.java at setUnknownTokenBoundaries() and inspect how child token boundaries are currently selected. Reproduce the case with children that are not in token order and verify the method records the minimum start and maximum stop boundaries across all children.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100