Skip to content

Commit

Permalink
Added various expressions, fixed rule statement and quantifier expres…
Browse files Browse the repository at this point in the history
…sion

Signed-off-by: Vishal <[email protected]>
  • Loading branch information
Vishalk91-4 committed Aug 27, 2024
1 parent 813d518 commit 9488388
Show file tree
Hide file tree
Showing 5 changed files with 190,213 additions and 183,007 deletions.
11 changes: 10 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ module.exports = grammar({
field('quant_target', $.quant_target),
'{',
choice(
field('expr1', $.expression),
field('expr1', choice($.subscript, $.expression)),
seq(
field('dotted_name', $.dotted_name),
field('string', $.string)
Expand All @@ -423,6 +423,8 @@ module.exports = grammar({
)),

quant_target: $ => prec(1, choice(
$.subscript,
$.call,
field('dictionary_or_list', $.identifier),
$.dictionary,
$.string,
Expand Down Expand Up @@ -649,6 +651,7 @@ module.exports = grammar({
$.schema_instantiation,
$.paren_expression,
$.braces_expression,
$.not_expression,
$.optional_attribute,
$.optional_item,
$.optional_attribute_declaration,
Expand All @@ -671,6 +674,12 @@ module.exports = grammar({
field('argument', $.primary_expression),
)),

not_expression : $ => prec.left(PREC.not, seq(
$.primary_expression,
'not',
$.primary_expression
)),

boolean_operator: $ => choice(
prec.left(PREC.and, seq(
field('left', $.expression),
Expand Down
46 changes: 44 additions & 2 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -945,8 +945,17 @@
"type": "FIELD",
"name": "expr1",
"content": {
"type": "SYMBOL",
"name": "expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "subscript"
},
{
"type": "SYMBOL",
"name": "expression"
}
]
}
},
{
Expand Down Expand Up @@ -1010,6 +1019,14 @@
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "subscript"
},
{
"type": "SYMBOL",
"name": "call"
},
{
"type": "FIELD",
"name": "dictionary_or_list",
Expand Down Expand Up @@ -1986,6 +2003,10 @@
"type": "SYMBOL",
"name": "braces_expression"
},
{
"type": "SYMBOL",
"name": "not_expression"
},
{
"type": "SYMBOL",
"name": "optional_attribute"
Expand Down Expand Up @@ -2072,6 +2093,27 @@
]
}
},
"not_expression": {
"type": "PREC_LEFT",
"value": 12,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "primary_expression"
},
{
"type": "STRING",
"value": "not"
},
{
"type": "SYMBOL",
"name": "primary_expression"
}
]
}
},
"boolean_operator": {
"type": "CHOICE",
"members": [
Expand Down
31 changes: 31 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@
"type": "none",
"named": true
},
{
"type": "not_expression",
"named": true
},
{
"type": "null_coalesce",
"named": true
Expand Down Expand Up @@ -1695,6 +1699,21 @@
]
}
},
{
"type": "not_expression",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "primary_expression",
"named": true
}
]
}
},
{
"type": "not_in_operation",
"named": true,
Expand Down Expand Up @@ -1980,6 +1999,10 @@
{
"type": "expression",
"named": true
},
{
"type": "subscript",
"named": true
}
]
},
Expand Down Expand Up @@ -2069,6 +2092,10 @@
"multiple": false,
"required": false,
"types": [
{
"type": "call",
"named": true
},
{
"type": "config_expr",
"named": true
Expand All @@ -2092,6 +2119,10 @@
{
"type": "string",
"named": true
},
{
"type": "subscript",
"named": true
}
]
}
Expand Down
Loading

0 comments on commit 9488388

Please sign in to comment.