Duplicate members in C runtime with imports: duplicate member 'g'
- Dominant language
- Java
- Stars
- 253
- Forks
- 178
- PR merge metrics
- No merged PRs in 30d
Description
## Steps to reproduce
```
// Option.g
grammar Option;
options {
language=C;
}
import Option2, Option3;
source
: source_item+
;
```
```
// Option2.g
parser grammar Option2;
source_item
: test
;
```
```
// Option3.g
parser grammar Option3;
test
: 'a'
;
```
Generate C code:
```
java -jar antlr-complete-3.5.3.jar Option.g
```
In `OptionParser.h` struct elements have duplicated names:
```c
// OptionParser.h
struct OptionParser_Ctx_struct
{
pANTLR3_PARSER pParser;
pOption_Option2 g;
pOption_Option3 g;
...
};
```
## Expected behavior
No duplicated names.
Like when using Java runtime:
```Java
@SuppressWarnings("all")
public class OptionParser extends Parser {
// delegates
public Option_Option2 gOption2;
public Option_Option3 gOption3;
public Parser[] getDelegates() {
return new Parser[] {gOption2, gOption3};
}
...
}
```
## Versions
```
Java: openjdk 17.0.12 2024-07-16
ANTLR3: 3.5.3
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the generation using Option.g, Option2.g, and Option3.g with the shown Java command, then inspect the generated OptionParser.h. Compare the C delegate members with the Java output and verify that the generated C struct contains distinct names for the imported grammars.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, java
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100