You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For Cpp, Go, JavaScript, Python2/3 target languages version 4.7 throws such errors while generating code:
error(32): code generation template recRuleAltStartAction has missing, misnamed, or incomplete arg list; missing isListLabel
For the rest of the languages it works.
I believe that the error is in the templates since in the recRuleAltStartAction templates for the problematic languages argument isListLabel is not present while in the templates of the ok-languages it is present.
Hi,
this grammar also fails in the Java reference implementation, although at a later stage:
./var/folders/7z/rdw_873x3_s5zr8pb81k9z7c0000gn/T/BaseJavaTest-main-95208223142060/TParser.java:173: error: incompatible types: ExpressionContext cannot be converted to List<ExpressionContext>
_localctx.args = _prevctx;
^
/var/folders/7z/rdw_873x3_s5zr8pb81k9z7c0000gn/T/BaseJavaTest-main-95208223142060/TParser.java:206: error: incompatible types: ExpressionContext cannot be converted to List<ExpressionContext>
_localctx.args = _prevctx;
Not sure if this is bug in ANTLR or in the grammar, but I’d suggest getting this right with the reference implementation first.
@parrt can you have a look (I’ve added a test descriptor, see enclosed)
Eric
Le 19 sept. 2017 à 05:27, Andrew Pashkin ***@***.***> a écrit :
Here is an example grammar:
grammar Test;
expression: op=NOT args+=expression
| args+=expression (op=AND args+=expression)+
| args+=expression (op=OR args+=expression)+
| IDENTIFIER
;
AND : 'and' ;
OR : 'or' ;
NOT : 'not' ;
IDENTIFIER : [a-zA-Z_][a-zA-Z0-9_]* ;
WS : [ \t\r\n]+ -> skip ;
For Cpp, Go, JavaScript, Python2/3 target languages version 4.7 throws such errors while generating code:
error(32): code generation template recRuleAltStartAction has missing, misnamed, or incomplete arg list; missing isListLabel
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#2016>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ADLYJCko1tuiC7EHc03BjAdNFbVWnNiLks5sjuA5gaJpZM4PbjXV>.
Le 20 sept. 2017 à 04:04, Terence Parr ***@***.***> a écrit :
With the Java target, all is ok:
varmint:/tmp $ alias a4.7.1
alias a4.7.1='java -cp "/Users/parrt/.m2/repository/org/antlr/antlr4/4.7.1-SNAPSHOT/antlr4-4.7.1-SNAPSHOT-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
varmint:/tmp $ a4.7.1 Test.g4
varmint:/tmp $
Looks like Swift, Java, C# are ok and have this argument. Probably should add to others.
It appears to be needed:
recRuleAltStartAction(ruleName, ctxName, label, isListLabel) ::= <<
_localctx = new <ctxName>Context(_parentctx, _parentState);
<if(label)>
<if(isListLabel)>
_localctx.<label>.add(_prevctx);
<else>
_localctx.<label> = _prevctx;
<endif>
<endif>
<if(label)>_localctx.<label> = _prevctx;<endif>
pushNewRecursionContext(_localctx, _startState, RULE_<ruleName>);
>>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
On Sep 19, 2017, at 4:02 PM, ericvergnaud ***@***.***> wrote:
But in Java the generated code won't compile
Envoyé de mon iPhone
> Le 20 sept. 2017 à 04:04, Terence Parr ***@***.***> a écrit :
>
> With the Java target, all is ok:
>
> varmint:/tmp $ alias a4.7.1
> alias a4.7.1='java -cp "/Users/parrt/.m2/repository/org/antlr/antlr4/4.7.1-SNAPSHOT/antlr4-4.7.1-SNAPSHOT-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
> varmint:/tmp $ a4.7.1 Test.g4
> varmint:/tmp $
> Looks like Swift, Java, C# are ok and have this argument. Probably should add to others.
>
>
>
> It appears to be needed:
>
> recRuleAltStartAction(ruleName, ctxName, label, isListLabel) ::= <<
> _localctx = new <ctxName>Context(_parentctx, _parentState);
> <if(label)>
> <if(isListLabel)>
> _localctx.<label>.add(_prevctx);
> <else>
> _localctx.<label> = _prevctx;
> <endif>
> <endif>
> <if(label)>_localctx.<label> = _prevctx;<endif>
> pushNewRecursionContext(_localctx, _startState, RULE_<ruleName>);
> >>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub, or mute the thread.
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
It's a bug in the Java target template.I believe that
<if(label)>_localctx.<label> = _prevctx;<endif>
was left in after creating the if statement right above it. I have created a unit test that should make everybody fail. I will see if I can figure out the other targets.
Activity
ericvergnaud commentedon Sep 19, 2017
parrt commentedon Sep 19, 2017
With the Java target, all is ok:
@ericvergnaud Looks like Swift, Java, C# are ok and have this argument. Probably should add to others.
It appears to be needed:
ericvergnaud commentedon Sep 19, 2017
parrt commentedon Sep 19, 2017
parrt commentedon Sep 21, 2017
It's a bug in the Java target template.I believe that
was left in after creating the
ifstatement right above it. I have created a unit test that should make everybody fail. I will see if I can figure out the other targets.Fix for antlr#2016 for Java, Swift. C# was ok, but other targets are …
parrt commentedon Sep 21, 2017
See PR #2022 I think i have it all fixed but it uncovered a C++ target prediction issue.
12 remaining items
add test for antlr#2016 and fix java.
parrt commentedon Aug 27, 2022
Hoping to resolve with #3841
add test for antlr#2016 and fix java.
add test for antlr#2016 and fix java.
parrt commentedon Aug 28, 2022
C++ and Go fail on this still but runtime now and not compilation.
Merge pull request #3841 from parrt/fix-2016-round-2
parrt commentedon Aug 29, 2022
Fixed-ish by #3841
KvanTTT commentedon Aug 31, 2022
Please close since it's fixed.
fix: #2016 Fix Go template list reference, go runtime and got test te…
fix: antlr#2016 - Generate correct iGo code for lists in a grammar, s…
add test for antlr#2016 and fix java.
fix: antlr#2016 Fix Go template list reference, go runtime and got te…
Typescript target (#4027)