|
|
|
|
@ -3,27 +3,27 @@ module.exports = grammar({
|
|
|
|
|
|
|
|
|
|
extras: $ => [
|
|
|
|
|
$.comment,
|
|
|
|
|
$._line_break,
|
|
|
|
|
/[ \t\r]/
|
|
|
|
|
$._line_break,
|
|
|
|
|
/[ \t\r]/
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
rules: {
|
|
|
|
|
program: $ => repeat(seq($._statement, optional($._terminator))),
|
|
|
|
|
|
|
|
|
|
_statement: $ => choice($._expression),
|
|
|
|
|
_expression: $ => choice($._argument),
|
|
|
|
|
_statement: $ => choice($._expression),
|
|
|
|
|
_expression: $ => choice($._argument),
|
|
|
|
|
|
|
|
|
|
_argument: $ => choice($._primary),
|
|
|
|
|
_argument: $ => choice($._primary),
|
|
|
|
|
|
|
|
|
|
_primary: $ => choice($._variable),
|
|
|
|
|
_primary: $ => choice($._variable),
|
|
|
|
|
|
|
|
|
|
_variable: $ => choice($.identifier , 'nil', 'self'),
|
|
|
|
|
_variable: $ => choice($.identifier , 'nil', 'self'),
|
|
|
|
|
|
|
|
|
|
identifier: $ => seq(repeat(choice('@', '$')), /[a-zA-Z_][a-zA-Z0-9_]*/),
|
|
|
|
|
identifier: $ => seq(repeat(choice('@', '$')), /[a-zA-Z_][a-zA-Z0-9_]*/),
|
|
|
|
|
|
|
|
|
|
comment: $ => token(seq('#', /.*/)),
|
|
|
|
|
comment: $ => token(seq('#', /.*/)),
|
|
|
|
|
|
|
|
|
|
_line_break: $ => '\n',
|
|
|
|
|
_terminator: $ => choice($._line_break, ';'),
|
|
|
|
|
_line_break: $ => '\n',
|
|
|
|
|
_terminator: $ => choice($._line_break, ';'),
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|