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,9 +1,14 @@
{ {
"name": "dust", "name": "dust",
"rules": { "rules": {
"source": { "root": {
"type": "REPEAT", "type": "REPEAT1",
"content": { "content": {
"type": "SYMBOL",
"name": "item"
}
},
"item": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -15,7 +20,6 @@
"name": "statement" "name": "statement"
} }
] ]
}
}, },
"comment": { "comment": {
"type": "PREC_LEFT", "type": "PREC_LEFT",
@ -33,21 +37,6 @@
{ {
"type": "PATTERN", "type": "PATTERN",
"value": ".*" "value": ".*"
},
{
"type": "CHOICE",
"members": [
{
"type": "TOKEN",
"content": {
"type": "STRING",
"value": "#"
}
},
{
"type": "BLANK"
}
]
} }
] ]
} }
@ -240,8 +229,6 @@
] ]
}, },
"operator": { "operator": {
"type": "TOKEN",
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -257,7 +244,6 @@
"value": "=" "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