19
C H A P T E R
LALR(1) Grammar
T
HIS chapter presents a grammar for Java. The grammar has been mechanically
checked to insure that it is LALR(1).
The grammar for Java presented piecemeal in the preceding chapters is much
better for exposition, but it cannot be parsed left to right with one token of looka
head because of certain syntactic peculiarities, some of them inherited from C and
C++. These problems and the solutions adopted for the LALR(1) grammar are
presented below, followed by the grammar itself.
19.1 Grammatical Difficulties
There are five problems with the grammar presented in preceding chapters.
19.1.1 Problem #1: Names Too Specific
Consider the two groups of productions:
PackageName:
Identifier
PackageName
.
Identifier
TypeName:
Identifier
PackageName
.
Identifier
and:
MethodName:
Identifier
AmbiguousName
.
Identifier
AmbiguousName:
Identifier
AmbiguousName
.
Identifier
433
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved