Java Reference
In-Depth Information
AppendixC
JavaSyntax
C.1 Introduction
This appendix describes the lexical and syntactic grammars 1 for the Java programming
language; the former specifies how individual tokens in the language are composed, and the
latter specifies how language constructs are formed. The grammars are based on the second
edition of the Java Language Specification.
C.2 Syntax
We employ the following notation to describe the lexical and syntactic grammars, similar
to what we used in Appendix B to specify j-- syntax.
// indicates comments;
Non-terminals are written in the form of Java (mixed-case) identifiers;
Terminals are written in bold;
Token representations are enclosed in <>;
[x] indicates x is optional, that is, zero or one occurrence of x;
fxg indicates zero or more occurrences of x;
xjy indicates x or y;
~x indicates negation of x;
Parentheses are used for grouping;
Level numbers in expressions indicate precedence.
C.2.1 Lexical Grammar
White Space
White space in Java is defined as the ASCII space ( SP ), horizontal tab ( HT ), and form feed
( FF ) characters, as well as line terminators: line feed ( LF ), carriage return ( CR ), and carriage
return ( CR ) followed by line feed ( LF ).
1 Adapted from ANTLR ( http://www.antlr.org ) Parser Generator examples.
307
 
Search WWH ::




Custom Search