blob: 67491ea63647b6ca2e0705bcee21416840c2efca [file] [log] [blame]
Joachim Bingeldbbde772014-05-12 15:26:10 +00001grammar CollectionQuery;
2
3@header {package de.ids_mannheim.korap.query.serialize.util;}
4
5/*
6 -- author: jbingel
7 -- date: 14-05-11
8*/
9
10/*
11 * LEXER SECTION
12 */
13
14WS : ( ' ' | '\t' | '\r' | '\n' )+ -> skip ;
15fragment FOCC : '{' WS* ( [0-9]* WS* ',' WS* [0-9]+ | [0-9]+ WS* ','? ) WS* '}';
16fragment NO_RE : ~[ \t\/];
17fragment ALPHABET : ~('\t' | ' ' | '/' | '*' | '?' | '+' | '{' | '}' | '[' | ']'
18 | '(' | ')' | '|' | '"' | ',' | ':' | '\'' | '\\' | '!' | '=' | '~' | '&' | '^' | '<' | '>' );
19NUMBER : [0-9]+;
20
21NL : [\r\n] -> skip;
22ws : WS+;
23
24WORD : ALPHABET+;
25LRB : '(';
26RRB : ')';
27LT : '<';
28GT : '>';
29LEQ : '<=';
30GEQ : '>=';
31EQ : '=';
32NE : '!=';
33AND : '&';
34OR : '|';
35
36/*
37 * PARSER SECTION
38 */
39
40conj
41: AND | OR;
42
43operator
44: EQ | NE | LT | GT | LEQ | GEQ;
45
46expr
47: field operator value
48| value operator field operator value
49;
50
51field
52: WORD;
53
54value
55: WORD | NUMBER;
56
57andGroup
58: (expr AND)* (LRB orGroup RRB)? (AND expr)*
59| (expr AND)+ expr
60;
61
62orGroup
63: (expr OR)* (LRB andGroup RRB)? (OR expr)*
64| (expr OR)+ expr
65;
66
67exprGroup
68: andGroup
69| orGroup
70;
71
72start
73: expr
74| exprGroup
75;