Re: predictive parsing

"oliverhunt@gmail.com" <oliverhunt@gmail.com>
19 Feb 2006 11:02:58 -0500

          From comp.compilers

Related articles
predictive parsing j0mbolar@engineer.com (j0mbolar) (2006-02-19)
Re: predictive parsing oliverhunt@gmail.com (oliverhunt@gmail.com) (2006-02-19)
Re: predictive parsing u.hobelmann@web.de (Ulrich Hobelmann) (2006-02-19)
| List of all articles for this month |

From: "oliverhunt@gmail.com" <oliverhunt@gmail.com>
Newsgroups: comp.compilers
Date: 19 Feb 2006 11:02:58 -0500
Organization: http://groups.google.com
References: 06-02-139
Keywords: parse
Posted-Date: 19 Feb 2006 11:02:58 EST

This looks very much like the sort of problem i'd give students in
tutorials, so i have some misgivings...


Your first problem is that you have an ambiguous grammar (at LL(1)) so
you need to fix any productions with a common prefix, so
A -> C | CA | D | DA
becomes
A -> C A1 | D A2
A1 -> A | e
A2 -> A | e


where e means epsilon.
At this point all that is necessary is to do is remove the epsilon
transitions and all will be well.


You could in fact take this grammar all the way through to CNF, but
that's probably excessive...



Post a followup to this message

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