ESCJ 13: Grammar parsed by javafe.parser.Parse



This document describes the grammar parsed by javafe.parser.Parse.

We first enumerate the differences between this grammar and the grammar described in Chapter 19 of "The Java Language Specification".
 

  1. We introduce the meta-symbols '(', ')', '[', ']', '*', '+' and '|', with their usual meanings.
  2. We merge ClassBodyDeclaration and InterfaceMemberDeclaration to the non-terminal TypeDeclElem.
  3. Change Modifiers to include empty modifier set, exclude duplicates and duplicate access protection modifiers.
  4. Change FormalParameterList to include enclosing parens, and allow empty parameter list.Ditto for ArgumentList.
  5. We relax the left hand side of an Assignment to be a ConditionalExpression.
  6. We tighten CastExpression.
  7. We merge PrimaryNoNewArray into Primary, and use greedy parsing to appropriately resolve the resulting ambuigity on expressions such as new int[2][2].
  8. We merge PostfixExpression into Primary. The resulting grammar is looser, but the type checker with catch programs such as x++[3].
  9. We merge ClassInstanceCreationExpression and ArrayCreationExpression into NewExpression.
  10. We inline FieldAccess, ArrayAccess and MethodInvocation.
  11. We express Primary as PrimaryCore PrimarySuffix*.
  12. Add void to PrimitiveType.
  13. Allow semicolons between member declarations. These semicolons are not allowed according to JLS, but are accepted by javac and present in many programs in the JDK toolkit.
The parser is split into several classes. We list separately the grammar productions implemented in each class.


Productions for ParseType


Productions for Parse


Productions for ParseStmt


Productions for ParseExpr

Legal Statement Privacy Statement