add precedence to splat operators; test for associativity
This commit is contained in:
17
grammar.js
17
grammar.js
@@ -16,8 +16,6 @@ module.exports = grammar({
|
|||||||
name: 'hcl',
|
name: 'hcl',
|
||||||
|
|
||||||
conflicts: $ => [
|
conflicts: $ => [
|
||||||
[$.attr_splat],
|
|
||||||
[$.full_splat],
|
|
||||||
// string literals are just quoted template without template stuff
|
// string literals are just quoted template without template stuff
|
||||||
[$.string_lit, $.quoted_template],
|
[$.string_lit, $.quoted_template],
|
||||||
],
|
],
|
||||||
@@ -145,18 +143,15 @@ module.exports = grammar({
|
|||||||
|
|
||||||
splat: $ => choice($.attr_splat, $.full_splat),
|
splat: $ => choice($.attr_splat, $.full_splat),
|
||||||
|
|
||||||
attr_splat: $ => seq(
|
attr_splat: $ => prec.right(seq(
|
||||||
'.',
|
'.*',
|
||||||
'*',
|
|
||||||
repeat($.get_attr),
|
repeat($.get_attr),
|
||||||
),
|
)),
|
||||||
|
|
||||||
full_splat: $ => seq(
|
full_splat: $ => prec.right(seq(
|
||||||
'[',
|
'[*]',
|
||||||
'*',
|
|
||||||
']',
|
|
||||||
repeat(choice($.get_attr, $.index)),
|
repeat(choice($.get_attr, $.index)),
|
||||||
),
|
)),
|
||||||
|
|
||||||
for_expr: $ => choice($.for_tuple_expr, $.for_object_expr),
|
for_expr: $ => choice($.for_tuple_expr, $.for_object_expr),
|
||||||
|
|
||||||
|
|||||||
@@ -480,57 +480,53 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"attr_splat": {
|
"attr_splat": {
|
||||||
"type": "SEQ",
|
"type": "PREC_RIGHT",
|
||||||
"members": [
|
"value": 0,
|
||||||
{
|
"content": {
|
||||||
"type": "STRING",
|
"type": "SEQ",
|
||||||
"value": "."
|
"members": [
|
||||||
},
|
{
|
||||||
{
|
"type": "STRING",
|
||||||
"type": "STRING",
|
"value": ".*"
|
||||||
"value": "*"
|
},
|
||||||
},
|
{
|
||||||
{
|
"type": "REPEAT",
|
||||||
"type": "REPEAT",
|
"content": {
|
||||||
"content": {
|
"type": "SYMBOL",
|
||||||
"type": "SYMBOL",
|
"name": "get_attr"
|
||||||
"name": "get_attr"
|
}
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
},
|
},
|
||||||
"full_splat": {
|
"full_splat": {
|
||||||
"type": "SEQ",
|
"type": "PREC_RIGHT",
|
||||||
"members": [
|
"value": 0,
|
||||||
{
|
"content": {
|
||||||
"type": "STRING",
|
"type": "SEQ",
|
||||||
"value": "["
|
"members": [
|
||||||
},
|
{
|
||||||
{
|
"type": "STRING",
|
||||||
"type": "STRING",
|
"value": "[*]"
|
||||||
"value": "*"
|
},
|
||||||
},
|
{
|
||||||
{
|
"type": "REPEAT",
|
||||||
"type": "STRING",
|
"content": {
|
||||||
"value": "]"
|
"type": "CHOICE",
|
||||||
},
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "REPEAT",
|
"type": "SYMBOL",
|
||||||
"content": {
|
"name": "get_attr"
|
||||||
"type": "CHOICE",
|
},
|
||||||
"members": [
|
{
|
||||||
{
|
"type": "SYMBOL",
|
||||||
"type": "SYMBOL",
|
"name": "index"
|
||||||
"name": "get_attr"
|
}
|
||||||
},
|
]
|
||||||
{
|
}
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "index"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
},
|
},
|
||||||
"for_expr": {
|
"for_expr": {
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
@@ -1210,12 +1206,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"conflicts": [
|
"conflicts": [
|
||||||
[
|
|
||||||
"attr_splat"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"full_splat"
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
"string_lit",
|
"string_lit",
|
||||||
"quoted_template"
|
"quoted_template"
|
||||||
|
|||||||
@@ -756,6 +756,10 @@
|
|||||||
"type": ".",
|
"type": ".",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": ".*",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "/",
|
"type": "/",
|
||||||
"named": false
|
"named": false
|
||||||
@@ -800,6 +804,10 @@
|
|||||||
"type": "[",
|
"type": "[",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "[*]",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "]",
|
"type": "]",
|
||||||
"named": false
|
"named": false
|
||||||
|
|||||||
12900
src/parser.c
12900
src/parser.c
File diff suppressed because it is too large
Load Diff
@@ -52,9 +52,9 @@ foo = bar.*.foo
|
|||||||
(variable_expr
|
(variable_expr
|
||||||
(identifier))
|
(identifier))
|
||||||
(splat
|
(splat
|
||||||
(attr_splat))
|
(attr_splat
|
||||||
(get_attr
|
(get_attr
|
||||||
(identifier))))))
|
(identifier))))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
full splat
|
full splat
|
||||||
@@ -64,6 +64,26 @@ foo = bar[*].foo
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(config_file
|
||||||
|
(body
|
||||||
|
(attribute
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(variable_expr
|
||||||
|
(identifier))
|
||||||
|
(splat
|
||||||
|
(full_splat
|
||||||
|
(get_attr
|
||||||
|
(identifier))))))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
full splat repeated
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
foo = bar[*][*].a.b.c[d]
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(config_file
|
(config_file
|
||||||
(body
|
(body
|
||||||
(attribute
|
(attribute
|
||||||
@@ -73,5 +93,15 @@ foo = bar[*].foo
|
|||||||
(identifier))
|
(identifier))
|
||||||
(splat
|
(splat
|
||||||
(full_splat))
|
(full_splat))
|
||||||
(get_attr
|
(splat
|
||||||
(identifier))))))
|
(full_splat
|
||||||
|
(get_attr
|
||||||
|
(identifier))
|
||||||
|
(get_attr
|
||||||
|
(identifier))
|
||||||
|
(get_attr
|
||||||
|
(identifier))
|
||||||
|
(index
|
||||||
|
(expression
|
||||||
|
(variable_expr
|
||||||
|
(identifier))))))))))
|
||||||
|
|||||||
Reference in New Issue
Block a user