-
Notifications
You must be signed in to change notification settings - Fork 496
/
hsql.bnf
179 lines (162 loc) · 7.5 KB
/
hsql.bnf
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
{
// Specify the parent parser.
overrides="com.alecstrong.sql.psi.core.SqlParser"
elementTypeClass = "com.alecstrong.sql.psi.core.SqlElementType"
implements="com.alecstrong.sql.psi.core.psi.SqlCompositeElement"
extends="com.alecstrong.sql.psi.core.psi.SqlCompositeElementImpl"
psiClassPrefix = "Hsql"
parserImports=[
"static com.alecstrong.sql.psi.core.psi.SqlTypes.ALWAYS"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.AND"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.AS"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.ASC"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.BETWEEN"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.BY"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.COLLATE"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.COMMA"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.CONSTRAINT"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.DEFAULT"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.DESC"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.DIGIT"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.DOT"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.GENERATED"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.GROUP"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.ID"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.INSERT"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.INTO"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.KEY"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.LP"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.MERGE"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.MULTIPLY"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.NO"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.NOT"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.NULL"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.ORDER"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.PARTITION"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.PRIMARY"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.ROW"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.RP"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.TO"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.UNIQUE"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.WHERE"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.WITH"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.WITHOUT"
]
}
overrides ::= type_name | column_constraint | bind_parameter | insert_stmt | result_column | generated_clause
type_name ::= (
tiny_int_data_type |
small_int_data_type |
int_data_type |
big_int_data_type |
fixed_point_data_type |
approximate_numeric_data_type |
boolean_data_type |
date_data_type |
character_string_data_type |
binary_string_data_type |
bit_string_data_type |
interval_data_type
) {
extends = "com.alecstrong.sql.psi.core.psi.impl.SqlTypeNameImpl"
implements = "com.alecstrong.sql.psi.core.psi.SqlTypeName"
override = true
}
column_constraint ::= [ CONSTRAINT {identifier} ] (
'AUTO_INCREMENT' |
PRIMARY KEY [ ASC | DESC ] {conflict_clause} |
NOT NULL {conflict_clause} |
UNIQUE {conflict_clause} |
{check_constraint} |
generated_clause |
{default_constraint} |
COLLATE {collation_name} |
{foreign_key_clause}
) {
extends = "com.alecstrong.sql.psi.core.psi.impl.SqlColumnConstraintImpl"
implements = "com.alecstrong.sql.psi.core.psi.SqlColumnConstraint"
override = true
}
bind_parameter ::= DEFAULT | ( '?' | ':' {identifier} ) {
mixin = "app.cash.sqldelight.dialect.grammar.mixins.BindParameterMixin"
extends = "com.alecstrong.sql.psi.core.psi.impl.SqlBindParameterImpl"
implements = "com.alecstrong.sql.psi.core.psi.SqlBindParameter"
override = true
}
tiny_int_data_type ::= 'TINYINT'
small_int_data_type ::= 'SMALLINT'
int_data_type ::= 'INTEGER' | 'INT'
big_int_data_type ::= 'BIGINT'
fixed_point_data_type ::= { 'NUMERIC' | 'DECIMAL' | 'DEC' } [ LP precision [ COMMA scale ] RP ]
approximate_numeric_data_type ::= 'FLOAT' [ LP precision RP ] | 'REAL' | ( 'DOUBLE' 'PRECISION' ) | 'DOUBLE'
precision ::= digit
scale ::= digit
boolean_data_type ::= 'BOOLEAN'
character_string_data_type ::= { ('CHARACTER' 'VARYING') | ('CHAR' 'VARYING') | 'VARCHAR' } LP digit RP | character_large_object_data_type | { 'CHARACTER' | 'CHAR' | 'LONGVARCHAR' } [ LP digit RP ]
character_large_object_data_type ::= { ('CHARACTER' 'LARGE' 'OBJECT') | ('CHAR' 'LARGE' 'OBJECT') | 'CLOB' } [ LP character_large_object_length RP ]
character_large_object_length ::= digit [ multiplier ] [ char_length_units ]
multiplier ::= 'K' | 'M' | 'G'
char_length_units ::= 'CHARACTERS' | 'OCTETS'
binary_string_data_type ::= { ('BINARY' 'VARYING') | 'VARBINARY' } LP digit RP | binary_large_object_string_data_type | { 'BINARY' | 'LONGVARBINARY' } [ LP digit RP ] | 'UUID'
binary_large_object_string_data_type ::= { ('BINARY' 'LARGE' 'OBJECT') | 'BLOB' } [ LP digit RP ]
bit_string_data_type ::= ('BIT' 'VARYING') LP digit RP | 'BIT' [ LP digit RP ]
date_data_type ::= 'DATE' | ( 'TIME' | 'TIMESTAMP' ) [ LP digit RP ] [ ( WITH | WITHOUT ) 'TIME' 'ZONE' ]
interval_data_type ::= 'INTERVAL' interval_qualifier
interval_qualifier ::= start_field TO end_field | single_datetime_field
start_field ::= non_second_primary_datetime_field [ LP digit RP ]
end_field ::= non_second_primary_datetime_field | 'SECOND' [ LP digit RP ]
single_datetime_field ::= non_second_primary_datetime_field [ LP digit RP ] | 'SECOND' [ LP digit [ COMMA digit ] RP ]
non_second_primary_datetime_field ::= 'YEAR' | 'MONTH' | 'DAY' | 'HOUR' | 'MINUTE'
generated_clause ::= GENERATED ( ( (ALWAYS | BY DEFAULT) AS 'IDENTITY' ) | (ALWAYS AS <<expr '-1'>>) ) {
extends = "com.alecstrong.sql.psi.core.psi.impl.SqlGeneratedClauseImpl"
implements = "com.alecstrong.sql.psi.core.psi.SqlGeneratedClause"
override = true
}
insert_stmt ::= [ {with_clause} ] ( INSERT | MERGE ) INTO [ {database_name} DOT ] {table_name} [ AS {table_alias} ] [ LP {column_name} ( COMMA {column_name} ) * RP ] [ merge_key_selector ] {insert_stmt_values} {
extends = "com.alecstrong.sql.psi.core.psi.impl.SqlInsertStmtImpl"
implements = "com.alecstrong.sql.psi.core.psi.SqlInsertStmt"
override = true
pin = 5
}
merge_key_selector ::= KEY LP {column_name} RP
result_column ::= ( MULTIPLY
| {table_name} DOT MULTIPLY
| (window_function_invocation | <<expr '-1'>>) [ [ AS ] {column_alias} ] ) {
mixin = "app.cash.sqldelight.dialects.hsql.grammar.mixins.ResultColumnMixin"
implements = "com.alecstrong.sql.psi.core.psi.SqlResultColumn"
override = true
}
window_function_invocation ::=
window_func LP [ MULTIPLY | ( <<expr '-1'>> ( COMMA <<expr '-1'>> ) * ) ] RP [ 'FILTER' LP WHERE <<expr '-1'>> RP] 'OVER' ( window_defn | window_name) {
pin = 6
}
window_defn ::= LP [ base_window_name ]
[ PARTITION BY <<expr '-1'>> ( COMMA <<expr '-1'>> ) * ]
[ ORDER BY {ordering_term} ( COMMA {ordering_term} ) * ]
[ frame_spec ]
RP {
pin = 1
mixin = "app.cash.sqldelight.dialects.hsql.grammar.mixins.WindowDefinitionMixin"
}
frame_spec ::= ( 'RANGE' | 'ROWS' | 'GROUPS' )
(
BETWEEN (
'UNBOUNDED' 'PRECEDING' |
'CURRENT' ROW |
<<expr '-1'>> 'PRECEDING' |
<<expr '-1'>> 'FOLLOWING'
) AND (
'UNBOUNDED' 'FOLLOWING' |
'CURRENT' ROW |
<<expr '-1'>> 'PRECEDING' |
<<expr '-1'>> 'FOLLOWING'
) |
'UNBOUNDED' 'PRECEDING' |
'CURRENT' ROW |
<<expr '-1'>> 'PRECEDING'
) [ 'EXCLUDE' NO 'OTHERS' | 'EXCLUDE' 'CURRENT' ROW | 'EXCLUDE' GROUP | 'EXCLUDE' 'TIES' ] {
pin = 1
}
window_func ::= id
window_name ::= id
base_window_name ::= id