Skip to content

Commit

Permalink
Merge pull request #27 from Vishalk91-4/config-rules
Browse files Browse the repository at this point in the history
Resolved schema config, various schema and rule statements
  • Loading branch information
Peefy authored Aug 27, 2024
2 parents 610f2b5 + 9488388 commit e7961cc
Show file tree
Hide file tree
Showing 5 changed files with 192,467 additions and 180,360 deletions.
17 changes: 15 additions & 2 deletions 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 Expand Up @@ -876,10 +885,14 @@ module.exports = grammar({
field('attribute', $.identifier),
)),

optional_attribute_declaration: $ => prec(2, seq(
optional_attribute_declaration: $ => prec.right(12, seq(
field('attribute', $.identifier),
'?:',
field('type', $.type),
optional(seq(
'=',
field('default', $.expression)
))
)),

optional_item: $ => prec(PREC.call, seq(
Expand Down
75 changes: 71 additions & 4 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 Expand Up @@ -3542,8 +3584,8 @@
}
},
"optional_attribute_declaration": {
"type": "PREC",
"value": 2,
"type": "PREC_RIGHT",
"value": 12,
"content": {
"type": "SEQ",
"members": [
Expand All @@ -3566,6 +3608,31 @@
"type": "SYMBOL",
"name": "type"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "="
},
{
"type": "FIELD",
"name": "default",
"content": {
"type": "SYMBOL",
"name": "expression"
}
}
]
},
{
"type": "BLANK"
}
]
}
]
}
Expand Down
41 changes: 41 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 @@ -1836,6 +1855,16 @@
}
]
},
"default": {
"multiple": false,
"required": false,
"types": [
{
"type": "expression",
"named": true
}
]
},
"type": {
"multiple": false,
"required": true,
Expand Down Expand Up @@ -1970,6 +1999,10 @@
{
"type": "expression",
"named": true
},
{
"type": "subscript",
"named": true
}
]
},
Expand Down Expand Up @@ -2059,6 +2092,10 @@
"multiple": false,
"required": false,
"types": [
{
"type": "call",
"named": true
},
{
"type": "config_expr",
"named": true
Expand All @@ -2082,6 +2119,10 @@
{
"type": "string",
"named": true
},
{
"type": "subscript",
"named": true
}
]
}
Expand Down
Loading

0 comments on commit e7961cc

Please sign in to comment.