predictive parsing

"j0mbolar" <>
19 Feb 2006 02:03:03 -0500

          From comp.compilers

Related articles
predictive parsing (j0mbolar) (2006-02-19)
Re: predictive parsing ( (2006-02-19)
Re: predictive parsing (Ulrich Hobelmann) (2006-02-19)
| List of all articles for this month |

From: "j0mbolar" <>
Newsgroups: comp.compilers
Date: 19 Feb 2006 02:03:03 -0500
Keywords: LL(1), parse, question
Posted-Date: 19 Feb 2006 02:03:03 EST

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.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.