BNF for qinlinedparjava.jj

TOKENS

/************************************
 * The qinlinedparJava Grammar Starts Here *
 ************************************/
Goal ::= MainClass ( TypeDeclaration )* <EOF>
MainClass ::= "class" Identifier "{" "public" "static" "void" "main" "(" "String" "[" "]" Identifier ")" "{" "try" "{" ( VarDeclaration )* ( Statement )* "}" "catch" "(" Identifier Identifier ")" "{" "}" "}" "}"
TypeDeclaration ::= ClassExtendsDeclaration
ClassExtendsDeclaration ::= "class" Identifier "extends" "Thread" "{" ( FieldDeclaration )* ( MethodDeclaration )* "}"
FieldDeclaration ::= Type Identifier ";"
VarDeclaration ::= Type Identifier ";"
MethodDeclaration ::= runMethodDeclaration
runMethodDeclaration ::= "public" "void" "run" "(" ")" "{" "try" "{" ( VarDeclaration )* ( Statement )* "}" "catch" "(" Identifier Identifier ")" "{" "}" "}"
Type ::= BooleanType
| IntegerType
| Identifier
BooleanType ::= "boolean"
IntegerType ::= "int"
Statement ::= Block
| AssignmentStatement
| FieldAssignmentStatement
| IfStatement
| WhileStatement
| MessageSend
| PrintStatement
| SynchStatement
Block ::= "{" ( Statement )* "}"
AssignmentStatement ::= Identifier "=" Expression ";"
FieldAssignmentStatement ::= Identifier "." Identifier "=" Identifier ";"
IfStatement ::= "if" "(" Identifier ")" Statement "else" Statement
WhileStatement ::= "while" "(" Identifier ")" Statement
SynchStatement ::= "synchronized" "(" Identifier ")" Statement
PrintStatement ::= "System.out.println" "(" Identifier ")" ";"
Expression ::= AndExpression
| CompareExpression
| PlusExpression
| MinusExpression
| TimesExpression
| FieldRead
| PrimaryExpression
AndExpression ::= Identifier "&&" Identifier
CompareExpression ::= Identifier "<" Identifier
PlusExpression ::= Identifier "+" Identifier
MinusExpression ::= Identifier "-" Identifier
TimesExpression ::= Identifier "*" Identifier
FieldRead ::= Identifier "." Identifier
MessageSend ::= callStartMethod
| callNotifyMethod
| callNotifyAllMethod
| callWaitMethod
| callJoinMethod
callStartMethod ::= Identifier "." "start" "(" ")" ";"
callNotifyMethod ::= Identifier "." "notify" "(" ")" ";"
callNotifyAllMethod ::= Identifier "." "notifyAll" "(" ")" ";"
callWaitMethod ::= Identifier "." "wait" "(" ")" ";"
callJoinMethod ::= Identifier "." "join" "(" ")" ";"
PrimaryExpression ::= IntegerLiteral
| TrueLiteral
| FalseLiteral
| Identifier
| ThisExpression
| AllocationExpression
| NotExpression
IntegerLiteral ::= <INTEGER_LITERAL>
TrueLiteral ::= "true"
FalseLiteral ::= "false"
Identifier ::= <IDENTIFIER>
ThisExpression ::= "this"
AllocationExpression ::= "new" Identifier "(" ")"
NotExpression ::= "!" Identifier