Implement select expression

This commit is contained in:
Jeff 2023-09-30 16:06:01 -04:00
parent cbe92941a1
commit 77c15c5d54
6 changed files with 5206 additions and 4552 deletions

View File

@ -51,7 +51,6 @@ x = foobar.0
---
(root
(item
(statement

View File

@ -65,6 +65,10 @@ select number from foobar where text == 'answer'
(item
(statement
(open_statement
(expression
(select
(identifier)
(identifier)
(expression
(operation
(expression
@ -72,20 +76,8 @@ select number from foobar where text == 'answer'
(operator)
(expression
(value
(table
(identifier)
(identifier)
(list
(value
(string))
(value
(integer)))))))))))
(item
(statement
(open_statement
(expression
(value
(42)))))))
(string)))))))))))
==================
Table Insert

View File

@ -28,6 +28,7 @@ module.exports = grammar({
$.operation,
$.control_flow,
$.tool,
$.select,
),
identifier: $ => /[a-z|_|.]+[0-9]?/,
@ -86,7 +87,7 @@ module.exports = grammar({
'}',
),
operator: $ => prec(2, choice(
operator: $ => choice(
'=',
'+',
'-',
@ -105,7 +106,7 @@ module.exports = grammar({
'select',
'from',
'where',
)),
),
operation: $ => prec.right(seq(
$.expression,
@ -113,6 +114,16 @@ module.exports = grammar({
$.expression,
)),
select: $ => prec.right(seq(
'select',
$.identifier,
'from',
$.identifier,
optional(
seq('where', $.expression)
),
)),
control_flow: $ => prec.right(seq(
'if',
$.expression,

View File

@ -106,6 +106,10 @@
{
"type": "SYMBOL",
"name": "tool"
},
{
"type": "SYMBOL",
"name": "select"
}
]
},
@ -388,9 +392,6 @@
]
},
"operator": {
"type": "PREC",
"value": 2,
"content": {
"type": "CHOICE",
"members": [
{
@ -466,7 +467,6 @@
"value": "where"
}
]
}
},
"operation": {
"type": "PREC_RIGHT",
@ -489,6 +489,52 @@
]
}
},
"select": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "select"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "from"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "where"
},
{
"type": "SYMBOL",
"name": "expression"
}
]
},
{
"type": "BLANK"
}
]
}
]
}
},
"control_flow": {
"type": "PREC_RIGHT",
"value": 0,

View File

@ -48,6 +48,10 @@
"type": "operation",
"named": true
},
{
"type": "select",
"named": true
},
{
"type": "tool",
"named": true
@ -185,6 +189,25 @@
]
}
},
{
"type": "select",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "expression",
"named": true
},
{
"type": "identifier",
"named": true
}
]
}
},
{
"type": "statement",
"named": true,

File diff suppressed because it is too large Load Diff