| Goal | ::= | MainClassDeclaration ( ClassDeclaration | ThreadDeclaration )* <EOF> |
| MainClassDeclaration | ::= | "class" <ID> "{" "public" "static" "void" "main" "(" "String" "[" "]" <ID> ")" "{" ( VarDeclaration )* ( Statement )* "}" "}" |
| ClassDeclaration | ::= | "class" <ID> ( "extends" <ID> )? "{" ( FieldDeclaration | MethodDeclaration )* "}" |
| ThreadDeclaration | ::= | "class" <ID> "extends" "Thread" "{" ( FieldDeclaration | MethodDeclaration | VoidDeclaration )* "}" |
| VarDeclaration | ::= | Type <ID> ( "=" Expression )? ";" |
| MethodDeclaration | ::= | "public" ( "synchronized" )? Type <ID> "(" ( Type <ID> ( "," Type <ID> )* )? ")" "{" ( VarDeclaration )* ( Statement )* "return" Expression ";" "}" |
| VoidDeclaration | ::= | "public" "void" <ID> "(" ")" "{" ( VarDeclaration )* ( Statement )* "}" |
| FieldDeclaration | ::= | Type <ID> ";" |
| Type | ::= | Type ( "[" "]" )* |
| | | "boolean" | |
| | | "int" | |
| | | <ID> | |
| Statement | ::= | "{" ( Statement )* "}" |
| | | "if" "(" Expression ")" Statement ( "else" Statement )? | |
| | | "while" "(" Expression ")" Statement | |
| | | "Xinu" "." <ID> "(" ( Expression ( "," Expression )* )? ")" ";" | |
| | | Expression "=" Expression ";" | |
| Expression | ::= | Expression "." <ID> |
| | | Expression "." <ID> "(" ( Expression ( "," Expression )* )? ")" | |
| | | Expression "||" Expression | |
| | | Expression "&&" Expression | |
| | | Expression "==" Expression | |
| | | Expression ">" Expression | |
| | | Expression "<" Expression | |
| | | Expression "+" Expression | |
| | | Expression "-" Expression | |
| | | Expression "*" Expression | |
| | | Expression "/" Expression | |
| | | Expression "[" Expression "]" | |
| | | "new" Type "(" ")" | |
| | | "new" Type "[" Expression "]" ( "[" "]" )* | |
| | | "Xinu" "." <ID> "(" ( Expression ( "," Expression )* )? ")" | |
| | | "-" Expression | |
| | | "!" Expression | |
| | | "(" Expression ")" | |
| | | <ID> | |
| | | <INT> | |
| | | <STRING> | |
| | | "true" | |
| | | "false" | |
| | | "this" | |
| | | "null" |