Chapter 18. Syntax

 

Is there grammar in a title. There is grammar in a title. Thank you.

 
 --Gertrude Stein, Arthur a Grammar, in How to Write (1931)

This chapter presents a grammar for the Java programming language.

The grammar presented piecemeal in the preceding chapters is much better for exposition, but it is not well suited as a basis for a parser. The grammar presented in this chapter is the basis for the reference implementation. Note that it is not an LL(1) grammar, though in many cases it minimizes the necessary look ahead.

The grammar below uses the following BNF-style conventions:

  • [x] denotes zero or one occurrences of x.

  • {x} denotes zero or more occurrences of x.

    x | y means one of either x or y.

The Grammar of the Java Programming Language ...

Get Java™ Language Specification, Third Edition, The now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.