- upgraded to ANTLR 4.1 (4.2 and 4.3 lack a needed class and maven-plugin not yet released for 4.4)
- content filters in collection queries
diff --git a/src/main/antlr/CollectionQuery.g4 b/src/main/antlr/CollectionQuery.g4
index 226e065..3d6aaa8 100644
--- a/src/main/antlr/CollectionQuery.g4
+++ b/src/main/antlr/CollectionQuery.g4
@@ -4,25 +4,40 @@
/*
-- author: jbingel
- -- date: 14-05-11
+ -- date: 2014-05-11
*/
/*
* LEXER SECTION
*/
+/*
+ Regular expression
+ /x allows submatches like /^.*?RE.*?$/
+ /X forces full matches
+ /i means case insensitivity
+ /I forces case sensitivity
+*/
+FLAG_xi : '/' ( ('x'|'X') ('i'|'I')? );
+FLAG_ix : '/' ( ('i'|'I') ('x'|'X')? );
+
+
LRB : '(';
RRB : ')';
+LB : '[';
+RB : ']';
LT : '<';
GT : '>';
LEQ : '<=';
GEQ : '>=';
EQ : '=';
-NE : '!=';
AND : '&' | 'AND' | 'and' | 'UND' | 'und' ;
OR : '|' | 'OR' | 'or' | 'ODER' | 'oder' ;
+NEG : '!';
QMARK : '?';
SLASH : '/';
+COLON : ':';
DASH : '-';
+TILDE : '~';
WS : ( ' ' | '\t' | '\r' | '\n' )+ -> skip ;
fragment NO_RE : ~[ \t\/];
fragment ALPHABET : ~('\t' | ' ' | '/' | '*' | '?' | '+' | '{' | '}' | '[' | ']'
@@ -35,6 +50,7 @@
WORD : ALPHABET+;
+
/*
* Regular expressions
*/
@@ -63,15 +79,56 @@
: DIGIT DIGIT DIGIT DIGIT (DASH DIGIT DIGIT (DASH DIGIT DIGIT)?)?
;
-conj
-: AND | OR;
-
operator
-: EQ | NE | LT | GT | LEQ | GEQ;
+: (NEG? EQ) | LT | GT | LEQ | GEQ;
expr
-: (value operator)? field operator value
-//| LRB expr RRB
+: meta
+| token
+;
+
+meta
+: (value operator)? field operator value
+;
+
+token
+: LB (term|termGroup) RB
+;
+
+term
+: NEG* (foundry SLASH)? layer termOp key (COLON value)? flag?
+;
+
+termOp
+: (NEG? EQ? EQ | NEG? TILDE? TILDE)
+;
+
+termGroup
+: (term | LRB termGroup RRB) booleanOp (term | LRB termGroup RRB | termGroup)
+;
+
+key
+: WORD
+| regex
+| NUMBER
+;
+
+foundry
+: WORD
+;
+
+layer
+: WORD
+;
+
+booleanOp
+: AND
+| OR
+;
+
+flag
+: FLAG_xi
+| FLAG_ix
;
field
@@ -86,11 +143,8 @@
| regex
;
-
-
relation
-: (expr|exprGroup) conj (expr|exprGroup|relation)
-//| LRB relation RRB
+: (expr|exprGroup) booleanOp (expr|exprGroup|relation)
;
exprGroup
@@ -98,7 +152,7 @@
;
start
-: ( expr
- | exprGroup
- | relation )
+: expr EOF
+| exprGroup EOF
+| relation EOF
;
\ No newline at end of file