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

J

John J. Lee

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
 
J

John J. Lee

Mike Rovner said:
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.


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
 
M

Mike Rovner

John said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top