@@ -135,8 +135,7 @@ UNSET : '?';
135
135
NULL : N U L L ;
136
136
ORID : ' #' ;
137
137
138
- TEXT : (' \' ' ( ESC_SEQ | ' \'\' ' | ~(' \\ ' |' \' ' ) )* ' \' ' )
139
- | (' "' ( ESC_SEQ | ~(' \\ ' |' "' ) )* ' "' );
138
+ TEXT : (' \' ' ( ESC_SEQ | ' \'\' ' | ~(' \\ ' |' \' ' ) )* ' \' ' ) ;
140
139
141
140
INT : DIGIT + ;
142
141
FLOAT
@@ -147,6 +146,7 @@ FLOAT
147
146
;
148
147
149
148
WORD : LETTER (DIGIT |LETTER )* ;
149
+ ESCWORD : (' "' ( ESC_SEQ | ~(' \\ ' |' "' ) )* ' "' ) ;
150
150
151
151
152
152
@@ -181,9 +181,73 @@ UNICODE_ESC
181
181
// PARSER
182
182
// -----------------------------------------------------------------//
183
183
184
- word : WORD ;
185
- identifier : ORID INT ' :' INT ;
186
- unset : UNSET | (DOUBLEDOT word);
184
+ keywords
185
+ : SELECT
186
+ | INSERT
187
+ | UPDATE
188
+ | CREATE
189
+ | DELETE
190
+ | FROM
191
+ | WHERE
192
+ | INTO
193
+ | DROP
194
+ | FORCE
195
+ | VALUES
196
+ | SET
197
+ | ADD
198
+ | REMOVE
199
+ | AND
200
+ | OR
201
+ | ORDER
202
+ | BY
203
+ | LIMIT
204
+ | LIKE
205
+ | RANGE
206
+ | ASC
207
+ | AS
208
+ | DESC
209
+ | OTHIS
210
+ | ORID_ATTR
211
+ | OCLASS_ATTR
212
+ | OVERSION_ATTR
213
+ | OSIZE_ATTR
214
+ | OTYPE_ATTR
215
+ | CLUSTER
216
+ | DATABASE
217
+ | PROPERTY
218
+ | TRUNCATE
219
+ | EXTENDS
220
+ | ABSTRACT
221
+ | RECORD
222
+ | INDEX
223
+ | DICTIONARY
224
+ | ALTER
225
+ | CLASS
226
+ | SKIP
227
+ | GRANT
228
+ | REVOKE
229
+ | IN
230
+ | ON
231
+ | TO
232
+ | IS
233
+ | NOT
234
+ | GROUP
235
+ | DATASEGMENT
236
+ | LOCATION
237
+ | POSITION
238
+ | RUNTIME
239
+ | EDGE
240
+ | FUNCTION
241
+ | LINK
242
+ | VERTEX
243
+ | TYPE
244
+ | INVERSE
245
+ | IDEMPOTENT
246
+ | LANGUAGE
247
+ ;
248
+ reference : WORD | ESCWORD | keywords;
249
+ orid : ORID INT ' :' INT ;
250
+ unset : UNSET | (DOUBLEDOT reference);
187
251
number : (UNARY ^)? (INT |FLOAT ) ;
188
252
map : LACCOLADE (literal DOUBLEDOT expression (COMMA literal DOUBLEDOT expression)*)? RACCOLADE ;
189
253
collection : LBRACKET (expression (COMMA expression)*)? RBRACKET ;
@@ -194,16 +258,16 @@ literal
194
258
;
195
259
196
260
arguments : LPAREN (expression (COMMA expression)*)? RPAREN ;
197
- functionCall : word arguments ;
198
- methodCall : DOT word arguments* ;
261
+ functionCall : reference arguments ;
262
+ methodCall : DOT reference arguments* ;
199
263
200
264
expression
201
265
: literal
202
266
| map
203
267
| collection
204
- | identifier
268
+ | orid
205
269
| unset
206
- | word
270
+ | reference
207
271
| LPAREN expression RPAREN
208
272
| functionCall
209
273
| expression methodCall
@@ -216,7 +280,7 @@ filter
216
280
: LPAREN filter RPAREN
217
281
| filter filterAnd
218
282
| filter filterOr
219
- | filter filterIn
283
+ | expression filterIn
220
284
| NOT filter
221
285
| expression COMPARE_EQL expression
222
286
| expression COMPARE_INF expression
@@ -237,20 +301,20 @@ anything : .*? ;
237
301
commandUnknowned : expression (expression)* ;
238
302
239
303
commandInsertIntoByValues
240
- : INSERT INTO ((CLUSTER |INDEX ) DOUBLEDOT )? word insertCluster? insertFields VALUES insertSource
304
+ : INSERT INTO ((CLUSTER |INDEX ) DOUBLEDOT )? reference insertCluster? insertFields VALUES insertSource
241
305
;
242
306
commandInsertIntoBySet
243
- : INSERT INTO ((CLUSTER |INDEX ) DOUBLEDOT )? word insertCluster? SET insertSet (COMMA insertSet)*
307
+ : INSERT INTO ((CLUSTER |INDEX ) DOUBLEDOT )? reference insertCluster? SET insertSet (COMMA insertSet)*
244
308
;
245
309
insertSource
246
310
: commandSelect
247
311
| LPAREN insertSource RPAREN
248
312
| insertEntry (COMMA insertEntry)*
249
313
;
250
- insertCluster : CLUSTER word ;
314
+ insertCluster : CLUSTER reference ;
251
315
insertEntry : LPAREN expression (COMMA expression)* RPAREN ;
252
- insertSet : word COMPARE_EQL expression ;
253
- insertFields : LPAREN word (COMMA word )* RPAREN ;
316
+ insertSet : reference COMPARE_EQL expression ;
317
+ insertFields : LPAREN reference (COMMA reference )* RPAREN ;
254
318
255
319
commandSelect
256
320
: SELECT (projection (COMMA projection)*)? from (WHERE filter)? groupBy? orderBy? skip? limit?
@@ -266,11 +330,11 @@ projection
266
330
| OTYPE_ATTR )
267
331
(alias)?
268
332
;
269
- alias : AS word ;
333
+ alias : AS reference ;
270
334
from
271
335
: FROM
272
- ( ((CLUSTER |INDEX |DICTIONARY ) DOUBLEDOT )? word
273
- | identifier
336
+ ( ((CLUSTER |INDEX |DICTIONARY ) DOUBLEDOT )? reference
337
+ | orid
274
338
| collection
275
339
| commandSelect
276
340
| LPAREN commandSelect RPAREN )
@@ -281,40 +345,39 @@ orderByElement : expression (ASC|DESC)? ;
281
345
skip : SKIP INT ;
282
346
limit : LIMIT INT ;
283
347
284
- commandCreateClass : CREATE CLASS word (EXTENDS word )? (CLUSTER numberOrWord(COMMA numberOrWord)*)? ABSTRACT ?;
285
- numberOrWord : number | word ;
286
- commandCreateCluster : CREATE CLUSTER word word (DATASEGMENT word )? (LOCATION word )? (POSITION word )? ;
287
- commandCreateIndex : CREATE INDEX word (indexOn)? word (NULL | RUNTIME INT | (word (COMMA word )*))?;
288
- indexOn : ON word LPAREN word (COMMA word )* RPAREN ;
289
- commandCreateProperty : CREATE PROPERTY word DOT word word word ?;
290
- commandCreateEdge : CREATE EDGE word ? (edgeCluster)? FROM edgeEnd TO edgeEnd (SET insertSet (COMMA insertSet)*)?;
291
- edgeCluster : CLUSTER word ;
292
- edgeEnd : identifier | collection | commandSelect ;
293
- commandCreateFunction : CREATE FUNCTION word TEXT (IDEMPOTENT word )? (LANGUAGE word )? ;
294
- commandCreateLink : CREATE LINK linkName? (TYPE word )? FROM word.word TO word.word INVERSE ?;
295
- linkName : word ;
296
- commandCreateVertex : CREATE VERTEX word (CLUSTER word )? (SET insertSet (COMMA insertSet)*)?;
297
-
298
- commandAlterClass : ALTER CLASS word word cword ;
299
- commandAlterCluster : ALTER CLUSTER (word |number) word cword;
300
- commandAlterDatabase : ALTER DATABASE word cword;
301
- commandAlterProperty : ALTER PROPERTY word DOT word word cword ;
302
-
303
- commandDropClass : DROP CLASS word ;
304
- commandDropCluster : DROP CLUSTER word ;
305
- commandDropIndex : DROP INDEX word ;
306
- commandDropProperty : DROP PROPERTY word DOT word FORCE ;
307
-
308
- commandTruncateClass : TRUNCATE CLASS word ;
309
- commandTruncateCluster : TRUNCATE CLUSTER word ;
310
- commandTruncateRecord : TRUNCATE RECORD (identifier |collection) ;
311
-
312
- commandGrant : GRANT word ON word TO word ;
313
- commandRevoke : REVOKE word ON word FROM word ;
348
+ commandCreateClass : CREATE CLASS reference (EXTENDS reference )? (CLUSTER numberOrWord(COMMA numberOrWord)*)? ABSTRACT ?;
349
+ numberOrWord : number | reference ;
350
+ commandCreateCluster : CREATE CLUSTER reference reference (DATASEGMENT reference )? (LOCATION reference )? (POSITION reference )? ;
351
+ commandCreateIndex : CREATE INDEX reference (indexOn)? reference (NULL | RUNTIME INT | (reference (COMMA reference )*))?;
352
+ indexOn : ON reference LPAREN reference (COMMA reference )* RPAREN ;
353
+ commandCreateProperty : CREATE PROPERTY reference DOT reference reference reference ?;
354
+ commandCreateEdge : CREATE EDGE reference ? (edgeCluster)? FROM edgeEnd TO edgeEnd (SET insertSet (COMMA insertSet)*)?;
355
+ edgeCluster : CLUSTER reference ;
356
+ edgeEnd : orid | collection | commandSelect ;
357
+ commandCreateFunction : CREATE FUNCTION reference TEXT (IDEMPOTENT reference )? (LANGUAGE reference )? ;
358
+ commandCreateLink : CREATE LINK linkName? (TYPE reference )? FROM reference DOT reference TO reference DOT reference INVERSE ?;
359
+ linkName : reference ;
360
+ commandCreateVertex : CREATE VERTEX reference (CLUSTER reference )? (SET insertSet (COMMA insertSet)*)?;
361
+
362
+ commandAlterClass : ALTER CLASS reference reference cword ;
363
+ commandAlterCluster : ALTER CLUSTER (reference |number) reference cword;
364
+ commandAlterDatabase : ALTER DATABASE reference cword;
365
+ commandAlterProperty : ALTER PROPERTY reference DOT reference reference cword ;
366
+
367
+ commandDropClass : DROP CLASS reference ;
368
+ commandDropCluster : DROP CLUSTER reference ;
369
+ commandDropIndex : DROP INDEX reference ;
370
+ commandDropProperty : DROP PROPERTY reference DOT reference FORCE ;
371
+
372
+ commandTruncateClass : TRUNCATE CLASS reference ;
373
+ commandTruncateCluster : TRUNCATE CLUSTER reference ;
374
+ commandTruncateRecord : TRUNCATE RECORD (orid |collection) ;
375
+
376
+ commandGrant : GRANT reference ON reference TO reference ;
377
+ commandRevoke : REVOKE reference ON reference FROM reference ;
314
378
315
379
command
316
- : (commandUnknowned
317
- | commandCreateClass
380
+ : (commandCreateClass
318
381
| commandCreateCluster
319
382
| commandCreateIndex
320
383
| commandCreateProperty
0 commit comments