Related articles |
---|
Quick way to recognize grammar type srivatsar@yahoo.com (2004-02-01) |
Re: Quick way to recognize grammar type haberg@matematik.su.se (2004-02-04) |
Re: Quick way to recognize grammar type joachim.durchholz@web.de (Joachim Durchholz) (2004-02-04) |
Re: Quick way to recognize grammar type cfc@shell01.TheWorld.com (Chris F Clark) (2004-02-04) |
Re: Quick way to recognize grammar type scavadini@ucse.edu.ar (2004-02-08) |
Re: Quick way to recognize grammar type tbauer@cadrc.calpoly.edu (Tim Bauer) (2004-02-08) |
From: | Joachim Durchholz <joachim.durchholz@web.de> |
Newsgroups: | comp.compilers |
Date: | 4 Feb 2004 21:31:25 -0500 |
Organization: | Oberberg Online Infosysteme |
References: | 04-02-014 |
Keywords: | parse |
Posted-Date: | 04 Feb 2004 21:31:25 EST |
srivatsa wrote:
> Is there any way of determining quickly if a given grammar is one of
> LL(0)/LR(0)/LALR/LR(1). I know that we can construct the set of items
> and hence the parsing table. But I am looking for some tricks/tips
> by which we can quickly determine if the grammar is one of the above
> four types.
A grammar isn't LL if it has left-recursive rules, e.g.
A ::= A B
When designing a language for LL, I try to make sure that all
alternatives start with a unique identifier, and I avoid empty
productions where possible. This gives me a good first start.
For the remaining grammar classes, I haven't seen any quick rules.
Intuitively, a grammar is LR (0) if you can take a valid token
sequence, chop it in two, and still make sense of the left part. For
LR (1), you're allowed to take a look at the first chopped-off token
before trying to make sense of the code.
Not sure about the differences between LR and LALR; I recall dimly
that LALR and LR are essentially the same, but I might be totally
wrong with that.
Regards,
Jo
--
Currently looking for a new job.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.