add support for regex filter

This commit is contained in:
xvrl 2013-03-04 14:43:30 -08:00
parent f5e3ff9692
commit 88515ec59f
1 changed files with 7 additions and 4 deletions

View File

@ -92,6 +92,7 @@ DIV: '/';
COMMA: ',';
EQ: '=';
NEQ: '!=';
MATCH: '~';
GROUP: 'group';
IDENT : (LETTER)(LETTER | DIGIT | '_')* ;
@ -246,11 +247,13 @@ primaryDimFilter returns [DimFilter filter]
;
selectorDimFilter returns [DimFilter filter]
: dimension=IDENT op=(EQ|NEQ) value=QUOTED_STRING {
DimFilter f = new SelectorDimFilter($dimension.text, unescape($value.text));
: dimension=IDENT op=(EQ|NEQ|MATCH) value=QUOTED_STRING {
String dim = $dimension.text;
String val = unescape($value.text);
switch($op.type) {
case(EQ): $filter = f; break;
case(NEQ): $filter = new NotDimFilter(f); break;
case(EQ): $filter = new SelectorDimFilter(dim, val); break;
case(NEQ): $filter = new NotDimFilter(new SelectorDimFilter(dim, val)); break;
case(MATCH): $filter = new RegexDimFilter(dim, val); break;
}
}
;