C parsing fun

Károly Kiripolszky karoly.kiripolszky at gmail.com
Mon Feb 5 09:54:25 EST 2007


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 the analyzis as I only have to cope with
production code.

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 you will probably
> notice, that some full functional and in wide use being parser have
> still trouble with this ...
>
> Claudio
> >
> > Marc 'BlackJack' Rintsch írta:
> >> In <1170679559.272656.145660 at v33g2000cwv.googlegroups.com>,
> >> 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
> >




More information about the Python-list mailing list