This repository has been archived by the owner on Feb 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EZQL.g4
148 lines (124 loc) · 4.7 KB
/
EZQL.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
141
142
143
144
145
146
147
148
grammar EZQL;
stmt:
selectLocation|selectContent|selectContentInfo;
selectLocation:
K_SELECT K_LOCATION properties=selectProperties;
selectContent:
K_SELECT K_CONTENT properties=selectProperties;
selectContentInfo:
K_SELECT K_CONTENT K_INFO properties=selectProperties;
selectProperties:
(K_FILTER K_BY filter=expr)?
(K_QUERY query=expr)?
(K_ORDER K_BY sortClauses=sortClauseList)?
(K_LIMIT limit=argument)?
(K_OFFSET offset=argument)?
;
sortClauseList:
sortClause (',' sortClause)*;
sortClause:
name=ID sortOrder;
sortOrder:
order=(K_ASC|K_DESC);
expr:
K_MATCH K_ALL #matchAllExpr
| K_MATCH K_NONE #matchNoneExpr
| K_IS K_MAIN K_LOCATION #isMainLocationExpr
| K_IS K_NOT K_MAIN K_LOCATION #isNotMainLocationExpr
| K_IS flag=(K_VISIBLE|K_HIDDEN) #visibilityExpr
| K_FIELD field=ID K_IS K_EMPTY #isFieldEmptyExpr
| K_FIELD field=ID K_IS K_NOT K_EMPTY #isNotFieldEmptyExpr
| K_FIELD field=ID op=operator val=value #fieldExpr
| K_FIELD K_RELATION field=ID op=operator val=value #fieldRelationExpr
| K_LOCATION K_PRIORITY op=operator val=value #locationPriorityExpr
| K_CREATED op=operator val=value #createdExpr
| K_MODIFIED op=operator val=value #modifiedExpr
| K_FULLTEXT val=value fuzziness? boosting? #fulltextExpr
| target=userMetadataTarget op=operator val=value #userMetadataExpr
| clazz=ID op=operator val=value #criterionExpr
| left=expr K_AND right=expr #andExpr
| left=expr K_OR right=expr #orExpr
| '(' expr ')' #innerExpr
;
operator:
op=(EQ|K_IN|GT|LT|GTE|LTE|K_LIKE|K_BETWEEN|K_CONTAINS) #buildInOperator
| K_NOT K_IN #notInOperator
| NEQ #notEQ
;
fuzziness:
K_FUZZINESS val=value;
boosting:
K_BOOST fieldBoost (',' fieldBoost)*;
fieldBoost:
field=ID '^' val=value;
value:
argument|argumentList|argumentRange;
argumentRange:
a=argument '..' b=argument;
argumentList:
'(' argument (',' argument)* ')';
argument:
parameter | scalar;
parameter:
name=PARAMETER_NAME;
scalar:
val=INT #int
| val=(K_TRUE|K_FALSE) #boolean
| val=STRING #string
| val=DOUBLE #double
;
userMetadataTarget:
target=(K_OWNER|K_GROUP|K_MODIFIER);
K_ALL: [Aa][Ll][Ll];
K_AND: [Aa][Nn][Dd];
K_ASC: [Aa][Ss][Cc];
K_BETWEEN: [Bb][Ee][Tt][Ww][Ee][Ee][Nn];
K_BOOST: [Bb][Oo][Oo][Ss][Tt];
K_BY: [Bb][Yy];
K_CONTAINS: [Cc][Oo][Nn][Tt][Aa][Ii][Nn][Ss];
K_CONTENT: [Cc][Oo][Nn][Tt][Ee][Nn][Tt];
K_CREATED: [Cc][Rr][Ee][Aa][Tt][Ee][Dd];
K_DESC: [Dd][Ee][Ss][Cc];
K_EMPTY: [Ee][Mm][Pp][Tt][Yy];
K_FALSE: [Ff][Aa][Ll][Ss][Ee];
K_FULLTEXT: [Ff][Uu][Ll][Ll][Tt][Ee][Xx][Tt];
K_FUZZINESS: [Ff][Uu][Zz][Zz][Ii][Nn][Ee][Ss][Ss];
K_FIELD: [Ff][Ii][Ee][Ll][Dd];
K_FILTER: [Ff][Ii][Ll][Tt][Ee][Rr];
K_GROUP: [Gg][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