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
This is a bug that I found while trying to validate the parse trees produced for input across different ports (aka "target"). The problem is specifically in the JavaScript runtime, at this line:
The problem is that the token referenced is out of bounds for the array.
For grammar antlr/antlr4, input LexerElementLabel.g4, the parse tree is wrong for the JavaScript target.
$ git diff .
diff --git a/antlr/antlr4/examples/LexerElementLabel.g4.tree b/antlr/antlr4/examples/LexerElementLabel.g4.tree
index 24a5362f..1379cabe 100644
--- a/antlr/antlr4/examples/LexerElementLabel.g4.tree
+++ b/antlr/antlr4/examples/LexerElementLabel.g4.tree
@@ -1 +1 @@
-(grammarSpec (grammarDecl (grammarType lexer grammar) (identifier LexerElementLabel) ;) (rules (ruleSpec (lexerRuleSpec Token : (lexerRuleBlock (lexerAltList (lexerAlt lexerElements))) <missing SEMI>)) (ruleSpec (parserRuleSpec var = 'token' ;))) <EOF>)
\ No newline at end of file
+(grammarSpec (grammarDecl (grammarType lexer grammar) (identifier LexerElementLabel) ;) (rules (ruleSpec (lexerRuleSpec Token : (lexerRuleBlock (lexerAltList (lexerAlt lexerElements))) <missing undefined>)) (ruleSpec (parserRuleSpec var = 'token' ;))) <EOF>)
\ No newline at end of file
diff --git a/antlr/antlr4/examples/three.g4.tree b/antlr/antlr4/examples/three.g4.tree
index efea5989..82075168 100644
--- a/antlr/antlr4/examples/three.g4.tree
+++ b/antlr/antlr4/examples/three.g4.tree
@@ -1 +1 @@
-(grammarSpec (grammarDecl grammarType identifier <missing SEMI>) rules <EOF>)
\ No newline at end of file
+(grammarSpec (grammarDecl grammarType identifier <missing undefined>) rules <EOF>)
\ No newline at end of file
01/03-16:21:24 ~/issues/g4-all-trees/antlr/antlr4/examples
The runtime references the array recognizer.literalNames[expectedTokenType] directly, and out of bounds for the value of expectedTokenType. The code should be making a method call, to recognizer.Vocabulary.GetDisplayName(expectedTokenType).
Python3 may have a similar issue.
The workaround is to not save parse trees for input that we know have a parse error.
The text was updated successfully, but these errors were encountered:
kaby76
changed the title
[JavaScript runtime] The JavaScript runtime does not use the correct name for getMissing Symbol().
[JavaScript runtime] The JavaScript runtime does not correct error node name in parse tree.
Jan 4, 2025
This is a bug that I found while trying to validate the parse trees produced for input across different ports (aka "target"). The problem is specifically in the JavaScript runtime, at this line:
antlr4/runtime/JavaScript/src/antlr4/error/DefaultErrorStrategy.js
Line 529 in 6722835
The problem is that the token referenced is out of bounds for the array.
For grammar antlr/antlr4, input LexerElementLabel.g4, the parse tree is wrong for the JavaScript target.
The runtime references the array
recognizer.literalNames[expectedTokenType]
directly, and out of bounds for the value ofexpectedTokenType
. The code should be making a method call, torecognizer.Vocabulary.GetDisplayName(expectedTokenType)
.Python3 may have a similar issue.
The workaround is to not save parse trees for input that we know have a parse error.
Cpp
Dart
Go
Java
Python3
Swift
The text was updated successfully, but these errors were encountered: