forked from DerekStride/tree-sitter-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrammar.js
More file actions
84 lines (72 loc) · 1.83 KB
/
Copy pathgrammar.js
File metadata and controls
84 lines (72 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import keyword_rules from "./grammar/keywords.js";
import type_rules from "./grammar/types.js";
import column_list_rules from "./grammar/column-lists.js";
import expression_rules from "./grammar/expressions.js";
import transaction_rules from "./grammar/transactions.js";
import statement_rules from "./grammar/statements/index.js";
export default grammar({
name: 'sql',
extras: $ => [
/\s\n/,
/\s/,
$.comment,
$.marginalia,
],
externals: $ => [
$._dollar_quoted_string_start_tag,
$._dollar_quoted_string_end_tag,
$._dollar_quoted_string,
],
conflicts: $ => [
[$.object_reference, $._qualified_field],
[$.field, $._qualified_field],
[$._column, $._qualified_field],
[$.object_reference],
[$.between_expression, $.binary_expression],
[$.time],
[$.timestamp],
[$.statement, $._tsql_function_body_statement],
[$.return_statement, $._function_return],
[$.var_declaration, $.function_declaration],
],
precedences: $ => [
[
'binary_is',
'unary_not',
'binary_exp',
'binary_times',
'binary_plus',
'unary_other',
'binary_other',
'binary_in',
'binary_compare',
'binary_relation',
'pattern_matching',
'between',
'clause_connective',
'clause_disjunctive',
],
],
word: $ => $._identifier,
rules: {
program: $ => repeat(
seq(
choice(
$.statement,
$.block,
$.keyword_go,
),
optional(';'),
),
),
comment: _ => /--.*/,
// https://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment
marginalia: _ => /\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//,
...keyword_rules,
...type_rules,
...column_list_rules,
...expression_rules,
...transaction_rules,
...statement_rules,
}
});