wanted: C++ parser written in Python

  • Thread starter Franz Steinhaeusler
  • Start date
F

Franz Steinhaeusler

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,
 
F

Franz Steinhaeusler

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).
 
V

Ville Vainio

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.
 
F

Franz Steinhaeusler

Hello Ville,
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 :)
 
C

Chris Smith

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

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

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
 
D

dan.gass

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
 
Joined
Nov 14, 2006
Messages
1
Reaction score
0
Franz Steinhaeusler said:
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

I've written something simple in python. you can try it.

hope it helps.
 

Attachments

  • fgen_v0.93.zip
    21.7 KB · Views: 240

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top