BNF for qparjava.jj
NON-TERMINALS
Goal
::=
MainClass
(
TypeDeclaration
)* (
Query
)* <EOF>
MainClass
::=
"class"
Identifier
"{" "public" "static" "void" "main" "(" "String" "[" "]"
Identifier
")" "{" "try" "{" (
VarDeclaration
)* (
QParStatement
)* "}" "catch" "("
Identifier
Identifier
")" "{" "}" "}" "}"
TypeDeclaration
::=
ClassDeclaration
|
ClassExtendsDeclaration
ClassDeclaration
::=
"class"
Identifier
"{" (
VarDeclaration
)* "}"
ClassExtendsDeclaration
::=
"class"
Identifier
"extends" "Thread" "{" (
VarDeclaration
)* (
MethodDeclaration
)* "}"
VarDeclaration
::=
Type
Identifier
";"
MethodDeclaration
::=
"public" "void" "run" "(" ")" "{" "try" "{" (
VarDeclaration
)* (
QParStatement
)* "}" "catch" "("
Identifier
Identifier
")" "{" "}" "}"
Type
::=
BooleanType
|
IntegerType
|
Identifier
BooleanType
::=
"boolean"
IntegerType
::=
"int"
QParStatement
::=
(
Ann
)*
Statement
Ann
::=
<SCOMMENT1>
Label
<SCOMMENT2>
Label
::=
Identifier
":"
Statement
::=
Block
|
AssignmentStatement
|
FieldAssignmentStatement
|
IfStatement
|
WhileStatement
|
MessageSend
|
PrintStatement
|
SynchStatement
Block
::=
"{" (
QParStatement
)* "}"
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
Query
::=
<SCOMMENT1>
Identifier
"mhp?"
Identifier
<SCOMMENT2>