Grammar notation

The IRL grammar notation follows the notation presented in The Java Language Specification by James Gosling, Bill Joy and Guy Steele (Addison Wesley, 2nd Edition, 2000).

Terminal symbols, that is, the language keywords, are shown in Courier bold font in the syntactic and lexical rules presented in this chapter.

Nonterminal symbols are shown in italic font in the syntactic rules. A definition of a nonterminal symbol starts with the symbol followed by a colon. For example:

PropertyEntry: 

   property 
 PropertyName  = PropertyValue; 

states that the nonterminal symbol PropertyEntry has a single definition, which comprises the terminal token property followed by a PropertyName, the token equals sign, followed by an Identifier, followed by the token semicolon.

A definition may have several rules. Each rule is described on a separate line. The following example shows a nonterminal symbol with two rule definitions:

TestAssignmentList:
   TestAssignment 
   TestAssignmentList;  TestAssignment

The syntactic definition of the nonterminal symbol TestAssignmentList can be either TestAssignment or TestAssignmentList, followed by the token semicolon, followed by TestAssignment.

The subscripted suffix “opt” indicates an optional symbol. It may appear after a terminal or nonterminal symbol. For example:

 

WaitStatement :

wait untilopt Expression

is equivalent to:

 

WaitStatement :

wait Expression

wait until Expression

When the words “one of” follow the colon in a grammar definition, they signify that each of the symbols on the following line or lines is an alternative definition. For example, the following lexical grammar rule:

AssignmentOperator: one of
  = *= /= %= += -=

is a convenient abbreviation for:

AssignmentOperator:
   = 
  *= 
  /= 
  %= 
  +=
  -=

The words “but not” are used to indicate symbols that are excluded from the rule definition. For example:

ReducedAssignmentOperator:
   AssignmentOperator  but not -=

is equivalent to:

ReducedAssignmentOperator: one of 
  =   *=   /=   %=   += 

An explanatory phrase in parentheses may appear after some expressions.