OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 23, 2024 11:23 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Parsing C++
PostPosted: Sun May 24, 2009 3:49 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
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 ]


Top
 Profile  
 
 Post subject: Re: Parsing C++
PostPosted: Sun May 24, 2009 3:53 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
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++.

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject: Re: Parsing C++
PostPosted: Sun May 24, 2009 12:24 pm 
Offline

Joined: Tue May 08, 2007 11:57 am
Posts: 14
Location: Poland
Regular expressions should be useful


Top
 Profile  
 
 Post subject: Re: Parsing C++
PostPosted: Sun May 24, 2009 12:26 pm 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
viki wrote:
Regular expressions should be useful


Hardly - only for the lexing stage.

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject: Re: Parsing C++
PostPosted: Sun May 24, 2009 12:41 pm 
Offline
Member
Member

Joined: Sun Oct 05, 2008 5:00 am
Posts: 163
Location: Copenhagen, Denmark
http://www.nobugs.org/developer/parsingcpp/
and also
http://www.reddit.com/r/programming/comments/7uhw7/parsing_c/

clange


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 72 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group