Parsing C++

Programming, for all ages and all languages.
Post Reply
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Parsing C++

Post 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:
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Parsing C++

Post 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++.
viki
Posts: 14
Joined: Tue May 08, 2007 11:57 am
Location: Poland

Re: Parsing C++

Post by viki »

Regular expressions should be useful
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Parsing C++

Post by JamesM »

viki wrote:Regular expressions should be useful
Hardly - only for the lexing stage.
clange
Member
Member
Posts: 163
Joined: Sun Oct 05, 2008 5:00 am
Location: Copenhagen, Denmark
Contact:

Re: Parsing C++

Post by clange »

Post Reply