Add new root node

This commit is contained in:
Jeff 2023-09-29 07:17:47 -04:00
parent c7bfba7767
commit 954ea0928c
5 changed files with 1441 additions and 1164 deletions

@ -1 +1 @@
Subproject commit 4907dd9f8f6e7752c393e316a4eea27d1ff7fa3a Subproject commit c9c7eb31737fc3ce02bed5ce0069d8e04345f00b

View File

@ -2,12 +2,14 @@ module.exports = grammar({
name: 'dust', name: 'dust',
rules: { rules: {
source: $ => repeat(choice( root: $ => repeat1($.item),
item: $ => choice(
$.comment, $.comment,
$.statement, $.statement,
)), ),
comment: $ => prec.left(seq(token('#'), /.*/, optional(token('#')))), comment: $ => prec.left(seq(token('#'), /.*/)),
statement: $ => choice( statement: $ => choice(
$.closed_statement, $.closed_statement,
@ -60,11 +62,11 @@ module.exports = grammar({
')' ')'
), ),
operator: $ => token(choice( operator: $ => choice(
'+', '+',
'-', '-',
'=', '=',
)), ),
operation: $ => prec.left(seq( operation: $ => prec.left(seq(
$.expression, $.expression,

View File

@ -1,22 +1,26 @@
{ {
"name": "dust", "name": "dust",
"rules": { "rules": {
"source": { "root": {
"type": "REPEAT", "type": "REPEAT1",
"content": { "content": {
"type": "CHOICE", "type": "SYMBOL",
"members": [ "name": "item"
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "SYMBOL",
"name": "statement"
}
]
} }
}, },
"item": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "SYMBOL",
"name": "statement"
}
]
},
"comment": { "comment": {
"type": "PREC_LEFT", "type": "PREC_LEFT",
"value": 0, "value": 0,
@ -33,21 +37,6 @@
{ {
"type": "PATTERN", "type": "PATTERN",
"value": ".*" "value": ".*"
},
{
"type": "CHOICE",
"members": [
{
"type": "TOKEN",
"content": {
"type": "STRING",
"value": "#"
}
},
{
"type": "BLANK"
}
]
} }
] ]
} }
@ -240,24 +229,21 @@
] ]
}, },
"operator": { "operator": {
"type": "TOKEN", "type": "CHOICE",
"content": { "members": [
"type": "CHOICE", {
"members": [ "type": "STRING",
{ "value": "+"
"type": "STRING", },
"value": "+" {
}, "type": "STRING",
{ "value": "-"
"type": "STRING", },
"value": "-" {
}, "type": "STRING",
{ "value": "="
"type": "STRING", }
"value": "=" ]
}
]
}
}, },
"operation": { "operation": {
"type": "PREC_LEFT", "type": "PREC_LEFT",

View File

@ -74,6 +74,25 @@
] ]
} }
}, },
{
"type": "item",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "comment",
"named": true
},
{
"type": "statement",
"named": true
}
]
}
},
{ {
"type": "list", "type": "list",
"named": true, "named": true,
@ -124,19 +143,20 @@
} }
}, },
{ {
"type": "source", "type": "operator",
"named": true,
"fields": {}
},
{
"type": "root",
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "comment", "type": "item",
"named": true
},
{
"type": "statement",
"named": true "named": true
} }
] ]
@ -212,10 +232,22 @@
"type": ")", "type": ")",
"named": false "named": false
}, },
{
"type": "+",
"named": false
},
{ {
"type": ",", "type": ",",
"named": false "named": false
}, },
{
"type": "-",
"named": false
},
{
"type": "=",
"named": false
},
{ {
"type": "close", "type": "close",
"named": true "named": true
@ -252,10 +284,6 @@
"type": "integer", "type": "integer",
"named": true "named": true
}, },
{
"type": "operator",
"named": true
},
{ {
"type": "string", "type": "string",
"named": true "named": true

File diff suppressed because it is too large Load Diff