Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 4, 2007, 12:31 AM   #1
Soulstorm
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Writting a C++ Parser

Well, that may sound too vague, but I am trying to improve my skills in writing parsers. So far for C++ I haven't tried to look at any other type of parser other than recursive descent.

All I would like is to have some resources to get started with writing recursive descent parsers. Examples, tutorials, etc.

PS. If the resources are for Cocoa, I still want them
Soulstorm is offline   0 Reply With Quote
Old Aug 4, 2007, 01:08 AM   #2
kpua
macrumors 6502
 
Join Date: Jul 2006
http://en.wikipedia.org/wiki/Recursive_descent_parser
kpua is offline   0 Reply With Quote
Old Aug 11, 2007, 08:44 PM   #3
ChrisA
macrumors G4
 
Join Date: Jan 2006
Location: Redondo Beach, California
Quote:
Originally Posted by Soulstorm View Post
Well, that may sound too vague, but I am trying to improve my skills in writing parsers. So far for C++ I haven't tried to look at any other type of parser other than recursive descent.

All I would like is to have some resources to get started with writing recursive descent parsers. Examples, tutorials, etc.

PS. If the resources are for Cocoa, I still want them
Theoretical question: Can you write a recursive descent parser for C++?
I don't know I forgot if C++ is context sensitive or not

I would only do a recurcive decent parser for a simple language. The
last two I wrote I simply used LEX/YACC. It is so much easier and
you can be done in an hour.

But RD is easy, just write some functions that return "true" on a match.
Google found this. Looks good
http://teaching.idallen.com/cst8152/...t_parsing.html
ChrisA is offline   0 Reply With Quote
Old Aug 12, 2007, 03:39 AM   #4
Catfish_Man
macrumors 68030
 
Catfish_Man's Avatar
 
Join Date: Sep 2001
Location: Portland, OR
Send a message via AIM to Catfish_Man
C or Objective-C would likely be a better choice. C++ is horrifyingly complex to parse correctly.
Catfish_Man is offline   0 Reply With Quote
Old Aug 12, 2007, 06:32 AM   #5
Norton Disney
macrumors newbie
 
Join Date: Aug 2007
Flex/Bison are alternatives to Lex/Yacc, that I've personally used.

Probably the best resource that you can have for writing a compiler is the Dragon book. There's quite a lot of theory to wade through before you get to the juicy bits. For example, you're going to need to have a good understanding of BNF.

If I recall correctly, there are a lot of ambiguities in the C++ grammar that make writing a compiler for it difficult. That contrasts with C, which has only one ambiguity, the 'dangling else'.
Norton Disney is offline   0 Reply With Quote
Old Aug 12, 2007, 10:23 AM   #6
devman
macrumors 65816
 
devman's Avatar
 
Join Date: Apr 2004
Location: AU
good luck! A C++ parser is a tough task.
devman is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Fantastical 2 Debuts on iPhone With Reminders and Improved Event Parser MacRumors iOS Blog Discussion 143 Nov 10, 2013 08:22 PM
retrive image from feed parser preiostd iPhone/iPad Programming 5 Jun 26, 2013 07:00 PM
JSON+ API Response Parser, now with iPhone 5 Support arvindhsukumar iPhone and iPod touch Apps 0 Oct 5, 2012 10:15 AM

Forum Jump

All times are GMT -5. The time now is 11:10 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC