Convert syntax tree to Evaluator

This commit is contained in:
Jeff 2023-09-28 22:55:47 -04:00
parent bbe1b96341
commit fdd841a2d2
4 changed files with 490 additions and 368 deletions

View File

@ -3,9 +3,12 @@ module.exports = grammar({
rules: { rules: {
source: $ => repeat(choice( source: $ => repeat(choice(
$.comment,
$.statement, $.statement,
)), )),
comment: $ => seq('#', /.*/),
statement: $ => seq($.expression, $.close), statement: $ => seq($.expression, $.close),
expression: $ => choice( expression: $ => choice(

View File

@ -6,6 +6,10 @@
"content": { "content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{
"type": "SYMBOL",
"name": "comment"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "statement"
@ -13,6 +17,19 @@
] ]
} }
}, },
"comment": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "#"
},
{
"type": "PATTERN",
"value": ".*"
}
]
},
"statement": { "statement": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [

View File

@ -4,6 +4,11 @@
"named": true, "named": true,
"fields": {} "fields": {}
}, },
{
"type": "comment",
"named": true,
"fields": {}
},
{ {
"type": "expression", "type": "expression",
"named": true, "named": true,
@ -74,6 +79,10 @@
"multiple": true, "multiple": true,
"required": false, "required": false,
"types": [ "types": [
{
"type": "comment",
"named": true
},
{ {
"type": "statement", "type": "statement",
"named": true "named": true
@ -139,6 +148,10 @@
] ]
} }
}, },
{
"type": "#",
"named": false
},
{ {
"type": "(", "type": "(",
"named": false "named": false

File diff suppressed because it is too large Load Diff