473,796 Members | 2,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wanted: C++ parser written in Python

Hello NG,

has anyone written such a thing in python?
Where could I look for?

(I need it for an editor written in wxPython to display function names,
include, global variables, classes, ... in a sidepanel).

kind regards,
--
Franz Steinhaeusler
Jul 18 '05 #1
7 2372
mep
Try ANTLR with python code generation:
http://www.antlr.org/

And C++ grammers:
http://www.antlr.org/grammar/cpp

You can generate a c++ parser in python with the above.

--
Best Regards,
Wang Kebo

http://www.huihoo.org/~mep
"Franz Steinhaeusler" <fr************ *****@utanet.at > wrote in message
news:mu******** *************** *********@4ax.c om...
Hello NG,

has anyone written such a thing in python?
Where could I look for?

(I need it for an editor written in wxPython to display function names,
include, global variables, classes, ... in a sidepanel).

kind regards,
--
Franz Steinhaeusler

Jul 18 '05 #2
mep

"mep" <me**@163.com > wrote in message news:38******** *****@individua l.net...
Try ANTLR with python code generation:
http://www.antlr.org/

And C++ grammers:
http://www.antlr.org/grammar/cpp

You can generate a c++ parser in python with the above. ^^^^^^^^^^^^^^^ ^^
Sorry. Haven't look into the stuff carefully.
That grammer file requires some c++ code.

--
Best Regards,
Wang Kebo

http://www.huihoo.org/~mep
"Franz Steinhaeusler" <fr************ *****@utanet.at > wrote in message
news:mu******** *************** *********@4ax.c om...
Hello NG,

has anyone written such a thing in python?
Where could I look for?

(I need it for an editor written in wxPython to display function names,
include, global variables, classes, ... in a sidepanel).

kind regards,
--
Franz Steinhaeusler


Jul 18 '05 #3
On Fri, 25 Feb 2005 15:10:06 +0800, "mep" <me**@163.com > wrote:
Try ANTLR with python code generation:
http://www.antlr.org/

And C++ grammers:
http://www.antlr.org/grammar/cpp

You can generate a c++ parser in python with the above.


Thank you, but it is too big.

Anyway:
I'm looking for some (simple) "rules" to parse (regex)
and try to implement myself, if nothing is available.

It don't have to be perfect.

Maybe I look for some code in for example
Dev-Cpp from Bloodshed (there is also a c++ class browser).
--
Franz Steinhaeusler
Jul 18 '05 #4
>>>>> "Franz" == Franz Steinhaeusler <fr************ *****@utanet.at > writes:

Franz> Thank you, but it is too big.

Franz> Anyway:

Franz> I'm looking for some (simple) "rules" to parse (regex) and
Franz> try to implement myself, if nothing is available.

Check out

http://pyparsing.sourceforge.net/

Before you start implementing one yourself. Regexp solution would
probably be a bit flakier. And do share your results when you get
some; I'm in need of a c++ parser myself.

--
Ville Vainio http://tinyurl.com/2prnb
Jul 18 '05 #5
On 25 Feb 2005 12:38:53 +0200, Ville Vainio <vi***@spammers .com> wrote:

Hello Ville,
>> "Franz" == Franz Steinhaeusler <fr************ *****@utanet.at > writes:

Franz> Thank you, but it is too big.

Franz> Anyway:

Franz> I'm looking for some (simple) "rules" to parse (regex) and
Franz> try to implement myself, if nothing is available.

Check out

http://pyparsing.sourceforge.net/


Thank you for this information!

Also a little to complicated, I'm looking for
a quick solution.

Before you start implementing one yourself. Regexp solution would
probably be a bit flakier. And do share your results when you get
some; I'm in need of a c++ parser myself.


I don't want to scan a whole project,
only the currently open file.

class definition
method/function
ignore comment lines
show #includes would be enough at first.
I will inform again :)

--
Franz Steinhaeusler
Jul 18 '05 #6
>>>>> "Franz" == Franz Steinhaeusler <fr************ *****@utanet.at > writes:

Franz> On 25 Feb 2005 12:38:53 +0200, Ville Vainio <vi***@spammers .com> wrote:
Franz> Hello Ville,
>>> "Franz" == Franz Steinhaeusler
>>> <fr************ *****@utanet.at > writes:

Franz> Thank you, but it is too big. Franz> Anyway: Franz> I'm looking for some (simple) "rules" to parse (regex) and
Franz> try to implement myself, if nothing is available.
Check out

