Dynamically-Scoped Attributes generate error(33): missing code generation template SetNonLocalAttrHeader ONLY in C++ target.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 19k
- Forks
- 3.5k
- PR merge metrics
- No merged PRs in 30d
Description
Target: c++
Generating parser code with ANTLR 4.13.0
Expected behavior: does not trigger any error .
Actual behavior: triggers an `error(33): missing code generation template SetNonLocalAttrHeader`
The DynScope grammar from the doc triggers the error. (from "Actions and Attributes" chapter, exactly as it is in it.)
`antlr4 -Dlanguage=Java DynScope.g4` works
`antlr4 -Dlanguage=PHP DynScope.g4` works
`antlr4 -Dlanguage=JavaScript DynScope.g4` works
`antlr4 -Dlanguage=Cpp DynScope.g4` does not work and generate the error(33).
Here is a simplified version of the grammar that triggers the same error:
```
grammar DynScope;
prog: block ;
block locals [int myInt = 0;]
: '{' decl* '}'
;
decl:
'int' INT {$block::myInt += 1;} ';'
;
INT : [0-9]+ ;
WS : [ \t\r\n]+ -> skip ;
```
if i just comment the `{$block::myInt+=1;} ';'`, no errors is triggered.
like that:
```
grammar DynScope;
prog: block ;
block locals [int myInt = 0;]
: '{' decl* '}'
;
decl:
'int' INT // {$block::myInt += 1;} ';'
;
INT : [0-9]+ ;
WS : [ \t\r\n]+ -> skip ;
```
replacing `{$block::myInt += 1;}` by `{((BlockContext*)$ctx->parent)->myInt +=1 ;}` seems to work properly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the DynScope grammar from the “Actions and Attributes” documentation and reproduce the failure using `antlr4 -Dlanguage=Cpp DynScope.g4`; compare it with the Java, PHP, and JavaScript generations that succeed. Done means C++ generation no longer reports the missing `SetNonLocalAttrHeader` template for dynamically scoped attributes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100