[antlr-interest] The Python target is in fact Jython target?
Benjamin Niemann
pink at odahoda.de
Tue Jun 19 04:20:17 PDT 2007
Hello,
Tzu-Chien Chiu wrote:
> I was looking for a decent Python parser for C source files, and I found
> ANTLR.
>
> I am not an expert of Python nor Jython, but it seems to me that the
> Python runtime package 'antlr3' comes with ANTLR source distribution
> is for Jython because it imports java.util.Set and java.utl.HashSet.
No, the Python target is for CPython. It may also work with Jython or
IronPython, but I have not tested this.
> Some references:
>
> [1] A message in 2003 said the Python code generation target is in
> fact for Jython. Is this status up to date?
No. Much has change in the last four years.
> <code file="CParserParser.py">
> # $ANTLR 3.0 CParser.g 2007-06-18 19:07:46
>
> from antlr3 import *
> from antlr3.compat import set, frozenset
>
> import java.util.Set;
> import java.util.HashSet;
> ....
> class Symbols_scope(object):
> def __init__(self):
> self.Set types = None // Line 57
> </code>
These imports probably come from the grammar file. Which grammar are you
using? It usually needs more work than setting "language=Python" to get a
grammar working with another target than the original one.
There is a C grammar adapted for Python in runtime/Python/examples/C/ of the
source dist.
HTH
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
More information about the antlr-interest
mailing list