-
Notifications
You must be signed in to change notification settings - Fork 496
/
sqldelight.bnf
101 lines (97 loc) · 4.21 KB
/
sqldelight.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
/*
* Copyright (C) 2017 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
elementTypeHolderClass="app.cash.sqldelight.core.SqlDelightTypes"
psiPackage = "app.cash.sqldelight.core.psi"
psiImplPackage = "app.cash.sqldelight.core.psi.impl"
overrides="com.alecstrong.sql.psi.core.SqlParser"
elementTypeClass = "com.alecstrong.sql.psi.core.SqlElementType"
psiClassPrefix = "SqlDelight"
parserImports=[
// If you want to use a token from the core grammar it must be statically imported.
"static com.alecstrong.sql.psi.core.psi.SqlTypes.DEFAULT"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.AS"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.LOCK"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.VALUE"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.VALUES"
"static com.alecstrong.sql.psi.core.psi.SqlTypes.JAVADOC"
]
}
overrides ::= column_type | stmt_list | insert_stmt_values
stmt_list ::= import_stmt_list ( ( stmt_identifier {stmt} ';' ) | stmt_clojure ) * {
implements="com.alecstrong.sql.psi.core.psi.SqlStmtList"
extends="com.alecstrong.sql.psi.core.psi.impl.SqlStmtListImpl"
pin(".*")=2
override = true
}
stmt_clojure ::= stmt_identifier_clojure stmt_clojure_stmt_list '}' {
implements="com.alecstrong.sql.psi.core.psi.SqlCompositeElement"
extends="com.alecstrong.sql.psi.core.psi.SqlCompositeElementImpl"
pin = 1
}
stmt_clojure_stmt_list ::= {stmt} ';' ( {stmt} ';' ) * {
implements="com.alecstrong.sql.psi.core.psi.SqlCompositeElement"
extends="app.cash.sqldelight.core.lang.psi.ClojureStmtListMixin"
pin(".*") = 1
}
column_type ::= {type_name} [ AS ( VALUE | LOCK | ('@' annotation) * java_type_name ) ] {
implements=[
"com.alecstrong.sql.psi.core.psi.SqlColumnType";
"app.cash.sqldelight.core.lang.psi.TypedColumn"
]
extends="app.cash.sqldelight.core.lang.psi.ColumnTypeMixin"
override = true
}
insert_stmt_values ::= ( VALUES ( {bind_expr} | {values_expression}
( ',' {values_expression} ) * ) | {compound_select_stmt} | DEFAULT VALUES ) {
implements="com.alecstrong.sql.psi.core.psi.SqlInsertStmtValues"
extends="app.cash.sqldelight.core.lang.psi.InsertStmtValuesMixin"
override = true
}
// New rules.
import_stmt ::= 'import' java_type ';' {
extends="app.cash.sqldelight.core.lang.psi.ImportStmtMixin"
implements="com.alecstrong.sql.psi.core.psi.SqlCompositeElement"
}
import_stmt_list ::= import_stmt * {
extends="com.alecstrong.sql.psi.core.psi.SqlCompositeElementImpl"
implements="com.alecstrong.sql.psi.core.psi.SqlCompositeElement"
}
stmt_identifier ::= [ JAVADOC ] [ {identifier} ':' ] {
extends="app.cash.sqldelight.core.lang.psi.StmtIdentifierMixin"
implements="app.cash.sqldelight.core.lang.psi.StmtIdentifier"
pin(".*") = 2
}
stmt_identifier_clojure ::= [ JAVADOC ] {identifier} '{' {
extends="app.cash.sqldelight.core.lang.psi.StmtIdentifierMixin"
implements="app.cash.sqldelight.core.psi.SqlDelightStmtIdentifier"
pin = 3
}
annotation ::= java_type ( '(' annotation_value ')'
| '(' {identifier} '=' annotation_value ( ',' {identifier} '=' annotation_value )* ')'
)?
annotation_value ::= java_type_name '::class'
| {string_literal}
| {numeric_literal}
| '[' annotation_value ( ',' annotation_value ) * ']'
| annotation
java_type_name ::= parameterized_java_type
parameterized_java_type ::= java_type ( ( '<' java_type_name ( ',' java_type_name )* '>' )
| ( '<' ( java_type_name ',' )* java_type '<' java_type_name2 ( ',' java_type_name2 )* '>>' ) )?
java_type_name2 ::= java_type
java_type ::= ( {identifier} '.' )* {identifier} {
mixin="app.cash.sqldelight.core.lang.psi.JavaTypeMixin"
}