Page 1 of 1

Parsing C++

Posted: Sun May 24, 2009 3:49 am
by Love4Boobies
I've been working on compilers for a little while now and I was wondering what do you guys find the best parsing technique to be when dealing with C++, if you have any experience. Please don't mention anything about parser generators :wink:

Re: Parsing C++

Posted: Sun May 24, 2009 3:53 am
by JamesM
C++ is an absolutely horrendous language to parse. Personally I'd steer well clear. However, if you really do want to go there, then the clang project think (and I agree with them) that a hand-crafted recursive descent parser is the way to go. It means you can use a left-recursive grammar with all the lookahead you want, and allows for the context-sensitive checks that you require when parsing a non-context-free language like C++.

Re: Parsing C++

Posted: Sun May 24, 2009 12:24 pm
by viki
Regular expressions should be useful

Re: Parsing C++

Posted: Sun May 24, 2009 12:26 pm
by JamesM
viki wrote:Regular expressions should be useful
Hardly - only for the lexing stage.

Re: Parsing C++

Posted: Sun May 24, 2009 12:41 pm
by clange