473,802 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3505
"Mike Rovner" <mi**@nospam.co m> 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.co m> 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.co m> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6064
by: Will Stuyvesant | last post by:
There seems to be no XML parser that can do validation in the Python Standard Libraries. And I am stuck with Python 2.1.1. until my web master upgrades (I use Python for CGI). I know pyXML has validating parsers, but I can not compile things on the (unix) webserver. And even if I could, the compiler I have access to would be different than what was used to compile python for CGI. I need to write a CGI script that does XML validation...
2
3939
by: Thomas Guettler | last post by:
Hi! What are the difference between xml.parsers.expat and xml.sax? Up to now I used xml.sax.make_parser and subclass from ContentHandler. I think xml.sax.make_parser uses expat as default. Why should I want to use xml.parsers.expat?
2
1488
by: Dale Strickland-Clark | last post by:
A few days ago there was a discussion about which XML parser to use with Python. However, the discussion didn't cover validating parsers, at least, not w3.org XML Schemas. I looked into all the parsers that came up in the discussion but found no mention of w3.org schemas. It seems there are a few DTD validating parsers but that's all.
2
1394
by: Nainesh Jhaveri | last post by:
I have a ton of Business logic writter in Java, which I am trying to expose to .NET platform using Visual J#. NET. The java code is making extensive use of java.rmi.* package. but, the latest version of Visual J#. NET is not supporting the same. Is there a way to make this happen. Does any one have any information on migrating java RMI code into .NET platform.
7
2097
by: Nikhil | last post by:
Hi, I was interested in knowing of there are parsers in C than can parse C code in some form of Data Structures and then after some user manuplation, write back the code in a file. A commercial tool which can do that would be the best ... Thanks,
2
3744
by: dwelch91 | last post by:
Hi, c.l.p.'ers- I am having a problem with the import of xml.parsers.expat that has gotten me completely stumped. I have two programs, one a PyQt program and one a command line (text) program that both eventually call the same code that imports xml.parsers.expat. Both give me different results... The code that gets called is (print statements have been added for debugging):
0
3194
by: JosAH | last post by:
Greetings, welcome back at the sequel of the parsers article chapter. This part is dedicated to the ExpressionParser, the largest parser class for our little language. This class parses a complete expression and just like the other parser classes calls the Generator on the fly. When the parse has completed successfully, the generated code is returned. Otherwise the parse is aborted and an exception is thrown telling the reason of the...
0
3382
by: JosAH | last post by:
Greetings, this week's article part discusses the parsers used for our little language. We will implement the parsers according to the grammar rules we defined in the second part of this article. As you will see shortly, the implementation of the parsers is an almost one-to-one translation of those grammar rules. Recursive descent parsing The grammar rules are highly recursive, i.e. one rule mentions another rule
1
4223
by: josh logan | last post by:
Vincent Yau <y...@ohsu.eduwrites: Fast-forward to 2008 I installed Python 3.0b2 on a Windows Vista laptop (after having previously installed Python 2.5), and I am getting this same error: Traceback (most recent call last): File "Programming\Python\monkeys.py", line 24, in <module> test_parse(sys.argv)
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10536
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.