Skip to content

Commit

Permalink
Unary predicates
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekStride committed Dec 1, 2022
1 parent 41f1de2 commit 6adc957
Show file tree
Hide file tree
Showing 5 changed files with 69,577 additions and 68,899 deletions.
7 changes: 5 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1356,10 +1356,13 @@ module.exports = grammar({
$.select_expression,
),

where_expression: $ => seq(
$._expression,
where_expression: $ => choice(
$.predicate,
alias($._field_predicate, $.predicate),
),

_field_predicate: $ => field('operand', $.field),

predicate: $ => choice(
...[
['=', 'binary_relation'],
Expand Down
21 changes: 19 additions & 2 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -5541,14 +5541,31 @@
]
},
"where_expression": {
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
"name": "predicate"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_field_predicate"
},
"named": true,
"value": "predicate"
}
]
},
"_field_predicate": {
"type": "FIELD",
"name": "operand",
"content": {
"type": "SYMBOL",
"name": "field"
}
},
"predicate": {
"type": "CHOICE",
"members": [
Expand Down
54 changes: 10 additions & 44 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -2943,6 +2943,16 @@
}
]
},
"operand": {
"multiple": false,
"required": false,
"types": [
{
"type": "field",
"named": true
}
]
},
"operator": {
"multiple": true,
"required": false,
Expand Down Expand Up @@ -3792,53 +3802,9 @@
"multiple": false,
"required": true,
"types": [
{
"type": "binary_expression",
"named": true
},
{
"type": "case",
"named": true
},
{
"type": "cast",
"named": true
},
{
"type": "count",
"named": true
},
{
"type": "field",
"named": true
},
{
"type": "invocation",
"named": true
},
{
"type": "list",
"named": true
},
{
"type": "literal",
"named": true
},
{
"type": "parameter",
"named": true
},
{
"type": "predicate",
"named": true
},
{
"type": "subquery",
"named": true
},
{
"type": "window_function",
"named": true
}
]
}
Expand Down
Loading

0 comments on commit 6adc957

Please sign in to comment.