GRAMMAR
In the MiniJava grammar, we use the notation N*, where N is a nonterminal, to mean 0, 1, or more repetitions of N.GRAMMAR A.2
Program → MainClass ClassDecl* MainClass → Class id { public static void main ( String [] id ) { Statement }} ClassDecl → Class id { VarDecl* MethodDecl* } → Class id extends id { VarDecl* MethodDecl* } VarDecl → Type id ; MethodDecl → public Type id ( FormalList ) { VarDecl* Statement* return Exp ;} FormalList → Type id FormalRest* → FormalRest →, Type id Type → int [] → boolean → int → id Statement → { Statement* } → if ( Exp ) Statement else Statement → while ( Exp ) Statement → System.out.println ( Exp ) ; → id = Exp ; → id [ Exp ]= Exp ; Exp → Exp op Exp → Exp [ Exp ] → Exp . length → Exp . id ( ExpList ) → INTEGER LITERAL → true → false → id → this → new int [ Exp ] → new id () → ! Exp → ( Exp ) ExpList → Exp ExpRest* → ExpRest → ,Exp