468,241 Members | 1,574 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,241 developers. It's quick & easy.

parsers / lexers usable from Python and Java (and C++/C)?

Are there any parser / lexer generators useable from both CPython and
Java? I don't mind much if the Python-useable output is in Python or
C (as long as the C can be wrapped automatically, of course). If I
could run the same source files through two different tools, that
would be just as good.

I'm aware that I could use ANTLR from Jython or perhaps Python+JPE,
but I was looking for something accessible from CPython without having
Java installed, too (speed, and ease of use direct from C++ and C
would be a bonus). And no, I don't want to use JNI!

Failing that, do tools exist for which one could write spec. files for
lexer / parser generators that produce code useable from CPython, and
then apply some minimal tweaks and run them through another tool(s)
that generates Java code? YAPPS for Python and ANTLR for Java,
perhaps -- anybody tried that?
John
Jul 18 '05 #1
3 3212
"Mike Rovner" <mi**@nospam.com> writes:
John J. Lee wrote:
Are there any parser / lexer generators useable from both CPython and
Java?
PLY (http://systems.cs.uchicago.edu/ply/) implemented entirely in Python,
so it might be possible to use it from both implementations of Python.


No, I really did mean CPython and Java, not CPython and Jython.

You may look at http://www.python.org/cgi-bin/moinmoin/LanguageParsing for
other tools.


Thanks. There doesn't seem to be anything promising there,
unfortunately.

All I've found so far are some threads in which Tim Peters complains
about the lack of a Python interface of some kind to lex. Maybe I can
automatically SWIG-wrap lex's lexers, and use jflex for Java. For
parsing (and maybe lexing too), *maybe* it's possible to auto-wrap the
C++ ANTLR outputs, but wrapping C++ (even generated C++) in an
automated way without pain seems unlikely.
John
Jul 18 '05 #2
John J. Lee wrote:
"Mike Rovner" <mi**@nospam.com> writes:
John J. Lee wrote:
Are there any parser / lexer generators useable from both CPython
and Java?
PLY (http://systems.cs.uchicago.edu/ply/) implemented entirely in
Python, so it might be possible to use it from both implementations
of Python.


No, I really did mean CPython and Java, not CPython and Jython.


Your goal is a little vague for me. Jython IS java.
... wrapping C++ (even generated C++) in an
automated way without pain seems unlikely.


Take a look at boost.python pyste.

Mike


Jul 18 '05 #3
"Mike Rovner" <mi**@nospam.com> writes:
[...]
PLY (http://systems.cs.uchicago.edu/ply/) implemented entirely in
Python, so it might be possible to use it from both implementations
of Python.


No, I really did mean CPython and Java, not CPython and Jython.


Your goal is a little vague for me. Jython IS java.


Oh, you anal hacker, you.

... wrapping C++ (even generated C++) in an
automated way without pain seems unlikely.


Take a look at boost.python pyste.


Cool! There are so many nice cross-language tools out there for
Python now... :-)

Thanks
John
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Will Stuyvesant | last post: by
2 posts views Thread by Thomas Guettler | last post: by
2 posts views Thread by Dale Strickland-Clark | last post: by
2 posts views Thread by Nainesh Jhaveri | last post: by
7 posts views Thread by Nikhil | last post: by
2 posts views Thread by dwelch91 | last post: by
reply views Thread by JosAH | last post: by
reply views Thread by JosAH | last post: by
1 post views Thread by josh logan | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.