"vaib" <va************@gmail.comwrote in message
news:26**********************************@f24g2000 prh.googlegroups.com...
hi all . i am trying to build a parser in ANSI C . I made a lexical
analyser in the same language a while ago . It was a very simple lexer
that tokenised a simple C source code text file - basically a very
simple lexer . I had made use of hash tables for the data structure .
Now i want to know how to build a parser . I'll let you know what iI don't know the formal approach to these things but I haven't come across
know about parser building - i'll need a grammar written in the form
of regular expressions , i would need to implement something called a
parse tree in a data structure of my choice and so on.
an RE grammar before, not for an entire language anyway.
The usual approach if you're not using external tools is to program using
'recursive descent' or top-down, whatever the term is. In this case the
grammar is built-in to the code. You will need a tokeniser too, which it
seems you already have.
Then you have all you need and top-down is really easy! But you have to
decide what the output will be, and typically this will be some tree
representation of the syntax.
I don't have any /simple/ examples however (and they're not in C). But if
you post a simple grammar example (which I can understand as I don't know
RE), then maybe I can give a bit more help.
--
Bartc