predictive parsing
- From: "j0mbolar" <j0mbolar@xxxxxxxxxxxx>
- Date: 19 Feb 2006 02:03:03 -0500
I am running into an issue with my LL(1) parser
in representing some of the nonterminals.
The problem is this:
suppose that I have the following grammar:
start: A B
A: C | C A | D | D A
B: '*'
C: '!' | '@'
D: 'X' | 'Y'
Where A, B, C, D are nonterminals
that are represented by functions.
The issue arises in representing the following production:
A: C | C A | D | D A
Imagine my initial lookahead token is '!'.
C() would be called and I would get my next
token. How then could I determine if A() should
be called or if the lookahead token applies to B,
where I should return and then call B?
I would also like to generate a syntax error
if the initial lookahead token does not follow
one of the rules of A.
I think this has to do with properly computing
what should be in the FIRST() set.
--
j0mbolar
.
- Follow-Ups:
- Re: predictive parsing
- From: Ulrich Hobelmann
- Re: predictive parsing
- From: oliverhunt@xxxxxxxxx
- Re: predictive parsing
- Prev by Date: Re: A Plain English Compiler
- Next by Date: Re: predictive parsing
- Previous by thread: Dangling else
- Next by thread: Re: predictive parsing
- Index(es):
Relevant Pages
|
|