-
Notifications
You must be signed in to change notification settings - Fork 14
/
soql.g4
140 lines (63 loc) · 1.94 KB
/
soql.g4
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
grammar soql;
querySentence : selectStatement whereClausuleWrapper? groupByClausule? orderByClausule? ;
selectStatement: typeDef params FROM tables ;
typeDef: SELECT ;
params: paramComma* distinctParam ;
paramComma: distinctParam COMMA ;
distinctParam: distinct? selectedParam ;
selectedParam: param | count;
count: COUNT LEFTPAREN param RIGHTPAREN ;
param: objWithAttr | objWithOutAttr ;
objWithAttr: object DOT attribute;
objWithOutAttr: object ;
distinct: DISTINCT ;
object: TEXT ;
attribute: TEXT ;
joinedParams: object DOT attribute (DOT attribute)+ ;
tables: tableWithName ;
table: TEXT ;
tableName: TEXT ;
tableWithName: table tableName ;
logOp: AND | OR ;
whereClausuleWrapper: WHERE whereClausules ;
whereClausules: whereClausuleOps whereClausuleOps* ;
whereClausuleOps: logOp? NOT? whereClausule ;
whereClausule: whereClausuleParam QUERYOPERATOR whereClausuleValue;
whereClausuleValue: (QMARK TEXT QMARK) | COLONTEXT ;
whereClausuleParam: param | joinedParams ;
orderByClausule: ORDERBY orderByFullFormComma orderByFullFormComma* ;
orderByFullFormComma: orderByFullForm COMMA? ;
orderByFullForm: orderByParam ORDERING? ;
orderByParam: object DOT attribute (DOT attribute)* ;
groupByClausule: GROUPBY groupByParamComma groupByParamComma* ;
groupByParamComma: groupByParam COMMA? ;
groupByParam: object DOT attribute (DOT attribute)* ;
SELECT: 'SELECT' ;
WHERE: 'WHERE' ;
NOT: 'NOT' ;
FROM: 'FROM' ;
JOIN: 'JOIN' ;
AND: 'AND' ;
OR: 'OR' ;
ORDERBY: 'ORDER BY' ;
ORDERING: ASC | DESC ;
GROUPBY: 'GROUP BY' ;
ASC: 'ASC' ;
DESC: 'DESC' ;
DISTINCT: 'DISTINCT' ;
COUNT: 'COUNT' ;
QUERYOPERATOR: '>' | '<' | '>=' | '<=' | '=' | 'LIKE';
DOT: '.' ;
COMMA: ',' ;
QMARK: '"' ;
COLON: ':' ;
RIGHTPAREN: ')' ;
LEFTPAREN: '(' ;
TEXT: (LOWERCASE | UPPERCASE | DIGIT)+ ;
COLONTEXT: COLON TEXT ;
UPPERCASE: ('A'..'Z');
LOWERCASE: ('a'..'z');
DIGIT: ('0'..'9');
NUMBER: DIGIT+ ;
VALUE: NUMBER ;
WHITESPACE: (' ')+ -> skip;