|Left and Right recursive non-terminals firstname.lastname@example.org (1996-12-14)|
|Re: Left and Right recursive non-terminals email@example.com (1996-12-15)|
|Re: Left and Right recursive non-terminals firstname.lastname@example.org (David L Moore) (1996-12-15)|
|Re: Left and Right recursive non-terminals email@example.com (1996-12-18)|
|Re: Left and Right recursive non-terminals firstname.lastname@example.org (1996-12-20)|
|Re: Left and Right recursive non-terminals email@example.com (Horst von Brand) (1996-12-26)|
|From:||firstname.lastname@example.org (Barton C. Massey)|
|Date:||15 Dec 1996 16:19:01 -0500|
|Organization:||University of Oregon|
> I'm sure I read somewhere that a non-terminal that is both left and right
> recursive renders the grammar ambiguous (I think for any k).
A reachable non-terminal that is both left and right recursive and
which derives any nonempty string of terminals renders a grammar
ambiguous, yes. I don't know a reference, but the proof is pretty
Consider a such nonterminal A, with production
A -> A b A
where b is any string of terminals and nonterminals (need a
Greek keyboard :-).
Now, for there to be any finite-length strings recognizable by A, it
must be that it is possible to derive the empty sentence e from A.
Assume further that there is a nonempty sentence s such that s is
derivable from b (this is informal, but you get the idea).
Consider parsing the sentence s s s with A. We can parse this
A -> A b A -> (A b A) b A -> ((A b A) b A) b A -*-> ((s) s) s
A -> A b A -> (A b A) b A -> (A b A) b (A b A) -*-> (s) s (s)
In other words, we can have at least two parse trees for the
sentence s s s
\ / \
s s s
Finally, we note that by the definition of A, A must recognize the
sentence s s s , therefore A is ambiguous.
Hope this helps, (and that I didn't just do your homework for you :-)!
Return to the
Search the comp.compilers archives again.