I'm using ANTLRWorks 1.5.2 for grammar creation and subsequent creation of the lexer and parser. I did that for Java target, but my preferred language is python. I'm quite puzzled by this: how can I specify my target language in ANTLRWorks 1.5.2 and get lexer and parser in python? I read somewhere that antlrworks in just for java target. How can I install antlr3 and use python runtime? I would be really appriciate if anyone can guid me. thanks.
Asked
Active
Viewed 1,936 times
1 Answers
2
If you use the following options {...}
block in your grammar:
options {
language=Python;
}
and then press CTRLSHIFT + G from within ANTLRWorks, the *.py
lexer and parser files will be generated in the grammar's output/
directory.
However, debugging from within ANTLRWorks only works with the Java target.
As for a complete Python example, checkout this previous Q&A: ANTLR get and split lexer content

Community
- 1
- 1

Bart Kiers
- 166,582
- 36
- 299
- 288
-
Thanks for sharing your knowledge! I was really stuck at this point, as usual your help was very helpful and wise :) – sara Jul 23 '14 at 15:02
-
Is there any way to get Python lexer and parser in ANTLRWorks 2.1 ? – sara Jul 24 '14 at 07:14
-
No, grammars written for ANTLR3 cannot be used in ANTLRWorks2. ANTLRWorks2 works only with ANTLR4 grammars (and StringTemplates). However, there are [Python-2](https://github.com/antlr/antlr4-python2) and [-3](https://github.com/antlr/antlr4-python3) runtimes for ANTLR4 in the making which can (probably) be used with ANTLRWorks2. – Bart Kiers Jul 24 '14 at 07:40
-
I have one more question, now I'm using ANTLR and PyDev plugins for eclipse,Is it possible to generate lexer and parser in python language by eclipse? – sara Aug 05 '14 at 13:43
-
could you please tell me which tool is proper for using lexer and parser files in python language? (I want to use these files and execute data from input files) – sara Aug 06 '14 at 08:24