Concurrent MiniJava Grammar


  
Program ::= MainClassDeclaration ( ThreadClassDeclaration | ClassDeclaration )* <EOF>
MainClassDeclaration ::= "class" <ID> "{" "public" "static" "void" "main" "(" "String" "[" "]" <ID> ")" "{" ( VarDeclaration )* ( Statement )* "}" "}"

  
ThreadClassDeclaration ::= "class" <ID> "extends" "Thread" "{" ( FieldDeclaration | ( "public" ( RunMethodDeclaration | MethodDeclaration ) ) )* "}"
ClassDeclaration ::= "class" <ID> ( "extends" <ID> )? "{" ( FieldDeclaration | ( "public" ( RunMethodDeclaration | MethodDeclaration ) ) )* "}"
VarDeclaration ::= Type <ID> ( "=" Expression )? ";"
RunMethodDeclaration ::= "void" "run" "(" ")" "{" ( VarDeclaration )* ( Statement )* "}"
MethodDeclaration ::= ( "synchronized" )? Type <ID> "(" ( Type <ID> ( "," Type <ID> )* )? ")" "{" ( VarDeclaration )* ( Statement )* "return" Expression ";" "}"
FieldDeclaration ::= Type <ID> ";"
Type ::= SimpleType ( "[" "]" )*
SimpleType ::= "boolean"
| "int"
| <ID>
Statement ::= IfElseStatement
| IfStatement
| OtherStatement
OtherStatement ::= "{" ( Statement )* "}"
| "while" "(" Expression ")" Statement
| ExternalCall
| AssignableExpression "=" Expression ";"

  
ExternalCall ::= "Xinu" "." <ID> "(" ( Expression ( "," Expression )* )? ")" ";"
IfElseStatement ::= "if" "(" Expression ")" IfElseStatement "else" Statement
| OtherStatement
IfStatement ::= "if" "(" Expression ")" Statement
| OtherStatement
Expression ::= Expression1 ( "||" Expression1 )*
Expression1 ::= Expression2 ( "&&" Expression2 )*
Expression2 ::= Expression3 ( "==" Expression3 | "!=" Expression3 )*
Expression3 ::= Expression4 ( ">" Expression4 | "<" Expression4 )*
Expression4 ::= Expression5 ( "+" Expression5 | "-" Expression5 )*
Expression5 ::= Expression6 ( "*" Expression6 | "/" Expression6 )*
Expression6 ::= "!" Expression7
| "-" Expression7
| Expression7
Expression7 ::= "new" SimpleType ( "[" Expression "]" ( "[" "]" )* | "(" ")" ( FCExpression )? )
| Expression9
FCExpression ::= "." <ID> ( "(" ( Expression ( "," Expression )* )? ")" )?
Expression9 ::= "Xinu.readint" "(" ")"
| "(" Expression ")" ( FCExpression )*
| <NUM> ( FCExpression )*
| <STRINGLITERAL> ( FCExpression )*
| "true" ( FCExpression )*
| "false" ( FCExpression )*
| "this" ( FCExpression )*
| "null" ( FCExpression )*
| AssignableExpression ( FCExpression )*
AssignableExpression ::= <ID> ( "[" Expression "]" )?