From: | mw@ipx2.rz.uni-mannheim.de (Marc Wachowitz) |
Newsgroups: | comp.compilers |
Date: | 4 Jan 1997 20:50:03 -0500 |
Organization: | --- |
References: | 97-01-013 97-01-029 |
Keywords: | symbols, practice, Java |
John Lilley (jlilley@empathy.com) wrote:
> The symbol table in some languages like Java, C or C++ is necessary
> even for a syntactic parse, because typedefs determine what is an
> identifier vs a type, and there are places in the grammar where it
> must be known what is a type and what is not for the parse to
> proceed correctly.
That's not true for Java. The language specification (available online
as http://java.sun.com/doc/language_specification.html) contains a
chapter with a complete LALR(1) grammar, which one can feed to yacc
without complaints, after expanding the usage of an "opt"-Suffix to
several alternatives with and without the respective optional element.
The grammar which is used throughout the book for presentation does
indeed contain some non-LALR(1) constructs, but the above chapter
explains the grammar transformations which get rid of those problems,
and gives the final result. This may also be worth reading as a nice
intro to the kind of stuff one should expect if one wants to use yacc
or similar tools for existing languages. (When designing a new
language, it's not very difficult to get it "clean" in the first
place, though I'd even strive for LL(1) rather than LALR(1) in that
case.)
-- Marc Wachowitz <mw@ipx2.rz.uni-mannheim.de>
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.