Related articles |
---|
Grammar for variable and method declarations. wookiz@hotmail.com (wooks) (2007-03-01) |
Re: Grammar for variable and method declarations. chris.dollin@hp.com (Chris Dollin) (2007-03-03) |
Re: Grammar for variable and method declarations. gneuner2@comcast.net (George Neuner) (2007-03-03) |
From: | Chris Dollin <chris.dollin@hp.com> |
Newsgroups: | comp.compilers |
Date: | 3 Mar 2007 23:31:52 -0500 |
Organization: | HP labs, Bristol |
References: | 07-03-014 |
Keywords: | Java, parse |
Posted-Date: | 03 Mar 2007 23:31:52 EST |
wooks wrote:
> How do you define a grammar where you have a class construct that
> starts with a list of instance variables and method declarations for a
> language like Java.
Do what I /think/ they do with Java: make the syntax more liberal,
so that you can get a clean grammar, and disallow the excessively
liberal constructs later (for some value of "later").
> The particular difficulty is that both start
>
> public/private datatype id and are not distinguishable until the 4th
> token.
>
> I have tried left factoring and I end up getting conflicts on my when
> I declare my method and instance variable lists?
Example?
> Are there some general principles for these situations. Very new to
> all this.
The grammar and grammar tools are your servants, not your masters.
Just because you /can/ do it in the grammar doesn't mean you /must/
do it in the grammar.
--
Chris "electric hedgehog" Dollin
"- born in the lab under strict supervision -", - Magenta, /Genetesis/
Return to the
comp.compilers page.
Search the
comp.compilers archives again.