2.3
The Syntactic Grammar
GRAMMARS
2.3   The Syntactic Grammar
The
syntactic grammar
 for Java is given in Chapters 4, 6 10, 14, and 15. This
grammar has Java tokens defined by the lexical grammar as its terminal symbols.
It defines a set of productions, starting from the goal symbol
CompilationUnit
( 7.3), that describe how sequences of tokens can form syntactically correct Java
programs.
A LALR(1) version of the syntactic grammar is presented in Chapter 19. The
grammar in the body of this specification is very similar to the LALR(1) grammar
but more readable.
2.4   Grammar Notation
Terminal symbols are shown in
fixed width
 font in the productions of the lexical
and syntactic grammars, and throughout this specification whenever the text is
directly referring to such a terminal symbol. These are to appear in a program
exactly as written.
Nonterminal symbols are shown in
italic
 type. The definition of a nonterminal
is introduced by the name of the nonterminal being defined followed by a colon.
One or more alternative right hand sides for the nonterminal then follow on suc 
ceeding lines. For example, the syntactic definition:
IfThenStatement:
if (
Expression
 )
Statement
states that the nonterminal
IfThenStatement
represents the token
if
, followed by a
left parenthesis token, followed by an
Expression
, followed by a right parenthesis
token, followed by a
Statement
. As another example, the syntactic definition:
ArgumentList:
Argument
ArgumentList
 ,
Argument
states that an
ArgumentList
 may represent either a single
Argument
 or an
ArgumentList
, followed by a comma, followed by an
Argument
. This definition of
ArgumentList
 is
recursive
, that is to say, it is defined in terms of itself. The result
is that an
ArgumentList
 may contain any positive number of arguments. Such
recursive definitions of nonterminals are common.
The subscripted suffix  
opt
 , which may appear after a terminal or nontermi 
nal, indicates an
optional symbol
. The alternative containing the optional symbol
actually specifies two right hand sides, one that omits the optional element and
one that includes it. This means that:
8






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

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