Implement insert expression

This commit is contained in:
Jeff 2023-09-30 16:17:09 -04:00
parent 77c15c5d54
commit 191970fabb
5 changed files with 6426 additions and 6120 deletions

View File

@ -92,20 +92,10 @@ insert ['bob was here', 0] into foobar
(statement
(open_statement
(expression
(identifier)))))
(item
(statement
(open_statement
(expression
(operation
(expression
(value
(insert
(list
(value
(string))
(value
(integer)))))
(operator)
(expression
(identifier))))))))
(integer)))
(identifier)))))))

View File

@ -18,7 +18,7 @@ module.exports = grammar({
$.yield_statement,
)),
open_statement: $ => prec.left($.expression),
open_statement: $ => prec.right($.expression),
yield_statement: $ => seq($.open_statement, '->', $.open_statement),
@ -29,6 +29,7 @@ module.exports = grammar({
$.control_flow,
$.tool,
$.select,
$.insert,
),
identifier: $ => /[a-z|_|.]+[0-9]?/,
@ -101,11 +102,6 @@ module.exports = grammar({
'||',
'and',
'or',
'insert',
'into',
'select',
'from',
'where',
),
operation: $ => prec.right(seq(
@ -124,6 +120,16 @@ module.exports = grammar({
),
)),
insert: $ => prec.right(seq(
'insert',
repeat1($.list),
'into',
$.identifier,
optional(
seq('where', $.expression)
),
)),
control_flow: $ => prec.right(seq(
'if',
$.expression,

View File

@ -60,7 +60,7 @@
}
},
"open_statement": {
"type": "PREC_LEFT",
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SYMBOL",
@ -110,6 +110,10 @@
{
"type": "SYMBOL",
"name": "select"
},
{
"type": "SYMBOL",
"name": "insert"
}
]
},
@ -445,26 +449,6 @@
{
"type": "STRING",
"value": "or"
},
{
"type": "STRING",
"value": "insert"
},
{
"type": "STRING",
"value": "into"
},
{
"type": "STRING",
"value": "select"
},
{
"type": "STRING",
"value": "from"
},
{
"type": "STRING",
"value": "where"
}
]
},
@ -535,6 +519,55 @@
]
}
},
"insert": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "insert"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "list"
}
},
{
"type": "STRING",
"value": "into"
},
{
"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

@ -44,6 +44,10 @@
"type": "identifier",
"named": true
},
{
"type": "insert",
"named": true
},
{
"type": "operation",
"named": true
@ -82,6 +86,29 @@
]
}
},
{
"type": "insert",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "expression",
"named": true
},
{
"type": "identifier",
"named": true
},
{
"type": "list",
"named": true
}
]
}
},
{
"type": "item",
"named": true,

12404
src/parser.c

File diff suppressed because it is too large Load Diff