Related articles |
---|
Grammar -> Parser question chris63@my-dejanews.com (1998-06-04) |
Re: Grammar -> Parser question td@sysinno.se (Torbjorn Drevin) (1998-06-09) |
Re: Grammar -> Parser question torbenm@diku.dk (Torben Mogensen) (1998-06-09) |
Re: Grammar -> Parser question dwight@pentasoft.com (1998-06-09) |
Re: Grammar -> Parser question qjackson@wave.home.com (Quinn Tyler Jackson) (1998-06-09) |
Re: Grammar -> Parser question qjackson@wave.home.com (Quinn Tyler Jackson) (1998-06-18) |
From: | chris63@my-dejanews.com |
Newsgroups: | comp.compilers |
Date: | 4 Jun 1998 23:40:01 -0400 |
Organization: | Deja News - The Leader in Internet Discussion |
Keywords: | parse, question |
Suppose I have the following Grammar:
condition -> expr PLUS expr |
LPAREN condition RPAREN
expr -> ID |
LPAREN expr RPAREN
I want to hand-code a top down recursive descent parser for this grammar
using ideas from the Dragon Book (nonterminals become functions, terminals
become calls to match()). I can't use lex or yacc.
However, the LPAREN symbol is causing a problem: When I see it, I don't
know if I'm dealing with a nested condition or a nested expression.
How does one typically deal with this situation if one has to hand-code
the parser? It looks like I need some sort of lookahead and/or backtracking
mechanism so I can figure out which case I am dealing with.
sample source code demonstrating concepts appreciated. The actual grammar
is somewhat more complicated, but this is the critical area I need to address.
Regards,
Chris
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.