Related articles |
---|
Recursive descent and left recursion mfinney@lynchburg.net (1997-01-14) |
Re: Recursive descent and left recursion fjh@mundook.cs.mu.OZ.AU (1997-01-15) |
Re: Recursive descent and left recursion hogan@rintintin.Colorado.EDU (1997-01-15) |
Re: Recursive descent and left recursion dlmoore@ix.netcom.com (David L Moore) (1997-01-16) |
Re: Recursive descent and left recursion cfc@world.std.com (1997-01-16) |
Re: Recursive descent and left recursion fjh@murlibobo.cs.mu.OZ.AU (1997-01-16) |
Re: Recursive descent and left recursion cfc@world.std.com (1997-01-17) |
Re: Recursive descent and left recursion will@ccs.neu.edu (William D Clinger) (1997-01-17) |
Re: Recursive descent and left recursion cfc@world.std.com (Chris F Clark) (1997-01-21) |
Re: Recursive descent and left recursion schoebel@eicheinformatik.uni-stuttgart.de (1997-01-25) |
From: | David L Moore <dlmoore@ix.netcom.com> |
Newsgroups: | comp.compilers |
Date: | 16 Jan 1997 11:07:24 -0500 |
Organization: | Netcom |
References: | 97-01-099 |
Keywords: | parse, question |
mfinney@lynchburg.net wrote:
>
> However, I have been using recursive descent with left recursive
> grammers for more than a decade. All it takes is the trivially
> obvious check to allow the left recursion. Take, for example...
>
> (1) <exp> := <exp> + <term>
> (2) <exp> := <term>
>
> when expanding (1), at the first term I simply check to see if the
> current token in the input stream is the same as the last time that
> the rewriting rule was expanded. If it is, then the parse has not
> advanced and you have the infinite loop situation. I simply fail the
> expansion and select an alternate rewriting rule for expansion.
At the risk of appearing thick, I do not see how this works. Surely,
given an expression like "1+2+3+4+5" I have to "pump" out four exp +
terms before I shift the first symbol (the 1) of the expression, so
the method suggested will not parse this expression.
What am I failing to grasp?
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.