Change syntax

This commit is contained in:
Jeff 2023-09-30 22:59:27 -04:00
parent 69fda534a3
commit 57d908af9c
5 changed files with 6527 additions and 7278 deletions

@ -1 +1 @@
Subproject commit f596c6b5811cabc9b1b8ef87b9c6ce627b567c93 Subproject commit 1f829d930a8a5d4683ac41c6a2085c5f482868cd

View File

@ -14,13 +14,11 @@ module.exports = grammar({
comment: $ => seq(token('#'), /.*/), comment: $ => seq(token('#'), /.*/),
statement: $ => prec.right(choice( statement: $ => prec.right(choice(
$.open_statement, $.expression,
$.yield_statement, $.yield,
)), )),
open_statement: $ => prec.right($.expression), yield: $ => prec.left(seq($.statement, '->', $.statement)),
yield_statement: $ => seq($.open_statement, '->', $.open_statement),
expression: $ => choice( expression: $ => choice(
$._expression_kind, $._expression_kind,
@ -57,11 +55,7 @@ module.exports = grammar({
integer: $ => /\d+/, integer: $ => /\d+/,
string: $ => choice( string: $ => /(".*?")|('.*?')|(`.*?`)/,
/'([^"]+)'/,
/"([^"]+)"/,
/`([^"]+)`/
),
empty: $ => '()', empty: $ => '()',

View File

@ -46,29 +46,24 @@
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "open_statement" "name": "expression"
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "yield_statement" "name": "yield"
} }
] ]
} }
}, },
"open_statement": { "yield": {
"type": "PREC_RIGHT", "type": "PREC_LEFT",
"value": 0, "value": 0,
"content": { "content": {
"type": "SYMBOL",
"name": "expression"
}
},
"yield_statement": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "open_statement" "name": "statement"
}, },
{ {
"type": "STRING", "type": "STRING",
@ -76,9 +71,10 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "open_statement" "name": "statement"
} }
] ]
}
}, },
"expression": { "expression": {
"type": "CHOICE", "type": "CHOICE",
@ -209,21 +205,8 @@
"value": "\\d+" "value": "\\d+"
}, },
"string": { "string": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN", "type": "PATTERN",
"value": "'([^\"]+)'" "value": "(\".*?\")|('.*?')|(`.*?`)"
},
{
"type": "PATTERN",
"value": "\"([^\"]+)\""
},
{
"type": "PATTERN",
"value": "`([^\"]+)`"
}
]
}, },
"empty": { "empty": {
"type": "STRING", "type": "STRING",

View File

@ -256,21 +256,6 @@
"named": true, "named": true,
"fields": {} "fields": {}
}, },
{
"type": "open_statement",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "expression",
"named": true
}
]
}
},
{ {
"type": "root", "type": "root",
"named": true, "named": true,
@ -314,21 +299,16 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "open_statement", "type": "expression",
"named": true "named": true
}, },
{ {
"type": "yield_statement", "type": "yield",
"named": true "named": true
} }
] ]
} }
}, },
{
"type": "string",
"named": true,
"fields": {}
},
{ {
"type": "table", "type": "table",
"named": true, "named": true,
@ -396,7 +376,7 @@
} }
}, },
{ {
"type": "yield_statement", "type": "yield",
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
@ -404,7 +384,7 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "open_statement", "type": "statement",
"named": true "named": true
} }
] ]
@ -546,6 +526,10 @@
"type": "select", "type": "select",
"named": false "named": false
}, },
{
"type": "string",
"named": true
},
{ {
"type": "table", "type": "table",
"named": false "named": false

13698
src/parser.c

File diff suppressed because it is too large Load Diff