[antlr-interest] Python support for ANTLR
marqkole
marq.kole at philips.com
Mon Nov 1 01:13:02 PST 2004
All,
A few weeks ago (just before the ANTLR workshop in SFO) I managed to
get a pure Python version of ANTLR working on the calc example.
However, there are still a few problems in de code generator that
need to be sorted out, so I am asking for help. I will post the
ANTLR-Python stuff as a patch on the antlr-2.7.4 code in the files
section of this group.
To get this working, you need to have everything available to build
ANTLR and also have a recent (newer than version 2.1) Python on your
system. Then do the following (UNIX only):
1. untar the antlr-2.7.4 archive
gtar zxf antlr-2.7.4.tar.gz
2. patch the antlr-2.7.4 directory with the antlr-python patch
patch -p0 < antlr-2.7.4-python-041101.diff
3. Enter the antlr-2.7.4 directory and configure and build antlr as
usual.
4. Go to the lib/python directory and run
python setup.py install
This will build and install the ANTLR-Python runtime
5. Go to the examples/python/calc directory and build and run the
example.
antlr calc.g
python Calc.py < test.in
The problems I have currently are in the examples/python/lexertester
directory. There are a few simple tests here, but the generated code
will give errors due to incorrect indentation. Explanation: instead
of braces, Python uses indentation to mark blocks of code. In the
case of the generated code, the opening brace could be replaced by
an if statement that is always open (example: "if True:") followed
by an increased indentation level, while the closing brace can be
replaced by just a decreased indentation level. My problem is that I
just can't find where to do this for a single action item, such as a
pair of spurious braces. Just have a look at the generated code in
the lexertester examples to see what I mean.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list