I want to run a Lexer for Java in Python using Antlr
For Antlr4, I am using the Java8 grammar from https://github.com/antlr/grammars-v4/tree/master/java8.
I am generating the parser using
java -jar antlr-4.5.2-complete.jar -Dlanguage=Python2 ./Java8.g4
Now if I look at the generated Java8Lexer.py, it contains
return Character.isJavaIdentifierStart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))
I don't think that the type cast is valid python and it throws a syntax error there when I use it.
I had a similar problem using antlr3 using a antlr3 java 1.6 grammar. It generated
boolean isSomething = something
which is also not valid Python.
Am I missing something? Is there any way to use a Java Lexer in Python using antlr?