collection queries: regex, groups
diff --git a/src/main/antlr/CollectionQuery.g4 b/src/main/antlr/CollectionQuery.g4
index 0bd7fe5..7aad659 100644
--- a/src/main/antlr/CollectionQuery.g4
+++ b/src/main/antlr/CollectionQuery.g4
@@ -20,9 +20,9 @@
NE : '!=';
AND : '&' | 'AND' | 'and' | 'UND' | 'und' ;
OR : '|' | 'OR' | 'or' | 'ODER' | 'oder' ;
-
+QMARK : '?';
+SLASH : '/';
WS : ( ' ' | '\t' | '\r' | '\n' )+ -> skip ;
-fragment FOCC : '{' WS* ( [0-9]* WS* ',' WS* [0-9]+ | [0-9]+ WS* ','? ) WS* '}';
fragment NO_RE : ~[ \t\/];
fragment ALPHABET : ~('\t' | ' ' | '/' | '*' | '?' | '+' | '{' | '}' | '[' | ']'
| '(' | ')' | '|' | '"' | ',' | ':' | '\'' | '\\' | '!' | '=' | '~' | '&' | '^' | '<' | '>' );
@@ -34,19 +34,20 @@
WORD : ALPHABET+;
/*
- * Regular expressions (delimited by slashes in Annis)
+ * Regular expressions
*/
+fragment FOCC : '{' WS* ( [0-9]* WS* ',' WS* [0-9]+ | [0-9]+ WS* ','? ) WS* '}';
fragment RE_char : ~('*' | '?' | '+' | '{' | '}' | '[' | ']' | '/'
| '(' | ')' | '|' | '"' | ':' | '\'' | '\\');
fragment RE_alter : ((RE_char | ('(' REGEX ')') | RE_chgroup) '|' REGEX )+;
fragment RE_chgroup : '[' RE_char+ ']';
+fragment RE_quant : (RE_star | RE_plus | RE_occ) QMARK?;
fragment RE_opt : (RE_char | RE_chgroup | ( '(' REGEX ')')) '?';
fragment RE_star : (RE_char | RE_chgroup | ( '(' REGEX ')')) '*';
fragment RE_plus : (RE_char | RE_chgroup | ( '(' REGEX ')')) '+';
fragment RE_occ : (RE_char | RE_chgroup | ( '(' REGEX ')')) FOCC;
fragment RE_group : '(' REGEX ')';
-SLASH : '/';
-REGEX : SLASH ('.' | RE_char | RE_alter | RE_chgroup | RE_opt | RE_star | RE_plus | RE_occ | RE_group)* SLASH;
+REGEX : SLASH ('.' | RE_char | RE_alter | RE_chgroup | RE_opt | RE_quant | RE_group)* SLASH;
/*
* PARSER SECTION
@@ -67,12 +68,17 @@
;
field
-: WORD;
+: WORD
+;
value
-: WORD | NUMBER | '"' (WORD ws*)+'"'
-| regex;
-
+: WORD
+| NUMBER
+| '"' (WORD ws*)+'"'
+| regex
+;
+
+/*
andGroup
: (((LRB exprGroup RRB)|expr) AND)+ ((LRB exprGroup RRB)|expr)
;
@@ -80,13 +86,18 @@
orGroup
: (((LRB exprGroup RRB)|expr) OR)+ ((LRB exprGroup RRB)|expr)
;
+*/
+
+relation
+: (expr|exprGroup) conj (expr|exprGroup|relation)
+;
exprGroup
-: andGroup
-| orGroup
+: LRB (expr | exprGroup | relation) RRB
;
start
-: expr
-| exprGroup EOF
+: ( expr
+ | exprGroup EOF
+ | relation EOF )
;
\ No newline at end of file