-
Notifications
You must be signed in to change notification settings - Fork 496
/
hsql.bnf
160 lines (143 loc) · 6.44 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
{
// 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.CONSTRAINT"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.PRIMARY"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.KEY"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.ASC"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.DESC"
"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.MERGE"
"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.UNIQUE"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.COLLATE"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.DIGIT"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.TO"
"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} ) {
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' } [ '(' precision [ ',' scale ] ')' ]
approximate_numeric_data_type ::= 'FLOAT' [ '(' precision ')' ] | 'REAL' | ( 'DOUBLE' 'PRECISION' ) | 'DOUBLE'
precision ::= digit
scale ::= digit
boolean_data_type ::= 'BOOLEAN'
character_string_data_type ::= { ('CHARACTER' 'VARYING') | ('CHAR' 'VARYING') | 'VARCHAR' } '(' digit ')' | character_large_object_data_type | { 'CHARACTER' | 'CHAR' | 'LONGVARCHAR' } [ '(' digit ')' ]
character_large_object_data_type ::= { ('CHARACTER' 'LARGE' 'OBJECT') | ('CHAR' 'LARGE' 'OBJECT') | 'CLOB' } [ '(' character_large_object_length ')' ]
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' } '(' digit ')' | binary_large_object_string_data_type | { 'BINARY' | 'LONGVARBINARY' } [ '(' digit ')' ] | 'UUID'
binary_large_object_string_data_type ::= { ('BINARY' 'LARGE' 'OBJECT') | 'BLOB' } [ '(' digit ')' ]
bit_string_data_type ::= ('BIT' 'VARYING') '(' digit ')' | 'BIT' [ '(' digit ')' ]
date_data_type ::= 'DATE' | ( 'TIME' | 'TIMESTAMP' ) [ '(' digit ')' ] [ ( 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 [ '(' digit ')' ]
end_field ::= non_second_primary_datetime_field | 'SECOND' [ '(' digit ')' ]
single_datetime_field ::= non_second_primary_datetime_field [ '(' digit ')' ] | 'SECOND' [ '(' digit [ ',' digit ] ')' ]
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} '.' ] {table_name} [ AS {table_alias} ] [ '(' {column_name} ( ',' {column_name} ) * ')' ] [ 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 '(' {column_name} ')'
result_column ::= ( '*'
| {table_name} '.' '*'
| (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 '(' [ '*' | ( <<expr '-1'>> ( ',' <<expr '-1'>> ) * ) ] ')' [ 'FILTER' '(' 'WHERE' <<expr '-1'>> ')'] 'OVER' ( window_defn | window_name) {
pin = 6
}
window_defn ::= '(' [ base_window_name ]
[ 'PARTITION' 'BY' <<expr '-1'>> ( ',' <<expr '-1'>> ) * ]
[ 'ORDER' 'BY' {ordering_term} ( ',' {ordering_term} ) * ]
[ frame_spec ]
')' {
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