Talk:Recursive descent parser
This page really needs a discussion of the problem of left-recursive grammar rules. Such rules are extremely common, as for example
EXPR = INT | EXPR + EXPR | EXPR * EXPR;
A recursive descent parser, presented with this grammar, will loop forever on a malformed input.
Should probably mention that hand-written recursive descent parsers are usually based on EBNF grammars? These support left-recursion by turning
A = A b C | C
into
A = C (b C)*
Paolo Bonzini, 09:34, 8 Mar 2006 (UTC)
Recursive descent parser example
Dominus 04:44, 28 Aug 2003 (UTC)
The code on the page is wrong. Parse_E will parse the string NOTTRUETRUE which is not part of the language.
- I don't think it does. Care to demonstrate? -- Jan Hidders 11:22, 28 Aug 2003 (UTC)
- maybe the problem is hidden behind the if's, which should be else-if's??
- Ah, yes, of course. Hope I fixed that now. -- Jan Hidders 00:51, 4 Nov 2004 (UTC)
Does it accept 1*-1? I'm not sure it does
Does not look like it accepts this: // ident := number * - number . Symbol symbols[7] = {ident,becomes,number,times,minus,number,period}; Should it?