Command antlr4-parse -Dlanguage=Python3 test.g4
gives me this error.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2
at org.antlr.v4.gui.Interpreter.<init>(Interpreter.java:86)
at org.antlr.v4.gui.Interpreter.main(Interpreter.java:276)
I am trying to create a lexer, parser, and listener for Python.
Using antlr4-parse and test.g4, I was able to evaluate input code, so I know it works.
I have checked and rechecked the grammar file and can find no syntax errors. Everything looks correct.
The command antlr4-parse
can be used to test a parser rule from your grammar. For example, if your grammar looks like this:
grammar test;
startRule
: ANY* EOF
;
ANY
: .
;
then you can test startRule
like this:
antlr4-parse test.g4 startRule -gui input.txt
where the file input.txt
contains the text you would like to parse.
If you just want to generate the Python lexer and parser classes, you can use antlr4
(not antlr4-parse
):
antlr4 -Dlanguage=Python3 test.g4
1