antlr / antlr/antlr3

Issue with rules that have a return value named "values" in antlr 3.5

Open
#108 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
253
Forks
178
PR merge metrics
No merged PRs in 30d

Description

I'm trying to upgrade from ANTLR 3.2 to 3.5, and ran into a somewhat bizarre issue - the generated code for a couple of the rules did not have a return value, and wouldn't compile.

After playing around with it for a while, I finally figured out that this only seems to happen if the name of the return value for the rule is `values`. Renaming the return value to something else fixes the problem.

Here is a test grammar that shows the issue:

``` antlr
tree grammar test;

options {
ASTLabelType=CommonTree;
}

tokens {
TEST_TOKEN;
}

test_rule returns[int[\] values] : TEST_TOKEN {
$values = new int[]{5};
};
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the provided ANTLR test grammar and generate its code under ANTLR 3.5, then compare the result with 3.2 to isolate how the return value named "values" is handled. Done means the generated code preserves the return value and compiles without requiring the grammar author to rename it.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.