473,802 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

flex/bison like module in Python?

Dear Pythonists;

Curious if there exists in Python package(s) for use as lexer/parser
for implementation of language grammars?

Already using cmd.py from the standard distro for it's basic features
but wishing for much more advanced capability. As such, I refer to
flex/bison because though complex they are general purpose and very
useful.

I am trying to avoid having to do the lexer/parser part in C if
possible.

Thanks.

--
-------------------------------------------------------------------------------
Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant
305 321-1144 (mobile http://www.JerrySievers.com/
Jul 18 '05 #1
4 7146
"Jerry Sievers" <je***@jerrysie vers.com> wrote in message
news:m3******** ****@prod01.jer rysievers.com.. .
Dear Pythonists;

Curious if there exists in Python package(s) for use as lexer/parser
for implementation of language grammars?

Already using cmd.py from the standard distro for it's basic features
but wishing for much more advanced capability. As such, I refer to
flex/bison because though complex they are general purpose and very
useful.

I am trying to avoid having to do the lexer/parser part in C if
possible.

Thanks.

--
-------------------------------------------------------------------------- ----- Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant
305 321-1144 (mobile http://www.JerrySievers.com/


Check out this page from the Python Wiki:
http://www.python.org/moin/LanguageParsing

(although I'm partial to pyparsing, myself...)

-- Paul
Jul 18 '05 #2
Jerry Sievers wrote:
Curious if there exists in Python package(s) for use as lexer/parser
for implementation of language grammars?


(s) indeed:

http://www.nedbatchelder.com/text/python-parsers.html

</F>

Jul 18 '05 #3
You may checkout

www.antlr.org

around Xmas - a extension for Python will be released.

Regards,
Wolfgang.

"Jerry Sievers" <je***@jerrysie vers.com> wrote in message
news:m3******** ****@prod01.jer rysievers.com.. .
Dear Pythonists;

Curious if there exists in Python package(s) for use as lexer/parser
for implementation of language grammars?

Already using cmd.py from the standard distro for it's basic features
but wishing for much more advanced capability. As such, I refer to
flex/bison because though complex they are general purpose and very
useful.

I am trying to avoid having to do the lexer/parser part in C if
possible.

Thanks.

--
-------------------------------------------------------------------------------
Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant
305 321-1144 (mobile http://www.JerrySievers.com/

Jul 18 '05 #4

For command line parsing, take a look at the shlex module, also in the
standard distro. It may fit your requirements for additional
functionality beyond cmd.

/Jean Brouwers

PS) We use SimpleParse/mxTextTools for parsing large log files, both
are listed on the web page mentioned below. In addition, check out
David Mertz' web pages 'Text Processing in Python' at

<http://gnosis.cx/TPiP/>

In article <ma************ *************** ***********@pyt hon.org>,
Fredrik Lundh <fr*****@python ware.com> wrote:
Jerry Sievers wrote:
Curious if there exists in Python package(s) for use as lexer/parser
for implementation of language grammars?


(s) indeed:

http://www.nedbatchelder.com/text/python-parsers.html

</F>

Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3621
by: Peter Kleiweg | last post by:
Hi, I am looking for a Python equivalent of Flex. After some browsing, it seems that Plex is my best bet, but I would like to hear suggestions before I dive in. I have been using Flex a lot in combination with C programming. I never use Yacc (or Bison), though Flex and Yacc are supposed to be used together. But I found Yacc too cumbersome, and unnecessary. Yacc is about context-free grammars, nice if you
4
10940
by: Uwe Ziegenhagen | last post by:
Hello, my fellows and me implement a c++ tool that is able to divide blank/tab separated files into <number>, <text>, <c-singlelinecomment> and <multilinecomment>. So far it's not working bad, we have just one problem if I call the a.exe that gcc compiles with the following textfile (./a.exe < test.txt) he does not match the multiline comments correctly. *test.txt contains:
0
2594
by: Tom Heathcote | last post by:
Apologies for posting a flex++ question rather than a C++ question, but there does not appear to be a flex++ newsgroup... I am trying to rebuild some old lexical scanner / analyzer code, which I believe was generated by flex++/bison++. The rebuild is required because existing code is only a 7-bit scanner (uses char rather than unsigned char as its character type, and the tables only go up to 127) and I need to work with 8-bit input.
2
6596
by: olig9 | last post by:
Hello, is there a way to feed an ifstream to a parser generated with flex and bison? I could see that flex wants a FILE* for reading, but I only have an ifstream (actually and ifstream*) for input. It seems that flex++ can use an ifstream; but how does the generated lexer then work with bison? Or is there a (portable) way to get a FILE* from an ifstream? Thanks in advance, Oliver Gerlich
8
16848
by: pavel.orehov | last post by:
Hi, I am using flex and bizon to write HTTP parser. I am passing well flex and bison tools but can't compile their output. ================= Flex file (http_parser.lpp) ============== %{ #include <iostream> #include "http_parser.tab.hpp"
4
5398
by: daniele.calisi | last post by:
Hi everyone, after some days spent in long searches with google, I still not have found a solution with this problem: I need to use flex (or flex++) and bison (but not bison++) in order to create a simple expression parser (that reads from a string, but this is another problem) I have problems with the fact that I cannot use bison++, and bison creates a c file... do you have any simple tutorial on how create such
2
5118
by: eng.sharif | last post by:
i want use bison and flex in visual stdio 2005 for make small compiler by use Custom Build Rules in Visual C++ 2005 "FlexBison.rules file " but when i compile "example.y" i get error ------------------------------------------------------------------------------------------ bison.simple: No such file or directory bison: Project : error PRJ0019: A tool returned an error code from bison Project : error PRJ0002 : Error result 1 returned...
1
2276
by: eng.sharif | last post by:
want use bison and flex in visual stdio 2005 for make small compiler by use Custom Build Rules in Visual C++ 2005 "FlexBison.rules file " but when i compile "example.y" i get error ---------------------------------------------------------------------------­--------------- bison.simple: No such file or directory bison: Project : error PRJ0019: A tool returned an error code from bison
3
3345
by: Tinkertim | last post by:
Hello to all, I've been using C for a long time however I'm about to take my first splash into making a parser. I have some interesting things to accomplish and I'm hoping to get some recommended links to tutorials that might help me jump in. I will be parsing a configuration file, like this: vars {
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
10305
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
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
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.