Datei: NDODLL/NDOql/NDOql.ATG

Last Commit (ca02e8b)
1 using System.Collections.Generic;
2 using System.Text;
3 using System.Globalization;
4 using NDOql.Expressions;
5
6 COMPILER NDOQL
7
8
9 OqlExpression rootExpression;
10 public OqlExpression RootExpression
11 {
12 ····get { return rootExpression; }
13 }
14
15
16
17 /*------------------------------------------------------------------------*
18 *----- SCANNER DESCRIPTION ----------------------------------------------*
19 *------------------------------------------------------------------------*/
20
21 IGNORECASE
22
23 CHARACTERS
24
25 ····tab················= '\u0009'. /*··9 = tabulator */
26 ····eol················= '\u000a'. /* 10 = line feed */
27 ····cr················ = '\u000d'. /* 13 = carriage return */
28 ····newLine············= cr + eol. /* Line separator character (U+2028) + Paragraph separator character (U+2029) */
29
30 ····/* see https://msdn.microsoft.com/de-de/library/aa664670(v=vs.71).aspx
31 ······ and implementation in http://www.ssw.uni-linz.ac.at/Coco/CS/CSharp3.atg */
32
33 ····startletter········= 'A' .. 'Z' + 'a' .. 'z' + '_' + '\u00aa' + '\u00b5' + '\u00ba' + '\u00c0' .. '\u00d6' + '\u00d8' .. '\u00f6' + '\u00f8' .. '\u00ff'.
34 ····partletter········ = '.' + '0' .. '9' + 'A' .. 'Z' + 'a' .. 'z' + '_' + '\u0080' + '\u00a0' .. '\u00b3' + '\u00b5' + '\u00ba' + '\u00c0' .. '\u00d6' + '\u00d8' .. '\u00f6' + '\u00f8' .. '\u00ff'.
35
36 ····digit··············= "0123456789".
37 ····hexDigit·········· = digit + "ABCDEFabcdef".
38 ····notDigit·········· = ANY - digit.
39
40 ····regularStringChar··= ANY - "'" - newLine.
41 ····notNewLine········ = ANY - newLine .
42 ····ws················ = " " + tab + '\u000b' + '\u000c'. /* Any character with Unicode class Zs */
43
44
45 TOKENS
46
47 ··/* This definition is not exact, as it allows '_.x' or 'x..y' as valid identifiers. But we couldn't get a mapping to that kind of wrong identifiers anyway. */
48 ····ident = startletter { partletter }.····
49
50 ··/*--------------------------------------------------------------------------------*/
51 ····realCon =
52 ····['-'] [digit {digit}] "." digit {digit}
53 ············[("e" | "E" ) ["+" | "-"] digit {digit} ] ····················
54 ········.
55
56 ··/*--------------------------------------------------------------------------------*/
57 ····intCon =
58 ········['-'] (digit {digit} | digit {digit} )
59 ········.
60
61 ··/*--------------------------------------------------------------------------------*/
62 ····stringCon = "'"····{ regularStringChar } "'".
63
64
65 ····/*----- keyword names needed in LL(1) resolvers -----*/
66 ····AND······= "AND".
67 ····OR······ = "OR".
68 ····NOT······= "NOT".
69 ····LIKE···· = "LIKE".
70 ····ESCAPE·· = "ESCAPE".
71 ····BETWEEN··= "BETWEEN".
72 ····IS······ = "IS".
73 ····NULL···· = "NULL".
74 ····TRUE······= "TRUE".
75 ····MOD···· = "MOD".
76 ····IN···· = "IN".
77
78
79 ····parameter =··"{" digit "}".
80
81
82
83 COMMENTS FROM "--" TO eol
84
85 IGNORE eol + cr + tab
86
87 PRODUCTIONS
88
89 /*------------------------------------------------------------------------*
90 *--------------------------- Declarations -------------------------------*
91 *------------------------------------------------------------------------*/
92
93 NDOQL = RootExpr<out this.rootExpression> .
94
95 /*------------------------------------------------------------------------*/
96
97 RootExpr<out OqlExpression expression>
98 ····(.··OqlExpression child;
99 ········OqlExpression result = new OqlExpression(la.line, la.col);
100 ········bool negated = false;
101 ····.)
102 = ····[NOT (.negated = true; .)] OrExpr<out child>
103 (.
104 ····if (negated) result.UnaryOp = "NOT";
105 ····result.Add(child);
106 ····expression = result.Simplify();
107 .)
108 .
109
110 /*------------------------------------------------------------------------*/
111 OrExpr <out OqlExpression expression>··
112 ····(.
113 ········OqlExpression child;
114 ········OqlExpression result = new OqlExpression(la.line, la.col);
115 ····.)
116
117 = AndExpr ············<out child> (. result.Add(child); .)
118 ··{ "OR" (. bool negated = false; .) [NOT (. negated = true; .)]
119 ··AndExpr<out child> (. if (negated) child.UnaryOp = "NOT"; result.Add(child, "OR"); .)
120 ··}
121
122 (. expression = result.Simplify(); .)
123 .
124
125
126 /*------------------------------------------------------------------------*/
127 AndExpr<out OqlExpression expression>··
128 ····(.
129 ········OqlExpression child;
130 ········OqlExpression result = new OqlExpression(la.line, la.col);
131 ····.)
132 = EqlExpr<out child> (. result.Add(child); .) {
133 ················································"AND" (. bool negated = false; .) [NOT (. negated = true; .)]
134 ················································EqlExpr<out child> (. if (negated) child.UnaryOp = "NOT"; result.Add(child, "AND"); .)
135 ··············································}
136 (. expression = result.Simplify(); .)
137 .
138
139
140 /*------------------------------------------------------------------------*/
141 EqlExpr<out OqlExpression expression>
142 ····(.
143 ········OqlExpression child;
144 ········OqlExpression result = new OqlExpression(la.line, la.col);
145 ········string newOp = null;
146 ········bool negated = false;
147 ····.)
148 ····
149 = (
150 ····IF(!(scanner.Peek().kind==_IN))
151 ····RelExpr<out child> (. result.Add(child); .)
152 ····{
153 ········(
154 ············"!=" (. newOp = "<>"; .)
155 ············| "<>" (. newOp = "<>"; .)
156 ············| "=" (. newOp = "="; .) [NOT (. negated = true; .)]
157 ············| "LIKE" (. newOp = "LIKE"; .) /*[ESCAPE stringCon]*/
158 ········)
159 ········RelExpr<out child> (. if (negated) child.UnaryOp = "NOT"; result.Add(child, newOp); .)
160 ····}
161 ····|
162 ····Identifier <out child> (. result.Add(child); .)
163 ········IN "("
164 ········(
165 ············NumList <out child> (. child.HasBrackets = true; result.Add(child, "IN"); .)
166 ············| StringList <out child> (. child.HasBrackets = true; result.Add(child, "IN"); .)
167 ········)
168 ········")"
169 ·· )
170 (. expression = result.Simplify(); .)
171 .
172
173 /*------------------------------------------------------------------------*/
174 RelExpr <out OqlExpression expression>
175 ····(.
176 ········OqlExpression child;
177 ········OqlExpression result = new OqlExpression(la.line, la.col);
178 ········string newOp = null;
179 ········bool negated = false;
180 ····.)
181 = BitOrExpr<out child> (. result.Add(child); .)
182 ··[
183 ····(
184 ········"<" (. newOp = "<"; .)
185 ········| ">" (. newOp = ">"; .)
186 ········| "<=" (. newOp = "<="; .)
187 ········| ">=" (. newOp = ">="; .)
188 ········| "!<" (. newOp = ">="; .)
189 ········| "!>" (. newOp = "<="; .)
190 ····) BitOrExpr <out child> (. result.Add(child, newOp); .)
191 ····| IS [NOT (. negated = true; .)] NULL (. result.Add(new NamedConstantExpression("NULL", negated, t.line, t.col), "IS"); .)
192 ····| [NOT (. negated = true; .)] BETWEEN BitOrExpr <out child> (. result.Add(child, "BETWEEN"); .)
193 ································AND BitOrExpr <out child> (. result.Add(child, "BETWEEN"); .)
194 ··]
195 (. expression = result.Simplify(); .)
196 .
197
198 /*------------------------------------------------------------------------*/
199 BitOrExpr<out OqlExpression expression>
200 ····(.
201 ········OqlExpression child;
202 ········OqlExpression result = new OqlExpression(la.line, la.col);
203 ····.)
204 = BitXorExpr <out child> (. result.Add(child); .)
205 ··{"|" BitXorExpr <out child> (. result.Add(child, "|"); .) }
206 (. expression = result.Simplify(); .)
207 .
208
209
210 /*------------------------------------------------------------------------*/
211 BitXorExpr<out OqlExpression expression>
212 ····(.
213 ········OqlExpression child;
214 ········OqlExpression result = new OqlExpression(la.line, la.col);
215 ····.)
216 = BitAndExpr <out child> (. result.Add(child); .)
217 ··{"^" BitAndExpr <out child> (. result.Add(child, "^"); .) }
218 (. expression = result.Simplify(); .)
219 .
220
221
222 /*------------------------------------------------------------------------*/
223 BitAndExpr<out OqlExpression expression>
224 ····(.
225 ········OqlExpression child;
226 ········OqlExpression result = new OqlExpression(la.line, la.col);
227 ····.)
228 = AddExpr <out child> (. result.Add(child); .)
229 ··{"&" AddExpr <out child> (. result.Add(child, "&"); .) }
230 (. expression = result.Simplify(); .)
231 .
232
233
234 /*------------------------------------------------------------------------*/
235 AddExpr<out OqlExpression expression>
236 ····(.
237 ········OqlExpression child;
238 ········OqlExpression result = new OqlExpression(la.line, la.col);
239 ········string newOp = null;
240 ····.)
241 = MulExpr<out child> (. result.Add(child); .)
242 ····{
243 ········(
244 ············"+" (. newOp = "+"; .)
245 ············| "-" (. newOp = "-"; .)
246 ········)
247 ········MulExpr<out child> (. result.Add(child, newOp); .)
248 ····}
249 (. expression = result.Simplify(); .)
250 .
251
252 /*------------------------------------------------------------------------*/
253 MulExpr<out OqlExpression expression>
254 ····(.
255 ········OqlExpression child;
256 ········OqlExpression result = new OqlExpression(la.line, la.col);
257 ········string newOp = null;
258 ····.)
259 = Unary<out child> (. result.Add(child); .)
260 ····{
261 ········(
262 ············"*" (. newOp = "*"; .)
263 ············| "/" (. newOp = "/"; .)
264 ············| "%" (. newOp = "%"; .)
265 ············| "MOD" (. newOp = "MOD"; .)
266 ········)
267 ········Unary<out child> (. result.Add(child, newOp); .)
268 ····}
269 (. expression = result.Simplify(); .)
270 .
271
272 /*------------------------------------------------------------------------*/
273 Unary <out OqlExpression expression>
274 ····(.
275 ········OqlExpression child;
276 ········OqlExpression result = new OqlExpression(la.line, la.col);
277 ········string newOp = null;
278 ····.)
279
280 = [······"+" (. newOp = "+"; .)
281 ····| "-" (. newOp = "-"; .)
282 ····| "~" (. newOp = "~"; .)
283 ··]·· Primary<out child> (. result.Add(child); child.UnaryOp = newOp; .)
284 (. expression = result.Simplify(); .)··
285 .
286 /*------------------------------------------------------------------------*/
287 Primary <out OqlExpression expression>
288 ····(.
289 ········OqlExpression result = null;
290 ········OqlExpression child;
291 ····.)
292 =··
293 ··(
294 ······ident (. result = new IdentifierExpression(t.val, t.line, t.col); .)
295 ············[
296 ················IF(IsOidIdentifier(result))
297 ················"(" intCon
298 ····················(.
299 ····················result.UnaryOp="";
300 ····················result.Add(new IndexExpression(int.Parse(t.val), t.line, t.col));
301 ····················.)
302 ················")"
303 ················|
304 ················"("
305 ····················ParameterList <out child>
306 ····················(.
307 ························result = new FunctionExpression(result.Value, t.line, t.col);
308 ························result.UnaryOp="";························
309 ························result.Add(child);
310 ····················.)
311 ················")"
312 ············]
313 ······| Literal <out result>
314 ······| parameter (. result = new ParameterExpression(t.val, t.line, t.col); .)
315 ······| "(" RootExpr <out result> (. result.HasBrackets = true; .) ")"
316 ··)
317 (. expression = result.Simplify(); .)··
318 .
319
320 Identifier <out OqlExpression expression>
321 ····(.
322 ········OqlExpression result = null;
323 ····.)
324 =··
325 ····ident (. result = new IdentifierExpression(t.val, t.line, t.col); .)
326 (. expression = result.Simplify(); .)··
327 .
328
329 NumList <out OqlExpression expression>
330 ····(. ········
331 ········OqlExpression result = new OqlExpression(la.line, la.col);
332 ····.)
333 =
334 ····(
335 ········realCon (. result.Add(new NumberExpression(double.Parse(t.val, CultureInfo.InvariantCulture ), t.line, t.col)); .)
336 ········| intCon (. result.Add(new NumberExpression(int.Parse(t.val), t.line, t.col)); .)
337 ····)
338 {
339 ····","
340 ····(
341 ········realCon (. result.Add(new NumberExpression(double.Parse(t.val, CultureInfo.InvariantCulture ), t.line, t.col), ","); .)
342 ········| intCon (. result.Add(new NumberExpression(int.Parse(t.val), t.line, t.col), ","); .)
343 ····)
344 }
345 (. expression = result.Simplify(); .)
346 .
347
348 StringList <out OqlExpression expression>
349 ····(.
350 ········OqlExpression result = new OqlExpression(la.line, la.col);
351 ····.)
352 =
353 ····stringCon (. result.Add(new StringLiteralExpression(t.val, t.line, t.col)); .)
354 ····{
355 ········","
356 ········stringCon (. result.Add(new StringLiteralExpression(t.val, t.line, t.col), ","); .)
357 ····}
358 (. expression = result; /* Do not simplify here, because otherwise the brackets are missing */ .)
359 .
360
361 ParameterList <out OqlExpression expression>
362 ····(.
363 ········OqlExpression result = new ParameterListExpression(la.line, la.col);
364 ········OqlExpression child;
365 ····.)
366 =
367 ····[
368 ········Primary <out child> (. result.Add(child); .)
369 ········{
370 ············","
371 ············Primary <out child> (. result.Add(child, ","); .)
372 ········}
373 ····]
374 (. expression = result; /* Do not simplify here, because otherwise the brackets are missing */ .)
375 .
376
377
378
379 /*------------------------------------------------------------------------*/
380 Literal <out OqlExpression expression>
381 ····(.
382 ········OqlExpression result = null;
383 ····.)
384 =
385 (
386 ···· realCon (. result = new NumberExpression(double.Parse(t.val, CultureInfo.InvariantCulture ), t.line, t.col); .)
387 ····| intCon (. result = new NumberExpression(int.Parse(t.val), t.line, t.col); .)
388 ····| stringCon (. result = new StringLiteralExpression(t.val, t.line, t.col); .)
389 ····| "TRUE" (. result = new NamedConstantExpression("TRUE", t.line, t.col); .)
390 ····| "FALSE" (. result = new NamedConstantExpression("FALSE", t.line, t.col); .)
391 ····| "NULL" (. result = new NamedConstantExpression("NULL", t.line, t.col); .)
392 )
393 (. expression = result.Simplify(); .)··
394 .
395
396 END NDOQL.
397
New Commit (f96ae8c)
1 using System.Collections.Generic;
2 using System.Text;
3 using System.Globalization;
4 using NDOql.Expressions;
5
6 COMPILER NDOQL
7
8
9 OqlExpression rootExpression;
10 public OqlExpression RootExpression
11 {
12 ····get { return rootExpression; }
13 }
14
15
16
17 /*------------------------------------------------------------------------*
18 *----- SCANNER DESCRIPTION ----------------------------------------------*
19 *------------------------------------------------------------------------*/
20
21 IGNORECASE
22
23 CHARACTERS
24
25 ····tab················= '\u0009'. /*··9 = tabulator */
26 ····eol················= '\u000a'. /* 10 = line feed */
27 ····cr················ = '\u000d'. /* 13 = carriage return */
28 ····newLine············= cr + eol. /* Line separator character (U+2028) + Paragraph separator character (U+2029) */
29
 
 
 
