program

declarationdeclaration

declaration

class_declclass_decl fun_declfun_decl var_declvar_decl statementstatement

class_decl

CLASSCLASS identifieridentifier '<' identifieridentifier LBRACELBRACE functionfunction property_property_ class_declclass_decl RBRACERBRACE

CLASS

'class'

function

identifieridentifier LPARLPAR parametersparameters RPARRPAR blockblock

parameters

identifieridentifier ',' [suppress] identifieridentifier

block

LBRACELBRACE declarationdeclaration RBRACERBRACE

LBRACE

'{' [suppress]

property_

identifieridentifier blockblock

RBRACE

'}' [suppress]

fun_decl

FUNFUN identifieridentifier LPARLPAR parametersparameters RPARRPAR blockblock

FUN

'fun'

var_decl

VARVAR identifieridentifier EQEQ expressionexpression SEMISEMI

VAR

'var'

expression

assignmentassignment arith_operand_expressionarith_operand_expression functionfunction

assignment

callcall identifieridentifier EQEQ assignmentassignment arith_operand_expressionarith_operand_expression

call

primaryprimary LPARLPAR argumentsarguments RPARRPAR '.' identifieridentifier

primary

TRUETRUE FALSEFALSE NILNIL THISTHIS numbernumber stringstring identifieridentifier SUPERSUPER '.' identifieridentifier

arguments

expressionexpression ',' [suppress] expressionexpression

EQ

'=' [suppress]

arith_operand_expression

'or' operations'or' operations

'or' operations

'and' operations'and' operations OROR 'and' operations'and' operations 'and' operations'and' operations

'and' operations

'!=' | '==' operations'!=' | '==' operations ANDAND '!=' | '==' operations'!=' | '==' operations '!=' | '==' operations'!=' | '==' operations

'!=' | '==' operations

'>=' | '>' | '<=' | '<' operations'>=' | '>' | '<=' | '<' operations '!=' | '==''!=' | '==' '>=' | '>' | '<=' | '<' operations'>=' | '>' | '<=' | '<' operations '>=' | '>' | '<=' | '<' operations'>=' | '>' | '<=' | '<' operations

'>=' | '>' | '<=' | '<' operations

'-' | '+' operations'-' | '+' operations '>=' | '>' | '<=' | '<''>=' | '>' | '<=' | '<' '-' | '+' operations'-' | '+' operations '-' | '+' operations'-' | '+' operations

'-' | '+' operations

'/' | '*' operations'/' | '*' operations '-' | '+''-' | '+' '/' | '*' operations'/' | '*' operations '/' | '*' operations'/' | '*' operations

'/' | '*' operations

'!' | '-' operations'!' | '-' operations '/' | '*''/' | '*' '!' | '-' operations'!' | '-' operations '!' | '-' operations'!' | '-' operations

'!' | '-' operations

'!' | '-''!' | '-' '!' | '-' operations'!' | '-' operations callcall TRUETRUE FALSEFALSE NILNIL THISTHIS numbernumber stringstring identifieridentifier SUPERSUPER '.' identifieridentifier nested_arith_operand_expressionnested_arith_operand_expression

'!' | '-'

[!\-]

TRUE

'true'

FALSE

'false'

NIL

'nil'

THIS

'this'

number

\d+(?:\.\d+)?

string

string enclosed in '"'

SUPER

'super'

identifier

W:(A-Z_a-z, '0-9A-Z_a-z)

nested_arith_operand_expression

'(' [suppress] arith_operand_expressionarith_operand_expression ')' [suppress]

'/' | '*'

[/*]

'-' | '+'

[\-+]

'>=' | '>' | '<=' | '<'

>=|>|<=|<

'!=' | '=='

!=|==

AND

'and'

OR

'or'

statement

expr_statementexpr_statement for_statementfor_statement if_statementif_statement print_statementprint_statement return_statementreturn_statement while_statementwhile_statement blockblock

expr_statement

expressionexpression ';'

for_statement

FORFOR LPARLPAR var_declvar_decl expr_statementexpr_statement ';' expressionexpression ';' expressionexpression RPARRPAR statementstatement

FOR

'for'

if_statement

IFIF LPARLPAR expressionexpression RPARRPAR statementstatement ELSEELSE statementstatement

IF

'if'

ELSE

'else'

print_statement

PRINTPRINT expressionexpression SEMISEMI

PRINT

'print'

return_statement

RETURNRETURN expressionexpression SEMISEMI

RETURN

'return'

SEMI

';' [suppress]

while_statement

WHILEWHILE LPARLPAR expressionexpression RPARRPAR statementstatement

WHILE

'while'

LPAR

'(' [suppress]

RPAR

')' [suppress]