Program ::= ClassDeclaration* ClassDeclaration ::= class id [Extends] ClassBody Extends ::= extends ClassType ClassBody ::= '{' ClassBodyDeclaration* '}' ClassBodyDeclaration ::= ClassMemberDeclaration ClassMemberDeclaration ::= FieldDeclaration | MethodDeclaration Type ::= PrimitiveType | ReferenceType PrimitiveType ::= int | boolean | char | string ReferenceType ::= ClassType ClassType ::= SimpleName Name ::= SimpleName | QualifiedName SimpleName ::= id QualifiedName ::= Name '.' id FieldDeclaration ::= Type VariableDeclarators ';' VariableDeclarators ::= VariableDeclarator (',' VariableDeclarator)* VariableDeclarator ::= id MethodDeclaration ::= MethodHeader MethodBody MethodHeader ::= Type MethodDeclarator | void MethodDeclarator MethodDeclarator ::= id '(' [FormalParameterList] ')' FormalParameterList ::= FormalParameter (',' FormalParameter)* FormalParameter ::= Type id MethodBody ::= '{' LocalVariableDeclarationStatement* Statement* '}' | ';' LocalVariableDeclarationStatement ::= Type VariableDeclarators ';' Statement ::= IfThenStatement | IfThenElseStatement | WhileStatement | SimpleBlock | EmptyStatement | ExpressionStatement | ContinueStatement | ReturnStatement | IOStatement SimpleBlock ::= '{' Statement* '}' EmptyStatement ::= ';' ExpressionStatement ::= StatementExpression ';' StatementExpression ::= Assignment | MethodInvocation | ClassInstanceCreationExpression IfThenStatement ::= if '(' Expression ')' Statement IfThenElseStatement ::= if '(' Expression ')' Statement else Statement WhileStatement ::= while '(' Expression ')' Statement ContinueStatement ::= continue ';' ReturnStatement ::= return [Expression] ';' IOStatement ::= (input | output) Expression ';' Primary ::= Literal | this | '(' Expression ')' | ClassInstanceCreationExpression | FieldAccess | MethodInvocation ClassInstanceCreationExpression ::= new ClassType '('[ArgumentList] ')' ArgumentList ::= Expression (',' Expression)* FieldAccess ::= Primary '.' id | super '.' id MethodInvocation ::= Name '(' [ArgumentList] ')' | Primary '.' id '(' [ArgumentList] ')' | super '.' id '(' [ArgumentList]')' PrimitiveExpression ::= Primary | Name Expression ::= Expression '*' Expression | Expression '/' Expression | Expression '+' Expression | Expression '-' Expression | Expression '&&' Expression | Expression '||' Expression | Expression '==' Expression | Expression '!=' Expression | Expression '<' Expression | Expression '>' Expression | Expression '<=' Expression | Expression '>=' Expression | Assignment | '-' Expression | '+' Expression | '!' Expression | PrimitiveExpression Assignment ::= LeftHandSide '=' Expression LeftHandSide ::= Name | FieldAccess Literal ::= integer_constant | string_constant | null | true | false