Add array concat operator
This commit is contained in:
@@ -129,3 +129,32 @@ Logical and comparison
|
||||
left: (unary_expression
|
||||
operand: (identifier))
|
||||
right: (literal (boolean))))))
|
||||
|
||||
==================
|
||||
Array concat
|
||||
==================
|
||||
{
|
||||
roles = ["read"] ++ ["write", "admin"];
|
||||
ports = [8000 + 80] ++ [9443];
|
||||
}
|
||||
---
|
||||
|
||||
(source_file
|
||||
(object
|
||||
(field_definition
|
||||
path: (field_path (identifier))
|
||||
value: (binary_expression
|
||||
left: (array
|
||||
(literal (string)))
|
||||
right: (array
|
||||
(literal (string))
|
||||
(literal (string)))))
|
||||
(field_definition
|
||||
path: (field_path (identifier))
|
||||
value: (binary_expression
|
||||
left: (array
|
||||
(binary_expression
|
||||
left: (literal (integer))
|
||||
right: (literal (integer))))
|
||||
right: (array
|
||||
(literal (integer)))))))
|
||||
|
||||
@@ -5,11 +5,12 @@ const PREC = {
|
||||
OR: 4,
|
||||
LOGICAL_AND: 5,
|
||||
COMPARE: 6,
|
||||
ADD: 7,
|
||||
MUL: 8,
|
||||
UNARY: 9,
|
||||
CALL: 10,
|
||||
PATH: 11,
|
||||
CONCAT: 7,
|
||||
ADD: 8,
|
||||
MUL: 9,
|
||||
UNARY: 10,
|
||||
CALL: 11,
|
||||
PATH: 12,
|
||||
};
|
||||
|
||||
function commaSep(rule) {
|
||||
@@ -192,6 +193,11 @@ module.exports = grammar({
|
||||
field('operator', choice('==', '!=', '>', '>=', '<', '<=')),
|
||||
field('right', $._expression),
|
||||
)),
|
||||
prec.left(PREC.CONCAT, seq(
|
||||
field('left', $._expression),
|
||||
field('operator', token(prec(2, '++'))),
|
||||
field('right', $._expression),
|
||||
)),
|
||||
prec.left(PREC.ADD, seq(
|
||||
field('left', $._expression),
|
||||
field('operator', choice('+', '-')),
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"++"
|
||||
"&&"
|
||||
"||"
|
||||
"!"
|
||||
|
||||
+45
-5
@@ -716,7 +716,7 @@
|
||||
},
|
||||
"call_expression": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 10,
|
||||
"value": 11,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
@@ -786,7 +786,7 @@
|
||||
},
|
||||
"path_expression": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 11,
|
||||
"value": 12,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
@@ -815,7 +815,7 @@
|
||||
},
|
||||
"comparison_constraint": {
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 10,
|
||||
"value": 11,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
@@ -857,7 +857,7 @@
|
||||
},
|
||||
"unary_expression": {
|
||||
"type": "PREC",
|
||||
"value": 9,
|
||||
"value": 10,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
@@ -1033,6 +1033,46 @@
|
||||
{
|
||||
"type": "PREC_LEFT",
|
||||
"value": 7,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "left",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "operator",
|
||||
"content": {
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
"type": "PREC",
|
||||
"value": 2,
|
||||
"content": {
|
||||
"type": "STRING",
|
||||
"value": "++"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "right",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "PREC_LEFT",
|
||||
"value": 8,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
@@ -1074,7 +1114,7 @@
|
||||
},
|
||||
{
|
||||
"type": "PREC_LEFT",
|
||||
"value": 8,
|
||||
"value": 9,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
|
||||
+8
@@ -172,6 +172,10 @@
|
||||
"type": "+",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "++",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "-",
|
||||
"named": false
|
||||
@@ -1692,6 +1696,10 @@
|
||||
"type": "+",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "++",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": ",",
|
||||
"named": false
|
||||
|
||||
Generated
+6167
-5115
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user