http://pyparsing.sourceforge.net/
Franz> Thank you for this information!

Franz> Also a little to complicated, I'm looking for a quick
Franz> solution.

Before you start implementing one yourself. Regexp solution
would probably be a bit flakier. And do share your results when
you get some; I'm in need of a c++ parser myself.


Franz> I don't want to scan a whole project, only the currently
Franz> open file.

Franz> class definition method/function ignore comment lines show
Franz> #includes would be enough at first.
Franz> I will inform again :)

Franz> -- Franz Steinhaeusler
In the "instant gratification" department, there is Emacs with the
Emacs Code Browser interface. ECB contains a C++ parser done in
Lisp. If you need to extract things, there is a PyMacs interface that
works quite well.
See http://www.emacswiki.org for details.
Given the "power, performance, ease of use; pick any two" cliché,
we're clearly ditching the middle one with this approach. :)
Best,
Chris
Jul 18 '05 #7
You can look at the techniques and regular expressions in the
testgen.c.unit test module that is part of a generic test framework
called TestGen. TestGen uses a parser to automatically stub / copy
functions for testing purposes. The parser is capable of identifying
the function/method name as well as the parameters and return type.
The only caveat with using regular expressions is the function/method's
closing } must be in column zero. If you figure out a different way to
get around the restriction or other improvements to the parser let me
know.

I'm about to release a newer version, but the area that you would be
looking at is not changing so I would go ahead and download the latest
that is there. TestGen can be found at
sourceforge.net/projects/testgen

Regards,
Dan Gass

Jul 18 '05 #8

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

Similar topics

2
1513
by: anton muhin | last post by:
Hello, everybody! Can someone give an overview of existing Python parser generators? I played with TPG and like it a lot. However, I'd like to know more about alternatives. Google shows several options: PyLR, DParser, etc. I'm not intrested in ultra-speed: TPG although claims to be not lighting-quick seems quick enough for my needs, I'm rather looking for convinience and expressivness.
1
5288
by: Karalius, Joseph | last post by:
Can anyone explain what is happening here? I haven't found any useful info on Google yet. Thanks in advance. mmagnet:/home/jkaralius/src/zopeplone/Python-2.3.5 # make gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o Modules/python.o Modules/python.c gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o...
4
7169
by: tuxlover | last post by:
Hello everyone I have to write a verilog parser in python for a class project. I was wondering if all you folks could advise me on choosing the right python parser module. I am not comfortable with lex/yacc and as a result find myself strugging with any module which use lex/yacc syntax/philosophy. pyparser looks good to me, but before I dive into it, I would really appreciate feedback from members of this group Thanks
2
3230
by: Joel Hedlund | last post by:
Hi! I have a possibly dumb question about imports. I've written two python modules: parser.py ------------------------------------ class Parser(object): "my parser" ------------------------------------
4
4208
by: mkppk | last post by:
MICR = The line of digits printed using magnetic ink at the bottom of a check. Does anyone know of a Python function that has been written to parse a line of MICR data? Or, some financial package that may contain such a thing? Or, in general, where I should be looking when looking for a piece of Python code that may have already been written by someone? I'm working on a project that involves a check scanner the produces
28
16424
by: Marc Gravell | last post by:
In Linq, you can apparently get a meaningful body from and expression's .ToString(); random question - does anybody know if linq also includes a parser? It just seemed it might be a handy way to write a safe but easy implementation (i.e. no codedom) for an IBindingListView.Filter (by compiling to a Predicate<T>). Anybody know if this is possible at all? Marc
5
2623
by: Abandoned | last post by:
Hi.. I try a boolean parser in python since 1 weak.. But i can't do this because this is very complicated :( Do you know any blooean parser script in python or how do i write a boolean parser ? example query: ((google or yahoo) or (live msn)) not web I'm sorry my bad english. King Regards..
0
913
by: Robert Kern | last post by:
dudeja.rajat@gmail.com wrote: There are a couple of ways to do #3. One would be to use the difflib module from the standard library. The Differ.compare() method will give you a sequence of lines with prefixed character saying whether the line was the same in both files, deleted from the first or added by the second. Lines that are recognized as having changed (rather than just being deleted then readded with modifications) are also...
0
1385
by: Kirill Simonov | last post by:
======================== Announcing PyYAML-3.06 ======================== A new bug fix release of PyYAML is now available: http://pyyaml.org/wiki/PyYAML Changes
0
9530
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
10459
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
10236
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...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6793
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
5445
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
4120
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
3734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
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.