Implement select expression
This commit is contained in:
parent
cbe92941a1
commit
77c15c5d54
@ -51,7 +51,6 @@ x = foobar.0
|
||||
|
||||
---
|
||||
|
||||
|
||||
(root
|
||||
(item
|
||||
(statement
|
||||
|
@ -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
|
||||
|
15
grammar.js
15
grammar.js
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
9483
src/parser.c
9483
src/parser.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user