add splat expressions

This commit is contained in:
mhoffm
2021-06-08 18:50:12 +02:00
parent 17de5b425a
commit 49fe1f15c1
4 changed files with 1342 additions and 602 deletions

View File

@@ -9,12 +9,11 @@ module.exports = grammar({
conflicts: $ => [
[$.body],
[$.object_elem, $.variable_expr],
[$.attr_splat],
[$.full_splat],
],
extras: $ => [
$.comment,
/\s/,
],
extras: $ => [$.comment, /\s/],
rules: {
config_file: $ => $.body,
@@ -58,9 +57,9 @@ module.exports = grammar({
$.variable_expr,
// $.function_call,
// $.for_expr,
// seq($.expr_term, $.index),
// seq($.expr_term, $.get_attr),
// seq($.expr_term, $.splat),
seq($.expr_term, $.index),
seq($.expr_term, $.get_attr),
seq($.expr_term, $.splat),
seq('(', $.expression, ')'),
),
@@ -108,6 +107,15 @@ module.exports = grammar({
$.expression,
),
index: $ => seq('[', $.expression, ']'),
get_attr: $ => seq('.', $.identifier),
splat: $ => choice($.attr_splat, $.full_splat),
attr_splat: $ => seq('.', '*', repeat($.get_attr)),
full_splat: $ => seq('[', '*', ']', repeat(choice($.get_attr, $.index))),
variable_expr: $ => $.identifier,
// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890