Re: C parsing fun

2007-02-08 Thread Károly Kiripolszky
Yes, of course. But you can still fine-tune the code for the sources you want to parse. The C++ header files I needed to analyze contained no such strings. I believe there are very few real-life .h files out there containing those. In fact I chose #::OPEN::# and #::CLOSE::# because they're more for

Re: C parsing fun

2007-02-08 Thread Roberto Bonvallet
Károly Kiripolszky <[EMAIL PROTECTED]> wrote: > I've found a brute-force solution. In the preprocessing phase I simply > strip out the comments (things inside comments won't appear in the > result) and replace curly brackets with these symbols: #::OPEN::# and > #::CLOSE::#. This fails when the cod

Re: C parsing fun

2007-02-06 Thread Károly Kiripolszky
Helo again! When I came up with this idea on how to parse C files with ease, I was at home and I only have access to the sources in subject in the office. So I've tried the previously posted algorithm on the actual source today and I realized my originally example data I've ran the test with was s

Re: C parsing fun

2007-02-05 Thread Károly Kiripolszky
http://kiri.csing.hu/stack/python/bloppy-0.2.zip Test data now also contains brackets in literal strings. Claudio Grondi írta: > Károly Kiripolszky wrote: > > You're right, thank you for the comment! I will look after how to > > avoid this. > And after you have resolved this 'small' ;-) detail yo

Re: C parsing fun

2007-02-05 Thread Károly Kiripolszky
I've found a brute-force solution. In the preprocessing phase I simply strip out the comments (things inside comments won't appear in the result) and replace curly brackets with these symbols: #::OPEN::# and #::CLOSE::#. After parsing I convert them back. In fact I can disclude commented lines from

Re: C parsing fun

2007-02-05 Thread Claudio Grondi
Károly Kiripolszky wrote: > You're right, thank you for the comment! I will look after how to > avoid this. And after you have resolved this 'small' ;-) detail you will probably notice, that some full functional and in wide use being parser have still trouble with this ... Claudio > > Marc 'Bla

Re: C parsing fun

2007-02-05 Thread Károly Kiripolszky
You're right, thank you for the comment! I will look after how to avoid this. Marc 'BlackJack' Rintsch írta: > In <[EMAIL PROTECTED]>, > karoly.kiripolszky wrote: > > > and the great thing is that the algorithm can be used with any > > language that structures the code with brackets, like PHP and

Re: C parsing fun

2007-02-05 Thread Károly Kiripolszky
Marc 'BlackJack' Rintsch írta: > In <[EMAIL PROTECTED]>, > karoly.kiripolszky wrote: > > > and the great thing is that the algorithm can be used with any > > language that structures the code with brackets, like PHP and many > > others. > > But it fails if brackets appear in comments or literal st

Re: C parsing fun

2007-02-05 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, karoly.kiripolszky wrote: > and the great thing is that the algorithm can be used with any > language that structures the code with brackets, like PHP and many > others. But it fails if brackets appear in comments or literal strings. Ciao, Marc 'BlackJack' Rintsch

Re: C parsing fun

2007-02-05 Thread Károly Kiripolszky
Thx for responding, Szabolcs! I've already tried that, but couldn't manage to get it to work. The source I tried to parse is a huge MSVC 7.1 solution containing about 38 projects, and I believe the code is so complex that it has too many different dependencies and GCC just can't handle them. Btw I'

Re: C parsing fun

2007-02-05 Thread Szabolcs Nagy
> based on concepts my boss had. To do this I needed to represent C++ > code structure in Python somehow. I read the docs for Yapps, pyparsing > and other stuff like those, then I came up with a very simple idea. I > realized that bracketed code is almost like a Python list, except I > have to repl

Re: C parsing fun

2007-02-05 Thread karoly.kiripolszky
and the great thing is that the algorithm can be used with any language that structures the code with brackets, like PHP and many others. -- http://mail.python.org/mailman/listinfo/python-list

C parsing fun

2007-02-05 Thread karoly.kiripolszky
Helo ppl! At the job I was given the task to make a script to analyze C++ code based on concepts my boss had. To do this I needed to represent C++ code structure in Python somehow. I read the docs for Yapps, pyparsing and other stuff like those, then I came up with a very simple idea. I realized t