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

@ -66,26 +66,18 @@ select number from foobar where text == 'answer'
(statement
(open_statement
(expression
(operation
(select
(identifier)
(identifier)
(expression
(identifier))
(operator)
(expression
(value
(table
(identifier)
(identifier)
(list
(value
(string))
(value
(integer)))))))))))
(item
(statement
(open_statement
(expression
(value
(42)))))))
(operation
(expression
(identifier))
(operator)
(expression
(value
(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,85 +392,81 @@
]
},
"operator": {
"type": "PREC",
"value": 2,
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "="
},
{
"type": "STRING",
"value": "+"
},
{
"type": "STRING",
"value": "-"
},
{
"type": "STRING",
"value": "*"
},
{
"type": "STRING",
"value": "/"
},
{
"type": "STRING",
"value": "%"
},
{
"type": "STRING",
"value": "=="
},
{
"type": "STRING",
"value": "+="
},
{
"type": "STRING",
"value": "-="
},
{
"type": "STRING",
"value": "&&"
},
{
"type": "STRING",
"value": "||"
},
{
"type": "STRING",
"value": "and"
},
{
"type": "STRING",
"value": "or"
},
{
"type": "STRING",
"value": "insert"
},
{
"type": "STRING",
"value": "into"
},
{
"type": "STRING",
"value": "select"
},
{
"type": "STRING",
"value": "from"
},
{
"type": "STRING",
"value": "where"
}
]
}
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "="
},
{
"type": "STRING",
"value": "+"
},
{
"type": "STRING",
"value": "-"
},
{
"type": "STRING",
"value": "*"
},
{
"type": "STRING",
"value": "/"
},
{
"type": "STRING",
"value": "%"
},
{
"type": "STRING",
"value": "=="
},
{
"type": "STRING",
"value": "+="
},
{
"type": "STRING",
"value": "-="
},
{
"type": "STRING",
"value": "&&"
},
{
"type": "STRING",
"value": "||"
},
{
"type": "STRING",
"value": "and"
},
{
"type": "STRING",
"value": "or"
},
{
"type": "STRING",
"value": "insert"
},
{
"type": "STRING",
"value": "into"
},
{
"type": "STRING",
"value": "select"
},
{
"type": "STRING",
"value": "from"
},
{
"type": "STRING",
"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