Related articles |
---|
eliminating left-recursion aegis@mad.scientist.com (aegis) (2006-01-07) |
Re: eliminating left-recursion rjshaw@netspace.net.au (Russell Shaw) (2006-01-08) |
Re: eliminating left-recursion cdodd@acm.org (Chris Dodd) (2006-01-08) |
Re: eliminating left-recursion DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2006-01-09) |
Re: eliminating left-recursion lojiancn@hotmail.com (jackycn) (2006-01-09) |
From: | "jackycn" <lojiancn@hotmail.com> |
Newsgroups: | comp.compilers |
Date: | 9 Jan 2006 23:50:02 -0500 |
Organization: | http://groups.google.com |
References: | 06-01-01306-01-016 |
Keywords: | parse, LL(1) |
Posted-Date: | 09 Jan 2006 23:50:02 EST |
Please see Louden's 'Compiler Construction, Principles and Practice''s
Chapter 4, section 4.2.3.
CAS2: General immediate left recursion:
Given:
A --> Aa1 | Aa2 | .. | Aan | b1 | b2 | ... |bm
where, none of the b2, b2,...,bm begin with A.
The solution is :
A --> b1A' | b2A' |... |bmA'
A' --> a1A' | a2A' | ... |anA' | epsilon
so , give your's production expression:
d-declarator: ID | d-declarator '[' constant ']' | '(' d-declarator ')'
we can rewrite as
d-declarator : d-declarator '[' constant ']' | '(' d-declarator ')'
| ID
and the solution is:
d-declarator : ID d-declarator' | '(' d-declarator ')' d-declarator'
;
d-declarator' : '[' constant ']' declarator' | epsilon
;
Return to the
comp.compilers page.
Search the
comp.compilers archives again.