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',
rules: {
source: $ => repeat(choice(
root: $ => repeat1($.item),
item: $ => choice(
$.comment,
$.statement,
)),
),
comment: $ => prec.left(seq(token('#'), /.*/, optional(token('#')))),
comment: $ => prec.left(seq(token('#'), /.*/)),
statement: $ => choice(
$.closed_statement,
@ -60,11 +62,11 @@ module.exports = grammar({
')'
),
operator: $ => token(choice(
operator: $ => choice(
'+',
'-',
'=',
)),
),
operation: $ => prec.left(seq(
$.expression,

View File

@ -1,22 +1,26 @@
{
"name": "dust",
"rules": {
"source": {
"type": "REPEAT",
"root": {
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "SYMBOL",
"name": "statement"
}
]
"type": "SYMBOL",
"name": "item"
}
},
"item": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "SYMBOL",
"name": "statement"
}
]
},
"comment": {
"type": "PREC_LEFT",
"value": 0,
@ -33,21 +37,6 @@
{
"type": "PATTERN",
"value": ".*"
},
{
"type": "CHOICE",
"members": [
{
"type": "TOKEN",
"content": {
"type": "STRING",
"value": "#"
}
},
{
"type": "BLANK"
}
]
}
]
}
@ -240,24 +229,21 @@
]
},
"operator": {
"type": "TOKEN",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "+"
},
{
"type": "STRING",
"value": "-"
},
{
"type": "STRING",
"value": "="
}
]
}
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "+"
},
{
"type": "STRING",
"value": "-"
},
{
"type": "STRING",
"value": "="
}
]
},
"operation": {
"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",
"named": true,
@ -124,19 +143,20 @@
}
},
{
"type": "source",
"type": "operator",
"named": true,
"fields": {}
},
{
"type": "root",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "comment",
"named": true
},
{
"type": "statement",
"type": "item",
"named": true
}
]
@ -212,10 +232,22 @@
"type": ")",
"named": false
},
{
"type": "+",
"named": false
},
{
"type": ",",
"named": false
},
{
"type": "-",
"named": false
},
{
"type": "=",
"named": false
},
{
"type": "close",
"named": true
@ -252,10 +284,6 @@
"type": "integer",
"named": true
},
{
"type": "operator",
"named": true
},
{
"type": "string",
"named": true

File diff suppressed because it is too large Load Diff