-
Notifications
You must be signed in to change notification settings - Fork 111
Tsql grammar fixes #356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tsql grammar fixes #356
Changes from all commits
12f9a6d
065b2fb
0d007bc
df87b94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -25,39 +25,55 @@ export default { | |||||
| $.interval, | ||||||
| $.between_expression, | ||||||
| $.parenthesized_expression, | ||||||
| $.object_id, | ||||||
| ) | ||||||
| ), | ||||||
|
|
||||||
| object_reference: $ => choice( | ||||||
| seq( | ||||||
| field('database', $.identifier), | ||||||
| '.', | ||||||
| field('schema', $.identifier), | ||||||
| '.', | ||||||
| field('name', $.identifier), | ||||||
| ), | ||||||
| seq( | ||||||
| field('schema', $.identifier), | ||||||
| '.', | ||||||
| field('name', $.identifier), | ||||||
| ), | ||||||
| object_reference: $ => choice( | ||||||
| seq( | ||||||
| field('server', $.identifier), | ||||||
| '.', | ||||||
| field('database', $.identifier), | ||||||
| '.', | ||||||
| field('schema', $.identifier), | ||||||
| '.', | ||||||
| field('name', $.identifier), | ||||||
| ), | ||||||
| seq( | ||||||
| field('database', $.identifier), | ||||||
| '.', | ||||||
| field('schema', $.identifier), | ||||||
| '.', | ||||||
| field('name', $.identifier), | ||||||
| ), | ||||||
| seq( | ||||||
| field('database', $.identifier), | ||||||
| '..', | ||||||
| field('name', $.identifier), | ||||||
| ), | ||||||
| seq( | ||||||
| field('schema', $.identifier), | ||||||
| '.', | ||||||
| field('name', $.identifier), | ||||||
| ), | ||||||
| field('name', $.identifier), | ||||||
| ), | ||||||
|
|
||||||
| field: $ => field('name', $.identifier), | ||||||
| field: $ => field('name', $.identifier), | ||||||
|
|
||||||
| _qualified_field: $ => seq( | ||||||
| optional( | ||||||
| seq( | ||||||
| optional_parenthesis($.object_reference), | ||||||
| '.', | ||||||
| ), | ||||||
| _qualified_field: $ => seq( | ||||||
| optional( | ||||||
| seq( | ||||||
| optional_parenthesis($.object_reference), | ||||||
| '.', | ||||||
| ), | ||||||
| field('name', $.identifier), | ||||||
| ), | ||||||
| field('name', $.identifier), | ||||||
| ), | ||||||
|
|
||||||
| parameter: $ => /\?|(\$[0-9]+)/, | ||||||
| parameter: $ => choice( | ||||||
| /\?|(\$[0-9]+)/, | ||||||
| $._tsql_parameter, | ||||||
| ), | ||||||
|
|
||||||
| case: $ => seq( | ||||||
| $.keyword_case, | ||||||
|
|
@@ -171,7 +187,7 @@ export default { | |||||
| ), | ||||||
| ), | ||||||
|
|
||||||
| filter_expression : $ => seq( | ||||||
| filter_expression: $ => seq( | ||||||
| $.keyword_filter, | ||||||
| wrapped_in_parenthesis($.where), | ||||||
| ), | ||||||
|
|
@@ -330,23 +346,23 @@ export default { | |||||
|
|
||||||
| // Postgres syntax for intervals | ||||||
| interval: $ => seq( | ||||||
| $.keyword_interval, | ||||||
| $._literal_string, | ||||||
| $.keyword_interval, | ||||||
| $._literal_string, | ||||||
| ), | ||||||
|
|
||||||
| between_expression: $ => choice( | ||||||
| ...[ | ||||||
| [$.keyword_between, 'between'], | ||||||
| [seq($.keyword_not, $.keyword_between), 'between'], | ||||||
| ].map(([operator, precedence]) => | ||||||
| prec.left(precedence, seq( | ||||||
| field('left', $._expression), | ||||||
| field('operator', operator), | ||||||
| field('low', $._expression), | ||||||
| $.keyword_and, | ||||||
| field('high', $._expression) | ||||||
| )) | ||||||
| ), | ||||||
| [$.keyword_between, 'between'], | ||||||
| [seq($.keyword_not, $.keyword_between), 'between'], | ||||||
| ].map(([operator, precedence]) => | ||||||
| prec.left(precedence, seq( | ||||||
| field('left', $._expression), | ||||||
| field('operator', operator), | ||||||
| field('low', $._expression), | ||||||
| $.keyword_and, | ||||||
| field('high', $._expression) | ||||||
| )) | ||||||
| ), | ||||||
| ), | ||||||
|
|
||||||
| not_in: $ => seq( | ||||||
|
|
@@ -409,26 +425,13 @@ export default { | |||||
| $._identifier, | ||||||
| $._double_quote_string, | ||||||
| $._backtick_quoted_string, | ||||||
| $._tsql_parameter, | ||||||
| seq("`", $._identifier, "`"), | ||||||
| $._tsql_bracket_identifier, | ||||||
| ), | ||||||
| _tsql_parameter: $ => seq('@', $._identifier), | ||||||
| // support nordic chars and umlaue | ||||||
| _identifier: _ => /[A-Za-z_\u00C0-\u017F][0-9A-Za-z_\u00C0-\u017F]*/, | ||||||
|
|
||||||
| object_id: $ => seq( | ||||||
| $.keyword_object_id, | ||||||
| wrapped_in_parenthesis( | ||||||
| seq( | ||||||
| alias($._literal_string, $.literal), | ||||||
| optional( | ||||||
| seq( | ||||||
| ',', | ||||||
| alias($._literal_string, $.literal), | ||||||
| ), | ||||||
| ), | ||||||
| ), | ||||||
| ), | ||||||
| ), | ||||||
| _tsql_bracket_identifier: _ => /\[[^\]]*\]/, | ||||||
| _tsql_parameter: _ => /@[A-Za-z_0-9]*/, | ||||||
|
||||||
| _tsql_parameter: _ => /@[A-Za-z_0-9]*/, | |
| _tsql_parameter: _ => /@[_A-Za-z\u00C0-\u017F][0-9A-Za-z_\u00C0-\u017F]*/, |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -174,9 +174,9 @@ export default { | |||||||
| keyword_hash: _ => make_keyword("hash"), | ||||||||
| keyword_gist: _ => make_keyword("gist"), | ||||||||
| keyword_spgist: _ => make_keyword("spgist"), | ||||||||
| keyword_gin: _ => make_keyword("gin"), | ||||||||
| keyword_gin: _ => make_keyword("gin"), | ||||||||
| keyword_brin: _ => make_keyword("brin"), | ||||||||
| keyword_like: _ => choice(make_keyword("like"),make_keyword("ilike")), | ||||||||
| keyword_like: _ => choice(make_keyword("like"), make_keyword("ilike")), | ||||||||
| keyword_similar: _ => make_keyword("similar"), | ||||||||
| keyword_unsigned: _ => make_keyword("unsigned"), | ||||||||
| keyword_zerofill: _ => make_keyword("zerofill"), | ||||||||
|
|
@@ -244,7 +244,6 @@ export default { | |||||||
| keyword_invoker: _ => make_keyword("invoker"), | ||||||||
| keyword_security: _ => make_keyword("security"), | ||||||||
| keyword_version: _ => make_keyword("version"), | ||||||||
| keyword_extension: _ => make_keyword("extension"), | ||||||||
| keyword_out: _ => make_keyword("out"), | ||||||||
|
||||||||
| keyword_out: _ => make_keyword("out"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remobe duplicate
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keyword_object_id appears to have been removed, but test/corpus/expressions.txt and queries/highlights.scm still reference (keyword_object_id) / object_id. Either reintroduce the keyword (and corresponding object_id expression rule) or update those tests/queries to match the new intended representation.
| keyword_nocount: _ => make_keyword("nocount"), | |
| keyword_nocount: _ => make_keyword("nocount"), | |
| keyword_object_id: _ => make_keyword("object_id"), |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keyword_out is defined twice in this file (once earlier and again here). Even though the definitions are identical, the duplicate key is easy to miss and can cause confusion during future edits; remove one of them to keep the keyword list canonical.
| keyword_out: _ => make_keyword("out"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
programno longer includes thetransactionrule (it now only allowsstatement,block, orGO). Since the repository still hastest/corpus/transaction.txtasserting a(transaction ...)node, this change will break existing corpus tests unless the transaction corpus (and any dependent queries) are updated accordingly or thetransactionrule is reintroduced.