30 ····startletter········= 'A' .. 'Z' + 'a' .. 'z' + '_' + '\u00aa' + '\u00b5' + '\u00ba' + '\u00c0' .. '\u00d6' + '\u00d8' .. '\u00f6' + '\u00f8' .. '\u00ff'.
31 ····partletter········ = '.' + '0' .. '9' + 'A' .. 'Z' + 'a' .. 'z' + '_' + '\u0080' + '\u00a0' .. '\u00b3' + '\u00b5' + '\u00ba' + '\u00c0' .. '\u00d6' + '\u00d8' .. '\u00f6' + '\u00f8' .. '\u00ff'.
32
33 ····digit··············= "0123456789".
34 ····hexDigit·········· = digit + "ABCDEFabcdef".
35 ····notDigit·········· = ANY - digit.
36
37 ····regularStringChar··= ANY - "'" - newLine.
38 ····notNewLine········ = ANY - newLine .
39 ····ws················ = " " + tab + '\u000b' + '\u000c'. /* Any character with Unicode class Zs */
40
41
42 TOKENS
43
44 ··/* This definition is not exact, as it allows '_.x' or 'x..y' as valid identifiers. But we couldn't get a mapping to that kind of wrong identifiers anyway. */
45 ····ident = startletter { partletter }.····
46
47 ··/*--------------------------------------------------------------------------------*/
48 ····realCon =
49 ····['-'] [digit {digit}] "." digit {digit}
50 ············[("e" | "E" ) ["+" | "-"] digit {digit} ] ····················
51 ········.
52
53 ··/*--------------------------------------------------------------------------------*/
54 ····intCon =
55 ········['-'] (digit {digit} | digit {digit} )
56 ········.
57
58 ··/*--------------------------------------------------------------------------------*/
59 ····stringCon = "'"····{ regularStringChar } "'".
60
61
62 ····/*----- keyword names needed in LL(1) resolvers -----*/
63 ····AND······= "AND".
64 ····OR······ = "OR".
65 ····NOT······= "NOT".
66 ····LIKE···· = "LIKE".
67 ····ESCAPE·· = "ESCAPE".
68 ····BETWEEN··= "BETWEEN".
69 ····IS······ = "IS".
70 ····NULL···· = "NULL".
71 ····TRUE······= "TRUE".
72 ····MOD···· = "MOD".
73 ····IN···· = "IN".
74
75
76 ····parameter =··"{" digit "}".
77
78
79
80 COMMENTS FROM "--" TO eol
81
82 IGNORE eol + cr + tab
83
84 PRODUCTIONS
85
86 /*------------------------------------------------------------------------*
87 *--------------------------- Declarations -------------------------------*
88 *------------------------------------------------------------------------*/
89
90 NDOQL = RootExpr<out this.rootExpression> .
91
92 /*------------------------------------------------------------------------*/
93
94 RootExpr<out OqlExpression expression>
95 ····(.··OqlExpression child;
96 ········OqlExpression result = new OqlExpression(la.line, la.col);
97 ········bool negated = false;
98 ····.)
99 = ····[NOT (.negated = true; .)] OrExpr<out child>
100 (.
101 ····if (negated) result.UnaryOp = "NOT";
102 ····result.Add(child);
103 ····expression = result.Simplify();
104 .)
105 .
106
107 /*------------------------------------------------------------------------*/
108 OrExpr <out OqlExpression expression>··
109 ····(.
110 ········OqlExpression child;
111 ········OqlExpression result = new OqlExpression(la.line, la.col);
112 ····.)
113
114 = AndExpr ············<out child> (. result.Add(child); .)
115 ··{ "OR" (. bool negated = false; .) [NOT (. negated = true; .)]
116 ··AndExpr<out child> (. if (negated) child.UnaryOp = "NOT"; result.Add(child, "OR"); .)
117 ··}
118
119 (. expression = result.Simplify(); .)
120 .
121
122
123 /*------------------------------------------------------------------------*/
124 AndExpr<out OqlExpression expression>··
125 ····(.
126 ········OqlExpression child;
127 ········OqlExpression result = new OqlExpression(la.line, la.col);
128 ····.)
129 = EqlExpr<out child> (. result.Add(child); .) {
130 ················································"AND" (. bool negated = false; .) [NOT (. negated = true; .)]
131 ················································EqlExpr<out child> (. if (negated) child.UnaryOp = "NOT"; result.Add(child, "AND"); .)
132 ··············································}
133 (. expression = result.Simplify(); .)
134 .
135
136
137 /*------------------------------------------------------------------------*/
138 EqlExpr<out OqlExpression expression>
139 ····(.
140 ········OqlExpression child;
141 ········OqlExpression result = new OqlExpression(la.line, la.col);
142 ········string newOp = null;
143 ········bool negated = false;
144 ····.)
145 ····
146 = (
147 ····IF(!(scanner.Peek().kind==_IN))
148 ····RelExpr<out child> (. result.Add(child); .)
149 ····{
150 ········(
151 ············"!=" (. newOp = "<>"; .)
152 ············| "<>" (. newOp = "<>"; .)
153 ············| "=" (. newOp = "="; .) [NOT (. negated = true; .)]
154 ············| "LIKE" (. newOp = "LIKE"; .) /*[ESCAPE stringCon]*/
155 ········)
156 ········RelExpr<out child> (. if (negated) child.UnaryOp = "NOT"; result.Add(child, newOp); .)
157 ····}
158 ····|
159 ····Identifier <out child> (. result.Add(child); .)
160 ········IN "("
161 ········(
162 ············NumList <out child> (. child.HasBrackets = true; result.Add(child, "IN"); .)
163 ············| StringList <out child> (. child.HasBrackets = true; result.Add(child, "IN"); .)
164 ········)
165 ········")"
166 ·· )
167 (. expression = result.Simplify(); .)
168 .
169
170 /*------------------------------------------------------------------------*/
171 RelExpr <out OqlExpression expression>
172 ····(.
173 ········OqlExpression child;
174 ········OqlExpression result = new OqlExpression(la.line, la.col);
175 ········string newOp = null;
176 ········bool negated = false;
177 ····.)
178 = BitOrExpr<out child> (. result.Add(child); .)
179 ··[
180 ····(
181 ········"<" (. newOp = "<"; .)
182 ········| ">" (. newOp = ">"; .)
183 ········| "<=" (. newOp = "<="; .)
184 ········| ">=" (. newOp = ">="; .)
185 ········| "!<" (. newOp = ">="; .)
186 ········| "!>" (. newOp = "<="; .)
187 ····) BitOrExpr <out child> (. result.Add(child, newOp); .)
188 ····| IS [NOT (. negated = true; .)] NULL (. result.Add(new NamedConstantExpression("NULL", negated, t.line, t.col), "IS"); .)
189 ····| [NOT (. negated = true; .)] BETWEEN BitOrExpr <out child> (. result.Add(child, "BETWEEN"); .)
190 ································AND BitOrExpr <out child> (. result.Add(child, "BETWEEN"); .)
191 ··]
192 (. expression = result.Simplify(); .)
193 .
194
195 /*------------------------------------------------------------------------*/
196 BitOrExpr<out OqlExpression expression>
197 ····(.
198 ········OqlExpression child;
199 ········OqlExpression result = new OqlExpression(la.line, la.col);
200 ····.)
201 = BitXorExpr <out child> (. result.Add(child); .)
202 ··{"|" BitXorExpr <out child> (. result.Add(child, "|"); .) }
203 (. expression = result.Simplify(); .)
204 .
205
206
207 /*------------------------------------------------------------------------*/
208 BitXorExpr<out OqlExpression expression>
209 ····(.
210 ········OqlExpression child;
211 ········OqlExpression result = new OqlExpression(la.line, la.col);
212 ····.)
213 = BitAndExpr <out child> (. result.Add(child); .)
214 ··{"^" BitAndExpr <out child> (. result.Add(child, "^"); .) }
215 (. expression = result.Simplify(); .)
216 .
217
218
219 /*------------------------------------------------------------------------*/
220 BitAndExpr<out OqlExpression expression>
221 ····(.
222 ········OqlExpression child;
223 ········OqlExpression result = new OqlExpression(la.line, la.col);
224 ····.)
225 = AddExpr <out child> (. result.Add(child); .)
226 ··{"&" AddExpr <out child> (. result.Add(child, "&"); .) }
227 (. expression = result.Simplify(); .)
228 .
229
230
231 /*------------------------------------------------------------------------*/
232 AddExpr<out OqlExpression expression>
233 ····(.
234 ········OqlExpression child;
235 ········OqlExpression result = new OqlExpression(la.line, la.col);
236 ········string newOp = null;
237 ····.)
238 = MulExpr<out child> (. result.Add(child); .)
239 ····{
240 ········(
241 ············"+" (. newOp = "+"; .)
242 ············| "-" (. newOp = "-"; .)
243 ········)
244 ········MulExpr<out child> (. result.Add(child, newOp); .)
245 ····}
246 (. expression = result.Simplify(); .)
247 .
248
249 /*------------------------------------------------------------------------*/
250 MulExpr<out OqlExpression expression>
251 ····(.
252 ········OqlExpression child;
253 ········OqlExpression result = new OqlExpression(la.line, la.col);
254 ········string newOp = null;
255 ····.)
256 = Unary<out child> (. result.Add(child); .)
257 ····{
258 ········(
259 ············"*" (. newOp = "*"; .)
260 ············| "/" (. newOp = "/"; .)
261 ············| "%" (. newOp = "%"; .)
262 ············| "MOD" (. newOp = "MOD"; .)
263 ········)
264 ········Unary<out child> (. result.Add(child, newOp); .)
265 ····}
266 (. expression = result.Simplify(); .)
267 .
268
269 /*------------------------------------------------------------------------*/
270 Unary <out OqlExpression expression>
271 ····(.
272 ········OqlExpression child;
273 ········OqlExpression result = new OqlExpression(la.line, la.col);
274 ········string newOp = null;
275 ····.)
276
277 = [······"+" (. newOp = "+"; .)
278 ····| "-" (. newOp = "-"; .)
279 ····| "~" (. newOp = "~"; .)
280 ··]·· Primary<out child> (. result.Add(child); child.UnaryOp = newOp; .)
281 (. expression = result.Simplify(); .)··
282 .
283 /*------------------------------------------------------------------------*/
284 Primary <out OqlExpression expression>
285 ····(.
286 ········OqlExpression result = null;
287 ········OqlExpression child;
288 ····.)
289 =··
290 ··(
291 ······ident (. result = new IdentifierExpression(t.val, t.line, t.col); .)
292 ············[
293 ················IF(IsOidIdentifier(result))
294 ················"(" intCon
295 ····················(.
296 ····················result.UnaryOp="";
297 ····················result.Add(new IndexExpression(int.Parse(t.val), t.line, t.col));
298 ····················.)
299 ················")"
300 ················|
301 ················"("
302 ····················ParameterList <out child>
303 ····················(.
304 ························result = new FunctionExpression(result.Value, t.line, t.col);
305 ························result.UnaryOp="";························
306 ························result.Add(child);
307 ····················.)
308 ················")"
309 ············]
310 ······| Literal <out result>
311 ······| parameter (. result = new ParameterExpression(t.val, t.line, t.col); .)
312 ······| "(" RootExpr <out result> (. result.HasBrackets = true; .) ")"
313 ··)
314 (. expression = result.Simplify(); .)··
315 .
316
317 Identifier <out OqlExpression expression>
318 ····(.
319 ········OqlExpression result = null;
320 ····.)
321 =··
322 ····ident (. result = new IdentifierExpression(t.val, t.line, t.col); .)
323 (. expression = result.Simplify(); .)··
324 .
325
326 NumList <out OqlExpression expression>
327 ····(. ········
328 ········OqlExpression result = new OqlExpression(la.line, la.col);
329 ····.)
330 =
331 ····(
332 ········realCon (. result.Add(new NumberExpression(double.Parse(t.val, CultureInfo.InvariantCulture ), t.line, t.col)); .)
333 ········| intCon (. result.Add(new NumberExpression(int.Parse(t.val), t.line, t.col)); .)
334 ····)
335 {
336 ····","
337 ····(
338 ········realCon (. result.Add(new NumberExpression(double.Parse(t.val, CultureInfo.InvariantCulture ), t.line, t.col), ","); .)
339 ········| intCon (. result.Add(new NumberExpression(int.Parse(t.val), t.line, t.col), ","); .)
340 ····)
341 }
342 (. expression = result.Simplify(); .)
343 .
344
345 StringList <out OqlExpression expression>
346 ····(.
347 ········OqlExpression result = new OqlExpression(la.line, la.col);
348 ····.)
349 =
350 ····stringCon (. result.Add(new StringLiteralExpression(t.val, t.line, t.col)); .)
351 ····{
352 ········","
353 ········stringCon (. result.Add(new StringLiteralExpression(t.val, t.line, t.col), ","); .)
354 ····}
355 (. expression = result; /* Do not simplify here, because otherwise the brackets are missing */ .)
356 .
357
358 ParameterList <out OqlExpression expression>
359 ····(.
360 ········OqlExpression result = new ParameterListExpression(la.line, la.col);
361 ········OqlExpression child;
362 ····.)
363 =
364 ····[
365 ········Primary <out child> (. result.Add(child); .)
366 ········{
367 ············","
368 ············Primary <out child> (. result.Add(child, ","); .)
369 ········}
370 ····]
371 (. expression = result; /* Do not simplify here, because otherwise the brackets are missing */ .)
372 .
373
374
375
376 /*------------------------------------------------------------------------*/
377 Literal <out OqlExpression expression>
378 ····(.
379 ········OqlExpression result = null;
380 ····.)
381 =
382 (
383 ···· realCon (. result = new NumberExpression(double.Parse(t.val, CultureInfo.InvariantCulture ), t.line, t.col); .)
384 ····| intCon (. result = new NumberExpression(int.Parse(t.val), t.line, t.col); .)
385 ····| stringCon (. result = new StringLiteralExpression(t.val, t.line, t.col); .)
386 ····| "TRUE" (. result = new NamedConstantExpression("TRUE", t.line, t.col); .)
387 ····| "FALSE" (. result = new NamedConstantExpression("FALSE", t.line, t.col); .)
388 ····| "NULL" (. result = new NamedConstantExpression("NULL", t.line, t.col); .)
389 )
390 (. expression = result.Simplify(); .)··
391 .
392
393 END NDOQL.
394