|
|
|
@ -29,6 +29,7 @@ module.exports = compiler.grammar
|
|
|
|
@break_statement,
|
|
|
|
@break_statement,
|
|
|
|
@statement_block,
|
|
|
|
@statement_block,
|
|
|
|
@return_statement,
|
|
|
|
@return_statement,
|
|
|
|
|
|
|
|
@throw_statement,
|
|
|
|
@var_declaration)
|
|
|
|
@var_declaration)
|
|
|
|
|
|
|
|
|
|
|
|
expression_statement: -> seq(
|
|
|
|
expression_statement: -> seq(
|
|
|
|
@ -103,6 +104,11 @@ module.exports = compiler.grammar
|
|
|
|
"=",
|
|
|
|
"=",
|
|
|
|
@expression)
|
|
|
|
@expression)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw_statement: -> seq(
|
|
|
|
|
|
|
|
keyword("throw"),
|
|
|
|
|
|
|
|
@expression,
|
|
|
|
|
|
|
|
terminator())
|
|
|
|
|
|
|
|
|
|
|
|
expression: -> choice(
|
|
|
|
expression: -> choice(
|
|
|
|
@identifier,
|
|
|
|
@identifier,
|
|
|
|
@number,
|
|
|
|
@number,
|
|
|
|
@ -120,12 +126,12 @@ module.exports = compiler.grammar
|
|
|
|
@subscript_access,
|
|
|
|
@subscript_access,
|
|
|
|
@function_call,
|
|
|
|
@function_call,
|
|
|
|
@constructor_call,
|
|
|
|
@constructor_call,
|
|
|
|
|
|
|
|
@ternary,
|
|
|
|
@bool_op,
|
|
|
|
@bool_op,
|
|
|
|
@math_op,
|
|
|
|
@math_op,
|
|
|
|
@rel_op,
|
|
|
|
@rel_op,
|
|
|
|
@var_assignment,
|
|
|
|
@type_op,
|
|
|
|
@member_assignment,
|
|
|
|
@assignment,
|
|
|
|
@subscript_assignment,
|
|
|
|
|
|
|
|
seq("(", @expression, ")"))
|
|
|
|
seq("(", @expression, ")"))
|
|
|
|
|
|
|
|
|
|
|
|
function_call: -> seq(
|
|
|
|
function_call: -> seq(
|
|
|
|
@ -150,24 +156,17 @@ module.exports = compiler.grammar
|
|
|
|
".",
|
|
|
|
".",
|
|
|
|
@identifier))
|
|
|
|
@identifier))
|
|
|
|
|
|
|
|
|
|
|
|
member_assignment: -> prec(10, seq(
|
|
|
|
|
|
|
|
@expression,
|
|
|
|
|
|
|
|
".",
|
|
|
|
|
|
|
|
@identifier,
|
|
|
|
|
|
|
|
"=",
|
|
|
|
|
|
|
|
@expression))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subscript_access: -> prec(10, seq(
|
|
|
|
subscript_access: -> prec(10, seq(
|
|
|
|
@expression,
|
|
|
|
@expression,
|
|
|
|
"[",
|
|
|
|
"[",
|
|
|
|
@expression,
|
|
|
|
@expression,
|
|
|
|
"]"))
|
|
|
|
"]"))
|
|
|
|
|
|
|
|
|
|
|
|
subscript_assignment: -> prec(10, seq(
|
|
|
|
assignment: -> prec(-1, seq(
|
|
|
|
@expression,
|
|
|
|
choice(
|
|
|
|
"[",
|
|
|
|
@identifier,
|
|
|
|
@expression,
|
|
|
|
@member_access,
|
|
|
|
"]",
|
|
|
|
@subscript_access)
|
|
|
|
"=",
|
|
|
|
"=",
|
|
|
|
@expression))
|
|
|
|
@expression))
|
|
|
|
|
|
|
|
|
|
|
|
@ -210,6 +209,9 @@ module.exports = compiler.grammar
|
|
|
|
seq(@expression, "&&", @expression),
|
|
|
|
seq(@expression, "&&", @expression),
|
|
|
|
seq(@expression, "||", @expression))
|
|
|
|
seq(@expression, "||", @expression))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ternary: -> seq(
|
|
|
|
|
|
|
|
@expression, "?", @expression, ":", @expression)
|
|
|
|
|
|
|
|
|
|
|
|
math_op: -> choice(
|
|
|
|
math_op: -> choice(
|
|
|
|
seq(@expression, "++"),
|
|
|
|
seq(@expression, "++"),
|
|
|
|
seq(@expression, "--"),
|
|
|
|
seq(@expression, "--"),
|
|
|
|
@ -226,6 +228,10 @@ module.exports = compiler.grammar
|
|
|
|
seq(@expression, ">=", @expression),
|
|
|
|
seq(@expression, ">=", @expression),
|
|
|
|
seq(@expression, ">", @expression))
|
|
|
|
seq(@expression, ">", @expression))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type_op: -> choice(
|
|
|
|
|
|
|
|
seq(keyword("typeof"), @expression),
|
|
|
|
|
|
|
|
seq(@expression, keyword("instanceof"), @expression))
|
|
|
|
|
|
|
|
|
|
|
|
string: -> token(choice(
|
|
|
|
string: -> token(choice(
|
|
|
|
seq('"', repeat(choice(/[^"]/, '\\"')), '"'),
|
|
|
|
seq('"', repeat(choice(/[^"]/, '\\"')), '"'),
|
|
|
|
seq("'", repeat(choice(/[^']/, "\\'")), "'")))
|
|
|
|
seq("'", repeat(choice(/[^']/, "\\'")), "'")))
|
|
|
|
|