BNF for oscript.jj
NON-TERMINALS
ProgramFile
::=
( <UNIX_SELF_EXECUTABLE_COMMENT> )?
Program
<EOF>
Program
::=
(
EvaluationUnit
)*
EvaluationUnit
::=
ScopeBlock
|
VariableDeclarationBlock
|
FunctionDeclaration
|
TryStatement
|
ForLoopStatement
|
CollectionForLoopStatement
|
WhileLoopStatement
|
ConditionalStatement
|
SynchronizedStatement
|
ReturnStatement
|
BreakStatement
|
ContinueStatement
|
ExpressionBlock
|
ThrowBlock
|
ImportBlock
|
MixinBlock
|
EvalBlock
ScopeBlock
::=
"{"
Program
"}"
VariableDeclarationBlock
::=
VariableDeclaration
";"
ExpressionBlock
::=
Expression
";"
ThrowBlock
::=
"throw"
Expression
";"
ImportBlock
::=
"import"
Expression
";"
MixinBlock
::=
"mixin"
Expression
";"
EvalBlock
::=
"eval"
Expression
";"
VariableDeclaration
::=
Permissions
"var" <IDENTIFIER> ( "="
Expression
)?
FunctionDeclaration
::=
Permissions
"function" <IDENTIFIER> "(" (
Arglist
)? ")" ( "extends"
PrimaryExpressionWithTrailingFxnCallExpList
FunctionCallExpressionList
)? "{"
Program
"}"
Arglist
::=
Permissions
<IDENTIFIER> ( ","
Permissions
<IDENTIFIER> )* ( "..." )?
TryStatement
::=
"try"
EvaluationUnit
( "catch" "("
Expression
<IDENTIFIER> ")"
EvaluationUnit
)* ( "catch" "(" <IDENTIFIER> ")"
EvaluationUnit
)? ( "finally"
EvaluationUnit
)?
ForLoopStatement
::=
"for" "(" (
PreLoopStatement
)? ";" (
Expression
)? ";" (
Expression
)? ")"
EvaluationUnit
CollectionForLoopStatement
::=
"for" "("
PreLoopStatement
":"
Expression
")"
EvaluationUnit
PreLoopStatement
::=
VariableDeclaration
|
Expression
WhileLoopStatement
::=
"while" "("
Expression
")"
EvaluationUnit
ConditionalStatement
::=
"if" "("
Expression
")"
EvaluationUnit
( "else"
EvaluationUnit
)?
SynchronizedStatement
::=
"synchronized" "("
Expression
")"
EvaluationUnit
ReturnStatement
::=
"return" (
Expression
)? ";"
BreakStatement
::=
"break" ";"
ContinueStatement
::=
"continue" ";"
Expression
::=
AssignmentExpression
( ","
AssignmentExpression
)*
FunctionCallExpressionList
::=
"(" (
FunctionCallExpressionListBody
)? ")"
FunctionCallExpressionListBody
::=
AssignmentExpression
( ","
AssignmentExpression
)*
AssignmentExpression
::=
ConditionalExpression
( ( "=" | "+=" | "-=" | "*=" | "/=" | "%=" | ">>=" | "<<=" | ">>>=" | "&=" | "^=" | "|=" )
ConditionalExpression
)*
ConditionalExpression
::=
LogicalOrExpression
( "?"
LogicalOrExpression
":"
LogicalOrExpression
)?
LogicalOrExpression
::=
LogicalAndExpression
( "||"
LogicalAndExpression
)*
LogicalAndExpression
::=
BitwiseOrExpression
( "&&"
BitwiseOrExpression
)*
BitwiseOrExpression
::=
BitwiseXorExpression
( "|"
BitwiseXorExpression
)*
BitwiseXorExpression
::=
BitwiseAndExpression
( "^"
BitwiseAndExpression
)*
BitwiseAndExpression
::=
EqualityExpression
( "&"
EqualityExpression
)*
EqualityExpression
::=
RelationalExpression
( ( "==" | "!=" )
RelationalExpression
)*
RelationalExpression
::=
ShiftExpression
( ( "<" | ">" | ">=" | "<=" | "instanceof" )
ShiftExpression
)*
ShiftExpression
::=
AdditiveExpression
( ( "<<" | ">>" | ">>>" )
AdditiveExpression
)*
AdditiveExpression
::=
MultiplicativeExpression
( ( "+" | "-" )
MultiplicativeExpression
)*
MultiplicativeExpression
::=
UnaryExpression
( ( "*" | "/" | "%" )
UnaryExpression
)*
UnaryExpression
::=
( ( "++" | "--" | "+" | "-" | "~" | "!" ) )?
PostfixExpression
PostfixExpression
::=
TypeExpression
( "++" | "--" )?
TypeExpression
::=
AllocationExpression
|
PrimaryExpression
AllocationExpression
::=
"new"
PrimaryExpressionWithTrailingFxnCallExpList
FunctionCallExpressionList
PrimaryExpression
::=
PrimaryPrefix
(
PrimaryPostfix
)*
PrimaryExpressionWithTrailingFxnCallExpList
::=
PrimaryPrefix
(
PrimaryPostfixWithTrailingFxnCallExpList
)*
PrimaryPrefix
::=
ThisPrimaryPrefix
|
CalleePrimaryPrefix
|
ArrayDeclarationPrimaryPrefix
|
IdentifierPrimaryPrefix
|
ParenPrimaryPrefix
|
FunctionPrimaryPrefix
|
Literal
ThisPrimaryPrefix
::=
"this"
CalleePrimaryPrefix
::=
"callee"
IdentifierPrimaryPrefix
::=
<IDENTIFIER>
ParenPrimaryPrefix
::=
"("
Expression
")"
FunctionPrimaryPrefix
::=
"function" "(" (
Arglist
)? ")" ( "extends"
PrimaryExpressionWithTrailingFxnCallExpList
FunctionCallExpressionList
)? "{"
Program
"}"
ArrayDeclarationPrimaryPrefix
::=
"[" (
FunctionCallExpressionListBody
)? "]"
PrimaryPostfix
::=
FunctionCallPrimaryPostfix
|
ArraySubscriptPrimaryPostfix
|
PropertyIdentifierPrimaryPostfix
PrimaryPostfixWithTrailingFxnCallExpList
::=
ArraySubscriptPrimaryPostfix
|
PropertyIdentifierPrimaryPostfix
FunctionCallPrimaryPostfix
::=
FunctionCallExpressionList
ArraySubscriptPrimaryPostfix
::=
"["
Expression
( ".."
Expression
)? "]"
PropertyIdentifierPrimaryPostfix
::=
"." <IDENTIFIER>
Literal
::=
<INTEGER_LITERAL>
|
<FLOATING_POINT_LITERAL>
|
<STRING_LITERAL>
|
<REGEXP_LITERAL>
|
"true"
|
"false"
|
"null"
|
"undefined"
Permissions
::=
( "static" | "const" | "private" | "protected" | "public" )*