Skip to content

Commit

Permalink
parser: parse function call for sort clause
Browse files Browse the repository at this point in the history
It seems it is possible to use functions calls for sort clauses instead
of identifiers too, did not test other expressions though.
  • Loading branch information
jkbz64 committed Sep 10, 2023
1 parent a2518fe commit 62aae55
Show file tree
Hide file tree
Showing 5 changed files with 12,283 additions and 12,095 deletions.
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ module.exports = grammar({
/// FOR statement
sort_order: ($) => choice(kw("DESCENDING")),
sort_column: ($) =>
seq(field("column", $.identifier), optional($.sort_order)),
seq(field("column", choice($.function_call, $.identifier)), optional($.sort_order)),

sort_clause: ($) =>
seq(optional(kw("BREAK")), kw("BY"), repeat1($.sort_column)),
Expand Down
13 changes: 11 additions & 2 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -4108,8 +4108,17 @@
"type": "FIELD",
"name": "column",
"content": {
"type": "SYMBOL",
"name": "identifier"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "function_call"
},
{
"type": "SYMBOL",
"name": "identifier"
}
]
}
},
{
Expand Down
4 changes: 4 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,10 @@
"multiple": false,
"required": true,
"types": [
{
"type": "function_call",
"named": true
},
{
"type": "identifier",
"named": true
Expand Down
Loading

0 comments on commit 62aae55

Please sign in to comment.