newbee help : parser in C

U

user923005

On 19 Jun 2008 at 21:27, vaib wrote:
i am trying to build a parser in ANSI C .
Check out yacc (aka bison).
Look up Recursive Descent Parser and try something simpler
than C to start with. Maybe a subset of C.
<snip>




You may know more about parsers than I (not hard)
but specifing the grammar as reg exps sounds odd to me
Why not modified Backus Naar? See the appendix in K&R
for a C grammer.
From the grammar a RDP should follow in quite a
straitforward manner.
Beware C [has] some tricky corners (eg. typedefs).
yes Nick i got your point - do simpler things first and then move onto
more complex issues . i was now thinking of using yacc first and i'm
reading 'lex and yacc' for that purpose . yes now i know that i'll
write a simple grammar in Backus Naur from and then make a recursive
descent parser for the same . but can u tell me how to do it
exactly ?? and no , i dont know about parsers more than you ( or
anybody else for that matter - i'm just a beginner )

first hit:
   http://en.wikipedia.org/wiki/Recursive_descent_parser

it has code as well

Or even
http://www.google.com/search?hl=en&q=yacc+c+grammar
which gives over 37000 hits.
 
L

lawrence.jones

vaib said:
i plan to use yacc for generating a parser and then read its code

Reading yacc's generated code is not at all enlightening. It's purely
table driven, so the code is very simple and always the same. It's the
data in the tables that varies based on the grammer to be parsed, and
that's quite difficult to understand, even once you understand how it
all works. The verbose output is much more enlightening as to how the
parsing works.
and then continue my parser construction study from the 'dragon book'.

Parsing is not a simple subject. Reading the relevant sections of the
dragon book is definitely the best way to learn it.

-- Larry Jones

Any game without push-ups, hits, burns or noogies is a sissy game. -- Calvin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top