You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by ha...@apache.org on 2015/11/19 11:47:38 UTC
[31/55] [abbrv] [partial] incubator-eagle git commit: [EAGLE-46]
Rename package name as "org.apache.eagle"
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/ORExpression.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/ORExpression.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/ORExpression.java
deleted file mode 100644
index 87cfe4c..0000000
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/ORExpression.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package eagle.query.parser;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ORExpression {
- private List<ANDExpression> andExprList = new ArrayList<ANDExpression>();
-
- public List<ANDExpression> getANDExprList() {
- return andExprList;
- }
-
- public void setANDExprList(List<ANDExpression> list) {
- this.andExprList = list;
- }
-
- public String toString(){
- StringBuffer sb = new StringBuffer();
- boolean first = true;
- for(ANDExpression andRel : andExprList){
- if(first)
- first = false;
- else{
- sb.append(" ");
- sb.append(LogicalOperator.OR);
- sb.append(" ");
- }
- sb.append("(");
- boolean firstAND = true;
- for(AtomicExpression kv : andRel.getAtomicExprList()){
- if(firstAND)
- firstAND = false;
- else{
- sb.append(" ");
- sb.append(LogicalOperator.AND);
- sb.append(" ");
- }
- sb.append(kv);
- }
- sb.append(")");
- }
- return sb.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/TokenConstant.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/TokenConstant.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/TokenConstant.java
deleted file mode 100755
index c415b80..0000000
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/TokenConstant.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package eagle.query.parser;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public final class TokenConstant {
- public final static Pattern EXP_PATTERN= Pattern.compile("^EXP\\{(.+)\\}(\\s+AS\\s+)?\\s*(.+)?\\s*$",Pattern.CASE_INSENSITIVE);
- public final static Pattern STRING_PATTERN= Pattern.compile("^(\"(.*?\n)*.*\")$");
- public final static Pattern ARRAY_PATTERN= Pattern.compile("^(\\(.*\\))$");
- public final static Pattern NUMBER_PATTERN= Pattern.compile("^((-|\\+)?\\s*[0-9]+(\\.[0-9]+)?)$");
- public final static Pattern NULL_PATTERN= Pattern.compile("^(NULL|null)$");
- public final static Pattern ID_PATTERN= Pattern.compile("^@(.+)$");
-
- public final static String ID_PREFIX = "@";
- public final static String WHITE_SPACE = "";
-
- public static boolean isExpression(String query){
- if(query == null) return false;
- Matcher matcher = EXP_PATTERN.matcher(query);
- return matcher.matches();
- }
-
- /**
- * EXP{ expression } AS alias => expression
- *
- * @param expression
- * @return
- */
- public static String parseExpressionContent(String expression){
- Matcher matcher = EXP_PATTERN.matcher(expression);
- if(matcher.find()){
- expression = matcher.group(1);
- }
- return expression;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/TokenType.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/TokenType.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/TokenType.java
deleted file mode 100755
index 35a1dde..0000000
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/TokenType.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package eagle.query.parser;
-
-public enum TokenType {
- EXP, NUMBER, STRING, LIST, NULL,ID;
-
- public static TokenType locate(String tokenText){
- String _value = tokenText.trim();
- if (TokenConstant.EXP_PATTERN.matcher(_value).matches()) {
- // e.q. "value" with EXP{...}
- return EXP;
- }else if(TokenConstant.STRING_PATTERN.matcher(_value).matches()){
- // e.q. "value" with quotes
- return STRING;
- }else if(TokenConstant.ARRAY_PATTERN.matcher(_value).matches()){
- // e.q. (item1,item2,..)
- return LIST;
- }else if(TokenConstant.NUMBER_PATTERN.matcher(_value).matches()){
- // e.q. 1.32 without quotes
- return NUMBER;
- }else if(TokenConstant.NULL_PATTERN.matcher(_value).matches()){
- // e.q. null or NULL without quotes
- return NULL;
- } else if(TokenConstant.ID_PATTERN.matcher(_value).matches()){
- return ID;
- }
- throw new IllegalArgumentException("Can't locate type of value text: "+tokenText);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/UnsupportedExpressionOperatorException.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/UnsupportedExpressionOperatorException.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/UnsupportedExpressionOperatorException.java
deleted file mode 100644
index 1fe19cd..0000000
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/eagle/query/parser/UnsupportedExpressionOperatorException.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package eagle.query.parser;
-
-public class UnsupportedExpressionOperatorException extends RuntimeException{
- private static final long serialVersionUID = 565210592983703093L;
-
- public UnsupportedExpressionOperatorException(String message){
- super(message);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilter.tokens
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilter.tokens b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilter.tokens
new file mode 100755
index 0000000..5ebca36
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilter.tokens
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+WHITESPACE=1
+OP=2
+AND=3
+OR=4
+ID=5
+VALUE=6
+SINGLE_VALUE=7
+EXPR=8
+NUMBER=9
+NULL=10
+SET=11
+DOUBLEQUOTED_STRING=12
+LPAREN=13
+RPAREN=14
+LBRACE=15
+RBRACE=16
+'('=13
+')'=14
+'{'=15
+'}'=16
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterBaseListener.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterBaseListener.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterBaseListener.java
new file mode 100755
index 0000000..65fa321
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterBaseListener.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Generated from EagleFilter.g4 by ANTLR 4.5
+package org.apache.eagle.query.antlr.generated;
+
+import org.antlr.v4.runtime.ParserRuleContext;
+import org.antlr.v4.runtime.tree.ErrorNode;
+import org.antlr.v4.runtime.tree.TerminalNode;
+
+/**
+ * This class provides an empty implementation of {@link EagleFilterListener},
+ * which can be extended to create a listener which only needs to handle a subset
+ * of the available methods.
+ */
+public class EagleFilterBaseListener implements EagleFilterListener {
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void enterFilter(EagleFilterParser.FilterContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void exitFilter(EagleFilterParser.FilterContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void enterCombine(EagleFilterParser.CombineContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void exitCombine(EagleFilterParser.CombineContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void enterEquation(EagleFilterParser.EquationContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void exitEquation(EagleFilterParser.EquationContext ctx) { }
+
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void enterEveryRule(ParserRuleContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void exitEveryRule(ParserRuleContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void visitTerminal(TerminalNode node) { }
+ /**
+ * {@inheritDoc}
+ *
+ * <p>The default implementation does nothing.</p>
+ */
+ @Override public void visitErrorNode(ErrorNode node) { }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterLexer.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterLexer.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterLexer.java
new file mode 100755
index 0000000..0899732
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterLexer.java
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Generated from EagleFilter.g4 by ANTLR 4.5
+package org.apache.eagle.query.antlr.generated;
+
+import org.antlr.v4.runtime.Lexer;
+import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.Token;
+import org.antlr.v4.runtime.TokenStream;
+import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.atn.*;
+import org.antlr.v4.runtime.dfa.DFA;
+import org.antlr.v4.runtime.misc.*;
+
+@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
+public class EagleFilterLexer extends Lexer {
+ static { RuntimeMetaData.checkVersion("4.5", RuntimeMetaData.VERSION); }
+
+ protected static final DFA[] _decisionToDFA;
+ protected static final PredictionContextCache _sharedContextCache =
+ new PredictionContextCache();
+ public static final int
+ WHITESPACE=1, OP=2, AND=3, OR=4, ID=5, VALUE=6, SINGLE_VALUE=7, EXPR=8,
+ NUMBER=9, NULL=10, SET=11, DOUBLEQUOTED_STRING=12, LPAREN=13, RPAREN=14,
+ LBRACE=15, RBRACE=16;
+ public static String[] modeNames = {
+ "DEFAULT_MODE"
+ };
+
+ public static final String[] ruleNames = {
+ "WHITESPACE", "OP", "AND", "OR", "ID", "VALUE", "SINGLE_VALUE", "EXPR",
+ "NUMBER", "NULL", "SET", "DOUBLEQUOTED_STRING", "UNSIGN_INT", "STRING",
+ "LPAREN", "RPAREN", "LBRACE", "RBRACE"
+ };
+
+ private static final String[] _LITERAL_NAMES = {
+ null, null, null, null, null, null, null, null, null, null, null, null,
+ null, "'('", "')'", "'{'", "'}'"
+ };
+ private static final String[] _SYMBOLIC_NAMES = {
+ null, "WHITESPACE", "OP", "AND", "OR", "ID", "VALUE", "SINGLE_VALUE",
+ "EXPR", "NUMBER", "NULL", "SET", "DOUBLEQUOTED_STRING", "LPAREN", "RPAREN",
+ "LBRACE", "RBRACE"
+ };
+ public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
+
+ /**
+ * @deprecated Use {@link #VOCABULARY} instead.
+ */
+ @Deprecated
+ public static final String[] tokenNames;
+ static {
+ tokenNames = new String[_SYMBOLIC_NAMES.length];
+ for (int i = 0; i < tokenNames.length; i++) {
+ tokenNames[i] = VOCABULARY.getLiteralName(i);
+ if (tokenNames[i] == null) {
+ tokenNames[i] = VOCABULARY.getSymbolicName(i);
+ }
+
+ if (tokenNames[i] == null) {
+ tokenNames[i] = "<INVALID>";
+ }
+ }
+ }
+
+ @Override
+ @Deprecated
+ public String[] getTokenNames() {
+ return tokenNames;
+ }
+
+ @Override
+
+ public Vocabulary getVocabulary() {
+ return VOCABULARY;
+ }
+
+
+ public EagleFilterLexer(CharStream input) {
+ super(input);
+ _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
+ }
+
+ @Override
+ public String getGrammarFileName() { return "EagleFilter.g4"; }
+
+ @Override
+ public String[] getRuleNames() { return ruleNames; }
+
+ @Override
+ public String getSerializedATN() { return _serializedATN; }
+
+ @Override
+ public String[] getModeNames() { return modeNames; }
+
+ @Override
+ public ATN getATN() { return _ATN; }
+
+ public static final String _serializedATN =
+ "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2\22\u010c\b\1\4\2"+
+ "\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4"+
+ "\13\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22"+
+ "\t\22\4\23\t\23\3\2\6\2)\n\2\r\2\16\2*\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3"+
+ "\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\6\3E"+
+ "\n\3\r\3\16\3F\3\3\3\3\3\3\3\3\3\3\3\3\3\3\6\3P\n\3\r\3\16\3Q\3\3\3\3"+
+ "\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3"+
+ "\3\3\3\3\3\3\3\6\3k\n\3\r\3\16\3l\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3"+
+ "\3\3\3\3\3\3\3\3\6\3|\n\3\r\3\16\3}\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3"+
+ "\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\6\3\u0090\n\3\r\3\16\3\u0091\3\3\3\3\3"+
+ "\3\3\3\3\3\3\3\3\3\6\3\u009b\n\3\r\3\16\3\u009c\3\3\3\3\3\3\5\3\u00a2"+
+ "\n\3\3\4\3\4\3\4\3\4\3\4\3\4\5\4\u00aa\n\4\3\5\3\5\3\5\3\5\5\5\u00b0\n"+
+ "\5\3\6\3\6\6\6\u00b4\n\6\r\6\16\6\u00b5\3\7\3\7\3\7\5\7\u00bb\n\7\3\b"+
+ "\3\b\3\b\5\b\u00c0\n\b\3\t\3\t\3\t\3\t\3\t\3\t\5\t\u00c8\n\t\3\t\3\t\6"+
+ "\t\u00cc\n\t\r\t\16\t\u00cd\3\t\3\t\3\n\5\n\u00d3\n\n\3\n\3\n\3\n\5\n"+
+ "\u00d8\n\n\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\5\13\u00e2\n\13\3\f"+
+ "\3\f\5\f\u00e6\n\f\3\f\3\f\7\f\u00ea\n\f\f\f\16\f\u00ed\13\f\3\f\3\f\3"+
+ "\r\3\r\3\r\3\r\3\r\3\r\5\r\u00f7\n\r\3\16\6\16\u00fa\n\16\r\16\16\16\u00fb"+
+ "\3\17\3\17\3\17\6\17\u0101\n\17\r\17\16\17\u0102\3\20\3\20\3\21\3\21\3"+
+ "\22\3\22\3\23\3\23\2\2\24\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25"+
+ "\f\27\r\31\16\33\2\35\2\37\17!\20#\21%\22\3\2\7\5\2\13\f\16\17\"\"\4\2"+
+ ">>@@\6\2\"\"$$*+>@\3\2\177\177\3\2$$\u0134\2\3\3\2\2\2\2\5\3\2\2\2\2\7"+
+ "\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2"+
+ "\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\37\3\2\2\2\2"+
+ "!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\3(\3\2\2\2\5\u00a1\3\2\2\2\7\u00a9\3\2"+
+ "\2\2\t\u00af\3\2\2\2\13\u00b1\3\2\2\2\r\u00ba\3\2\2\2\17\u00bf\3\2\2\2"+
+ "\21\u00c7\3\2\2\2\23\u00d2\3\2\2\2\25\u00e1\3\2\2\2\27\u00e3\3\2\2\2\31"+
+ "\u00f6\3\2\2\2\33\u00f9\3\2\2\2\35\u0100\3\2\2\2\37\u0104\3\2\2\2!\u0106"+
+ "\3\2\2\2#\u0108\3\2\2\2%\u010a\3\2\2\2\')\t\2\2\2(\'\3\2\2\2)*\3\2\2\2"+
+ "*(\3\2\2\2*+\3\2\2\2+,\3\2\2\2,-\b\2\2\2-\4\3\2\2\2.\u00a2\7?\2\2/\60"+
+ "\7#\2\2\60\u00a2\7?\2\2\61\u00a2\t\3\2\2\62\63\7@\2\2\63\u00a2\7?\2\2"+
+ "\64\65\7>\2\2\65\u00a2\7?\2\2\66\67\7?\2\2\67\u00a2\7\u0080\2\289\7#\2"+
+ "\29:\7?\2\2:\u00a2\7\u0080\2\2;<\7k\2\2<\u00a2\7p\2\2=>\7K\2\2>\u00a2"+
+ "\7P\2\2?@\7p\2\2@A\7q\2\2AB\7v\2\2BD\3\2\2\2CE\7\"\2\2DC\3\2\2\2EF\3\2"+
+ "\2\2FD\3\2\2\2FG\3\2\2\2GH\3\2\2\2HI\7k\2\2I\u00a2\7p\2\2JK\7P\2\2KL\7"+
+ "Q\2\2LM\7V\2\2MO\3\2\2\2NP\7\"\2\2ON\3\2\2\2PQ\3\2\2\2QO\3\2\2\2QR\3\2"+
+ "\2\2RS\3\2\2\2ST\7K\2\2T\u00a2\7P\2\2UV\7e\2\2VW\7q\2\2WX\7p\2\2XY\7v"+
+ "\2\2YZ\7c\2\2Z[\7k\2\2[\\\7p\2\2\\\u00a2\7u\2\2]^\7E\2\2^_\7Q\2\2_`\7"+
+ "P\2\2`a\7V\2\2ab\7C\2\2bc\7K\2\2cd\7P\2\2d\u00a2\7U\2\2ef\7p\2\2fg\7q"+
+ "\2\2gh\7v\2\2hj\3\2\2\2ik\7\"\2\2ji\3\2\2\2kl\3\2\2\2lj\3\2\2\2lm\3\2"+
+ "\2\2mn\3\2\2\2no\7e\2\2op\7q\2\2pq\7p\2\2qr\7v\2\2rs\7c\2\2st\7k\2\2t"+
+ "u\7p\2\2u\u00a2\7u\2\2vw\7P\2\2wx\7Q\2\2xy\7V\2\2y{\3\2\2\2z|\7\"\2\2"+
+ "{z\3\2\2\2|}\3\2\2\2}{\3\2\2\2}~\3\2\2\2~\177\3\2\2\2\177\u0080\7E\2\2"+
+ "\u0080\u0081\7Q\2\2\u0081\u0082\7P\2\2\u0082\u0083\7V\2\2\u0083\u0084"+
+ "\7C\2\2\u0084\u0085\7K\2\2\u0085\u0086\7P\2\2\u0086\u00a2\7U\2\2\u0087"+
+ "\u0088\7k\2\2\u0088\u00a2\7u\2\2\u0089\u008a\7K\2\2\u008a\u00a2\7U\2\2"+
+ "\u008b\u008c\7k\2\2\u008c\u008d\7u\2\2\u008d\u008f\3\2\2\2\u008e\u0090"+
+ "\7\"\2\2\u008f\u008e\3\2\2\2\u0090\u0091\3\2\2\2\u0091\u008f\3\2\2\2\u0091"+
+ "\u0092\3\2\2\2\u0092\u0093\3\2\2\2\u0093\u0094\7p\2\2\u0094\u0095\7q\2"+
+ "\2\u0095\u00a2\7v\2\2\u0096\u0097\7K\2\2\u0097\u0098\7U\2\2\u0098\u009a"+
+ "\3\2\2\2\u0099\u009b\7\"\2\2\u009a\u0099\3\2\2\2\u009b\u009c\3\2\2\2\u009c"+
+ "\u009a\3\2\2\2\u009c\u009d\3\2\2\2\u009d\u009e\3\2\2\2\u009e\u009f\7P"+
+ "\2\2\u009f\u00a0\7Q\2\2\u00a0\u00a2\7V\2\2\u00a1.\3\2\2\2\u00a1/\3\2\2"+
+ "\2\u00a1\61\3\2\2\2\u00a1\62\3\2\2\2\u00a1\64\3\2\2\2\u00a1\66\3\2\2\2"+
+ "\u00a18\3\2\2\2\u00a1;\3\2\2\2\u00a1=\3\2\2\2\u00a1?\3\2\2\2\u00a1J\3"+
+ "\2\2\2\u00a1U\3\2\2\2\u00a1]\3\2\2\2\u00a1e\3\2\2\2\u00a1v\3\2\2\2\u00a1"+
+ "\u0087\3\2\2\2\u00a1\u0089\3\2\2\2\u00a1\u008b\3\2\2\2\u00a1\u0096\3\2"+
+ "\2\2\u00a2\6\3\2\2\2\u00a3\u00a4\7C\2\2\u00a4\u00a5\7P\2\2\u00a5\u00aa"+
+ "\7F\2\2\u00a6\u00a7\7c\2\2\u00a7\u00a8\7p\2\2\u00a8\u00aa\7f\2\2\u00a9"+
+ "\u00a3\3\2\2\2\u00a9\u00a6\3\2\2\2\u00aa\b\3\2\2\2\u00ab\u00ac\7Q\2\2"+
+ "\u00ac\u00b0\7T\2\2\u00ad\u00ae\7q\2\2\u00ae\u00b0\7t\2\2\u00af\u00ab"+
+ "\3\2\2\2\u00af\u00ad\3\2\2\2\u00b0\n\3\2\2\2\u00b1\u00b3\7B\2\2\u00b2"+
+ "\u00b4\n\4\2\2\u00b3\u00b2\3\2\2\2\u00b4\u00b5\3\2\2\2\u00b5\u00b3\3\2"+
+ "\2\2\u00b5\u00b6\3\2\2\2\u00b6\f\3\2\2\2\u00b7\u00bb\5\21\t\2\u00b8\u00bb"+
+ "\5\17\b\2\u00b9\u00bb\5\27\f\2\u00ba\u00b7\3\2\2\2\u00ba\u00b8\3\2\2\2"+
+ "\u00ba\u00b9\3\2\2\2\u00bb\16\3\2\2\2\u00bc\u00c0\5\31\r\2\u00bd\u00c0"+
+ "\5\23\n\2\u00be\u00c0\5\25\13\2\u00bf\u00bc\3\2\2\2\u00bf\u00bd\3\2\2"+
+ "\2\u00bf\u00be\3\2\2\2\u00c0\20\3\2\2\2\u00c1\u00c2\7G\2\2\u00c2\u00c3"+
+ "\7Z\2\2\u00c3\u00c8\7R\2\2\u00c4\u00c5\7g\2\2\u00c5\u00c6\7z\2\2\u00c6"+
+ "\u00c8\7r\2\2\u00c7\u00c1\3\2\2\2\u00c7\u00c4\3\2\2\2\u00c8\u00c9\3\2"+
+ "\2\2\u00c9\u00cb\5#\22\2\u00ca\u00cc\n\5\2\2\u00cb\u00ca\3\2\2\2\u00cc"+
+ "\u00cd\3\2\2\2\u00cd\u00cb\3\2\2\2\u00cd\u00ce\3\2\2\2\u00ce\u00cf\3\2"+
+ "\2\2\u00cf\u00d0\5%\23\2\u00d0\22\3\2\2\2\u00d1\u00d3\7/\2\2\u00d2\u00d1"+
+ "\3\2\2\2\u00d2\u00d3\3\2\2\2\u00d3\u00d4\3\2\2\2\u00d4\u00d7\5\33\16\2"+
+ "\u00d5\u00d6\7\60\2\2\u00d6\u00d8\5\33\16\2\u00d7\u00d5\3\2\2\2\u00d7"+
+ "\u00d8\3\2\2\2\u00d8\24\3\2\2\2\u00d9\u00da\7P\2\2\u00da\u00db\7W\2\2"+
+ "\u00db\u00dc\7N\2\2\u00dc\u00e2\7N\2\2\u00dd\u00de\7p\2\2\u00de\u00df"+
+ "\7w\2\2\u00df\u00e0\7n\2\2\u00e0\u00e2\7n\2\2\u00e1\u00d9\3\2\2\2\u00e1"+
+ "\u00dd\3\2\2\2\u00e2\26\3\2\2\2\u00e3\u00e5\5\37\20\2\u00e4\u00e6\5\17"+
+ "\b\2\u00e5\u00e4\3\2\2\2\u00e5\u00e6\3\2\2\2\u00e6\u00eb\3\2\2\2\u00e7"+
+ "\u00e8\7.\2\2\u00e8\u00ea\5\17\b\2\u00e9\u00e7\3\2\2\2\u00ea\u00ed\3\2"+
+ "\2\2\u00eb\u00e9\3\2\2\2\u00eb\u00ec\3\2\2\2\u00ec\u00ee\3\2\2\2\u00ed"+
+ "\u00eb\3\2\2\2\u00ee\u00ef\5!\21\2\u00ef\30\3\2\2\2\u00f0\u00f1\7$\2\2"+
+ "\u00f1\u00f2\5\35\17\2\u00f2\u00f3\7$\2\2\u00f3\u00f7\3\2\2\2\u00f4\u00f5"+
+ "\7$\2\2\u00f5\u00f7\7$\2\2\u00f6\u00f0\3\2\2\2\u00f6\u00f4\3\2\2\2\u00f7"+
+ "\32\3\2\2\2\u00f8\u00fa\4\62;\2\u00f9\u00f8\3\2\2\2\u00fa\u00fb\3\2\2"+
+ "\2\u00fb\u00f9\3\2\2\2\u00fb\u00fc\3\2\2\2\u00fc\34\3\2\2\2\u00fd\u0101"+
+ "\n\6\2\2\u00fe\u00ff\7^\2\2\u00ff\u0101\7$\2\2\u0100\u00fd\3\2\2\2\u0100"+
+ "\u00fe\3\2\2\2\u0101\u0102\3\2\2\2\u0102\u0100\3\2\2\2\u0102\u0103\3\2"+
+ "\2\2\u0103\36\3\2\2\2\u0104\u0105\7*\2\2\u0105 \3\2\2\2\u0106\u0107\7"+
+ "+\2\2\u0107\"\3\2\2\2\u0108\u0109\7}\2\2\u0109$\3\2\2\2\u010a\u010b\7"+
+ "\177\2\2\u010b&\3\2\2\2\33\2*FQl}\u0091\u009c\u00a1\u00a9\u00af\u00b5"+
+ "\u00ba\u00bf\u00c7\u00cd\u00d2\u00d7\u00e1\u00e5\u00eb\u00f6\u00fb\u0100"+
+ "\u0102\3\b\2\2";
+ public static final ATN _ATN =
+ new ATNDeserializer().deserialize(_serializedATN.toCharArray());
+ static {
+ _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
+ for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
+ _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterLexer.tokens
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterLexer.tokens b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterLexer.tokens
new file mode 100755
index 0000000..5ebca36
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterLexer.tokens
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+WHITESPACE=1
+OP=2
+AND=3
+OR=4
+ID=5
+VALUE=6
+SINGLE_VALUE=7
+EXPR=8
+NUMBER=9
+NULL=10
+SET=11
+DOUBLEQUOTED_STRING=12
+LPAREN=13
+RPAREN=14
+LBRACE=15
+RBRACE=16
+'('=13
+')'=14
+'{'=15
+'}'=16
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterListener.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterListener.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterListener.java
new file mode 100755
index 0000000..1d7cb57
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterListener.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Generated from EagleFilter.g4 by ANTLR 4.5
+package org.apache.eagle.query.antlr.generated;
+
+import org.antlr.v4.runtime.tree.ParseTreeListener;
+
+/**
+ * This interface defines a complete listener for a parse tree produced by
+ * {@link EagleFilterParser}.
+ */
+public interface EagleFilterListener extends ParseTreeListener {
+ /**
+ * Enter a parse tree produced by {@link EagleFilterParser#filter}.
+ * @param ctx the parse tree
+ */
+ void enterFilter(EagleFilterParser.FilterContext ctx);
+ /**
+ * Exit a parse tree produced by {@link EagleFilterParser#filter}.
+ * @param ctx the parse tree
+ */
+ void exitFilter(EagleFilterParser.FilterContext ctx);
+ /**
+ * Enter a parse tree produced by {@link EagleFilterParser#combine}.
+ * @param ctx the parse tree
+ */
+ void enterCombine(EagleFilterParser.CombineContext ctx);
+ /**
+ * Exit a parse tree produced by {@link EagleFilterParser#combine}.
+ * @param ctx the parse tree
+ */
+ void exitCombine(EagleFilterParser.CombineContext ctx);
+ /**
+ * Enter a parse tree produced by {@link EagleFilterParser#equation}.
+ * @param ctx the parse tree
+ */
+ void enterEquation(EagleFilterParser.EquationContext ctx);
+ /**
+ * Exit a parse tree produced by {@link EagleFilterParser#equation}.
+ * @param ctx the parse tree
+ */
+ void exitEquation(EagleFilterParser.EquationContext ctx);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterParser.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterParser.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterParser.java
new file mode 100755
index 0000000..3016bd7
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/antlr/generated/EagleFilterParser.java
@@ -0,0 +1,364 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Generated from EagleFilter.g4 by ANTLR 4.5
+package org.apache.eagle.query.antlr.generated;
+
+import org.antlr.v4.runtime.atn.*;
+import org.antlr.v4.runtime.dfa.DFA;
+import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.tree.*;
+import java.util.List;
+
+@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
+public class EagleFilterParser extends Parser {
+ static { RuntimeMetaData.checkVersion("4.5", RuntimeMetaData.VERSION); }
+
+ protected static final DFA[] _decisionToDFA;
+ protected static final PredictionContextCache _sharedContextCache =
+ new PredictionContextCache();
+ public static final int
+ WHITESPACE=1, OP=2, AND=3, OR=4, ID=5, VALUE=6, SINGLE_VALUE=7, EXPR=8,
+ NUMBER=9, NULL=10, SET=11, DOUBLEQUOTED_STRING=12, LPAREN=13, RPAREN=14,
+ LBRACE=15, RBRACE=16;
+ public static final int
+ RULE_filter = 0, RULE_combine = 1, RULE_equation = 2;
+ public static final String[] ruleNames = {
+ "filter", "combine", "equation"
+ };
+
+ private static final String[] _LITERAL_NAMES = {
+ null, null, null, null, null, null, null, null, null, null, null, null,
+ null, "'('", "')'", "'{'", "'}'"
+ };
+ private static final String[] _SYMBOLIC_NAMES = {
+ null, "WHITESPACE", "OP", "AND", "OR", "ID", "VALUE", "SINGLE_VALUE",
+ "EXPR", "NUMBER", "NULL", "SET", "DOUBLEQUOTED_STRING", "LPAREN", "RPAREN",
+ "LBRACE", "RBRACE"
+ };
+ public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
+
+ /**
+ * @deprecated Use {@link #VOCABULARY} instead.
+ */
+ @Deprecated
+ public static final String[] tokenNames;
+ static {
+ tokenNames = new String[_SYMBOLIC_NAMES.length];
+ for (int i = 0; i < tokenNames.length; i++) {
+ tokenNames[i] = VOCABULARY.getLiteralName(i);
+ if (tokenNames[i] == null) {
+ tokenNames[i] = VOCABULARY.getSymbolicName(i);
+ }
+
+ if (tokenNames[i] == null) {
+ tokenNames[i] = "<INVALID>";
+ }
+ }
+ }
+
+ @Override
+ @Deprecated
+ public String[] getTokenNames() {
+ return tokenNames;
+ }
+
+ @Override
+
+ public Vocabulary getVocabulary() {
+ return VOCABULARY;
+ }
+
+ @Override
+ public String getGrammarFileName() { return "EagleFilter.g4"; }
+
+ @Override
+ public String[] getRuleNames() { return ruleNames; }
+
+ @Override
+ public String getSerializedATN() { return _serializedATN; }
+
+ @Override
+ public ATN getATN() { return _ATN; }
+
+ public EagleFilterParser(TokenStream input) {
+ super(input);
+ _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
+ }
+ public static class FilterContext extends ParserRuleContext {
+ public CombineContext combine() {
+ return getRuleContext(CombineContext.class,0);
+ }
+ public TerminalNode EOF() { return getToken(EagleFilterParser.EOF, 0); }
+ public FilterContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_filter; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof EagleFilterListener ) ((EagleFilterListener)listener).enterFilter(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof EagleFilterListener ) ((EagleFilterListener)listener).exitFilter(this);
+ }
+ }
+
+ public final FilterContext filter() throws RecognitionException {
+ FilterContext _localctx = new FilterContext(_ctx, getState());
+ enterRule(_localctx, 0, RULE_filter);
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(6);
+ combine(0);
+ setState(7);
+ match(EOF);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class CombineContext extends ParserRuleContext {
+ public TerminalNode LPAREN() { return getToken(EagleFilterParser.LPAREN, 0); }
+ public List<CombineContext> combine() {
+ return getRuleContexts(CombineContext.class);
+ }
+ public CombineContext combine(int i) {
+ return getRuleContext(CombineContext.class,i);
+ }
+ public TerminalNode RPAREN() { return getToken(EagleFilterParser.RPAREN, 0); }
+ public EquationContext equation() {
+ return getRuleContext(EquationContext.class,0);
+ }
+ public TerminalNode AND() { return getToken(EagleFilterParser.AND, 0); }
+ public TerminalNode OR() { return getToken(EagleFilterParser.OR, 0); }
+ public CombineContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_combine; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof EagleFilterListener ) ((EagleFilterListener)listener).enterCombine(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof EagleFilterListener ) ((EagleFilterListener)listener).exitCombine(this);
+ }
+ }
+
+ public final CombineContext combine() throws RecognitionException {
+ return combine(0);
+ }
+
+ private CombineContext combine(int _p) throws RecognitionException {
+ ParserRuleContext _parentctx = _ctx;
+ int _parentState = getState();
+ CombineContext _localctx = new CombineContext(_ctx, _parentState);
+ CombineContext _prevctx = _localctx;
+ int _startState = 2;
+ enterRecursionRule(_localctx, 2, RULE_combine, _p);
+ try {
+ int _alt;
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(15);
+ switch (_input.LA(1)) {
+ case LPAREN:
+ {
+ setState(10);
+ match(LPAREN);
+ setState(11);
+ combine(0);
+ setState(12);
+ match(RPAREN);
+ }
+ break;
+ case ID:
+ case VALUE:
+ {
+ setState(14);
+ equation();
+ }
+ break;
+ default:
+ throw new NoViableAltException(this);
+ }
+ _ctx.stop = _input.LT(-1);
+ setState(25);
+ _errHandler.sync(this);
+ _alt = getInterpreter().adaptivePredict(_input,2,_ctx);
+ while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
+ if ( _alt==1 ) {
+ if ( _parseListeners!=null ) triggerExitRuleEvent();
+ _prevctx = _localctx;
+ {
+ setState(23);
+ switch ( getInterpreter().adaptivePredict(_input,1,_ctx) ) {
+ case 1:
+ {
+ _localctx = new CombineContext(_parentctx, _parentState);
+ pushNewRecursionContext(_localctx, _startState, RULE_combine);
+ setState(17);
+ if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)");
+ setState(18);
+ match(AND);
+ setState(19);
+ combine(3);
+ }
+ break;
+ case 2:
+ {
+ _localctx = new CombineContext(_parentctx, _parentState);
+ pushNewRecursionContext(_localctx, _startState, RULE_combine);
+ setState(20);
+ if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)");
+ setState(21);
+ match(OR);
+ setState(22);
+ combine(2);
+ }
+ break;
+ }
+ }
+ }
+ setState(27);
+ _errHandler.sync(this);
+ _alt = getInterpreter().adaptivePredict(_input,2,_ctx);
+ }
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ unrollRecursionContexts(_parentctx);
+ }
+ return _localctx;
+ }
+
+ public static class EquationContext extends ParserRuleContext {
+ public List<TerminalNode> VALUE() { return getTokens(EagleFilterParser.VALUE); }
+ public TerminalNode VALUE(int i) {
+ return getToken(EagleFilterParser.VALUE, i);
+ }
+ public TerminalNode OP() { return getToken(EagleFilterParser.OP, 0); }
+ public TerminalNode ID() { return getToken(EagleFilterParser.ID, 0); }
+ public EquationContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_equation; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof EagleFilterListener ) ((EagleFilterListener)listener).enterEquation(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof EagleFilterListener ) ((EagleFilterListener)listener).exitEquation(this);
+ }
+ }
+
+ public final EquationContext equation() throws RecognitionException {
+ EquationContext _localctx = new EquationContext(_ctx, getState());
+ enterRule(_localctx, 4, RULE_equation);
+ try {
+ setState(34);
+ switch (_input.LA(1)) {
+ case VALUE:
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(28);
+ match(VALUE);
+ setState(29);
+ match(OP);
+ setState(30);
+ match(VALUE);
+ }
+ break;
+ case ID:
+ enterOuterAlt(_localctx, 2);
+ {
+ setState(31);
+ match(ID);
+ setState(32);
+ match(OP);
+ setState(33);
+ match(VALUE);
+ }
+ break;
+ default:
+ throw new NoViableAltException(this);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
+ switch (ruleIndex) {
+ case 1:
+ return combine_sempred((CombineContext)_localctx, predIndex);
+ }
+ return true;
+ }
+ private boolean combine_sempred(CombineContext _localctx, int predIndex) {
+ switch (predIndex) {
+ case 0:
+ return precpred(_ctx, 2);
+ case 1:
+ return precpred(_ctx, 1);
+ }
+ return true;
+ }
+
+ public static final String _serializedATN =
+ "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3\22\'\4\2\t\2\4\3"+
+ "\t\3\4\4\t\4\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\5\3\22\n\3\3\3\3\3\3"+
+ "\3\3\3\3\3\3\3\7\3\32\n\3\f\3\16\3\35\13\3\3\4\3\4\3\4\3\4\3\4\3\4\5\4"+
+ "%\n\4\3\4\2\3\4\5\2\4\6\2\2\'\2\b\3\2\2\2\4\21\3\2\2\2\6$\3\2\2\2\b\t"+
+ "\5\4\3\2\t\n\7\2\2\3\n\3\3\2\2\2\13\f\b\3\1\2\f\r\7\17\2\2\r\16\5\4\3"+
+ "\2\16\17\7\20\2\2\17\22\3\2\2\2\20\22\5\6\4\2\21\13\3\2\2\2\21\20\3\2"+
+ "\2\2\22\33\3\2\2\2\23\24\f\4\2\2\24\25\7\5\2\2\25\32\5\4\3\5\26\27\f\3"+
+ "\2\2\27\30\7\6\2\2\30\32\5\4\3\4\31\23\3\2\2\2\31\26\3\2\2\2\32\35\3\2"+
+ "\2\2\33\31\3\2\2\2\33\34\3\2\2\2\34\5\3\2\2\2\35\33\3\2\2\2\36\37\7\b"+
+ "\2\2\37 \7\4\2\2 %\7\b\2\2!\"\7\7\2\2\"#\7\4\2\2#%\7\b\2\2$\36\3\2\2\2"+
+ "$!\3\2\2\2%\7\3\2\2\2\6\21\31\33$";
+ public static final ATN _ATN =
+ new ATNDeserializer().deserialize(_serializedATN.toCharArray());
+ static {
+ _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
+ for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
+ _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ANDExpression.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ANDExpression.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ANDExpression.java
new file mode 100644
index 0000000..f575e0f
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ANDExpression.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.parser;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ANDExpression {
+ // TODO use Set data structure to dedupe for optimization?
+ private List<AtomicExpression> atomicExpressionList = new ArrayList<AtomicExpression>();
+
+ public List<AtomicExpression> getAtomicExprList() {
+ return atomicExpressionList;
+ }
+
+ public void setAtomicExprList(List<AtomicExpression> list) {
+ this.atomicExpressionList = list;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/AtomicExpression.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/AtomicExpression.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/AtomicExpression.java
new file mode 100755
index 0000000..f831ede
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/AtomicExpression.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.parser;
+
+public class AtomicExpression {
+ private String key;
+ private ComparisonOperator op;
+ private String value;
+ private TokenType keyType;
+ private TokenType valueType;
+
+ public String getKey() {
+ return key;
+ }
+ public void setKey(String key) {
+ this.key = key;
+ }
+ public ComparisonOperator getOp() {
+ return op;
+ }
+ public void setOp(ComparisonOperator op) {
+ this.op = op;
+ }
+ public String getValue() {
+ return value;
+ }
+ public void setValue(String value) {
+ this.value = value;
+ }
+ public String toString(){
+ if(this.valueType == TokenType.STRING){
+ return key + op + "\"" + value + "\"";
+ }else{
+ return key + op + value;
+ }
+ }
+
+ public TokenType getKeyType() {
+ return keyType;
+ }
+
+ public void setKeyType(TokenType keyType) {
+ this.keyType = keyType;
+ }
+
+ public TokenType getValueType() {
+ return valueType;
+ }
+
+ public void setValueType(TokenType type) {
+ this.valueType = type;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ComparisonOperator.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ComparisonOperator.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ComparisonOperator.java
new file mode 100755
index 0000000..3a1be37
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ComparisonOperator.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.parser;
+
+public enum ComparisonOperator {
+ EQUAL("="),
+ LIKE("=~"),
+ IN("IN"),
+ NOT_IN("NOT IN"),
+ LESS("<"),
+ LESS_OR_EQUAL("<="),
+ GREATER(">"),
+ GREATER_OR_EQUAL(">="),
+ NOT_EQUAL("!="),
+ NOT_LIKE("!=~"),
+ CONTAINS("CONTAINS"),
+ NOT_CONTAINS("NOT CONTAINS"),
+ IS("IS"),
+ IS_NOT("IS NOT");
+
+ private final String _op;
+ private ComparisonOperator(String op){
+ _op = op;
+ }
+
+ public String toString(){
+ return _op;
+ }
+
+ public static ComparisonOperator locateOperator(String op){
+ op = op.replaceAll("\\s+"," ");
+ for(ComparisonOperator o : ComparisonOperator.values()){
+ if(op.toUpperCase().equals(o._op)){
+ return o;
+ }
+ }
+ throw new UnsupportedExpressionOperatorException(op);
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleANTLRErrorStrategy.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleANTLRErrorStrategy.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleANTLRErrorStrategy.java
new file mode 100644
index 0000000..e016ea9
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleANTLRErrorStrategy.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.parser;
+
+import org.antlr.v4.runtime.*;
+
+public class EagleANTLRErrorStrategy extends DefaultErrorStrategy {
+ /** Instead of recovering from exception {@code e}, re-throw it wrapped
+ * in a {@link org.antlr.v4.runtime.misc.ParseCancellationException} so it is not caught by the
+ * rule function catches. Use {@link Exception#getCause()} to get the
+ * original {@link org.antlr.v4.runtime.RecognitionException}.
+ */
+ @Override
+ public void recover(Parser recognizer, RecognitionException e) {
+ for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) {
+ context.exception = e;
+ }
+ super.recover(recognizer,e);
+ }
+
+ /** Make sure we don't attempt to recover inline; if the parser
+ * successfully recovers, it won't throw an exception.
+ */
+ @Override
+ public Token recoverInline(Parser recognizer)
+ throws RecognitionException
+ {
+ InputMismatchException e = new InputMismatchException(recognizer);
+ for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) {
+ context.exception = e;
+ }
+ return super.recoverInline(recognizer);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryFilterListenerImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryFilterListenerImpl.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryFilterListenerImpl.java
new file mode 100755
index 0000000..a631e53
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryFilterListenerImpl.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.parser;
+
+import org.apache.eagle.query.antlr.generated.EagleFilterListener;
+import org.apache.eagle.query.antlr.generated.EagleFilterParser;
+import org.antlr.v4.runtime.ParserRuleContext;
+import org.antlr.v4.runtime.tree.ErrorNode;
+import org.antlr.v4.runtime.tree.TerminalNode;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Stack;
+import java.util.regex.Matcher;
+
+public class EagleQueryFilterListenerImpl implements EagleFilterListener{
+ private final static Logger LOG = LoggerFactory.getLogger(EagleQueryFilterListenerImpl.class);
+ private Stack<ORExpression> _stack = new Stack<ORExpression>();
+
+ public ORExpression result(){
+ return _stack.pop();
+ }
+
+ public void enterEquation(EagleFilterParser.EquationContext ctx){
+ }
+
+ public void exitEquation(EagleFilterParser.EquationContext ctx){
+ TerminalNode id = ctx.ID();
+ TerminalNode op = ctx.OP();
+ List<TerminalNode> values = ctx.VALUE();
+ TerminalNode value = values.get(0);
+
+ if(values.size() == 2){
+ // value op value
+ id = values.get(0);
+ value = values.get(1);
+ }
+
+ if(LOG.isDebugEnabled()) LOG.debug("ID:" + id.getText() + ", OP:" + op.getText() + ", VALUE:" + value);
+
+ AtomicExpression kv = new AtomicExpression();
+ kv.setKey(id.getText());
+ kv.setOp(ComparisonOperator.locateOperator(op.getText()));
+
+ try{
+ kv.setValueType(TokenType.locate(value.getText()));
+ }catch (Exception ex){
+ LOG.error("Failed to locate value type for: " + value.getText() + " due to exception: " + ex.getMessage(), ex);
+ }
+
+ try{
+ kv.setKeyType(TokenType.locate(id.getText()));
+ }catch (Exception ex){
+ LOG.error("Failed to locate id type for: " + id.getText() + " due to exception: " + ex.getMessage(), ex);
+ }
+
+// if(id != null){
+ kv.setKey(postProcessNode(id.getText(),kv.getKeyType()));
+// }
+
+// if(value != null){
+ kv.setValue(postProcessNode(value.getText(),kv.getValueType()));
+ // As to List value, it will escape in List parser but not here
+ if(kv.getValueType() != TokenType.LIST) kv.setValue(StringEscapeUtils.unescapeJava(kv.getValue()));
+// }
+
+ // push to stack
+ ORExpression orExpr = new ORExpression();
+ ANDExpression andExpr = new ANDExpression();
+ andExpr.getAtomicExprList().add(kv);
+ orExpr.getANDExprList().add(andExpr);
+ _stack.push(orExpr);
+ }
+
+ private String postProcessNode(String text,TokenType type){
+ int len = text.length();
+ int start=0,end = len;
+ if(text.startsWith("\"")) start=1;
+ if(text.endsWith("\"")) end = len -1;
+ text = text.substring(start, end);
+ if(type == TokenType.EXP){
+ Matcher matcher = TokenConstant.EXP_PATTERN.matcher(text);
+ if(matcher.find()){
+ text = matcher.group(1);
+ }
+ text = text.replace(TokenConstant.ID_PREFIX,TokenConstant.WHITE_SPACE);
+ }
+ return text;
+ }
+
+ public void enterCombine(EagleFilterParser.CombineContext ctx){
+
+ }
+
+ public void exitCombine(EagleFilterParser.CombineContext ctx){
+ int numChild = ctx.getChildCount();
+ if(numChild == 1){
+ if(LOG.isDebugEnabled()) LOG.debug("Only one child, skip ...");
+ return; // does nothing for a combine which has only one equation
+ }
+
+ if((ctx.LPAREN() != null) && (ctx.RPAREN() != null)){
+ if(LOG.isDebugEnabled()) LOG.debug("LPAREN + RPAREN rule matched, skip ...");
+ return; // does nothing for a combine which is within parenthesis
+ }
+ ORExpression orExprRight = _stack.pop();
+ ORExpression orExprLeft = _stack.pop();
+ TerminalNode node = ctx.AND();
+ if(node != null){
+ ORExpression newORExpr = new ORExpression();
+ for(ANDExpression left : orExprLeft.getANDExprList()){
+ for(ANDExpression right : orExprRight.getANDExprList()){
+ ANDExpression tmp = new ANDExpression();
+ tmp.getAtomicExprList().addAll(left.getAtomicExprList());
+ tmp.getAtomicExprList().addAll(right.getAtomicExprList());
+ newORExpr.getANDExprList().add(tmp);
+ }
+ }
+ _stack.push(newORExpr);
+ return;
+ }
+
+ node = ctx.OR();
+ if(node != null){
+ ORExpression newORExpr = new ORExpression();
+ for(ANDExpression andExpr : orExprLeft.getANDExprList()){
+ newORExpr.getANDExprList().add(andExpr);
+ }
+ for(ANDExpression andExpr : orExprRight.getANDExprList()){
+ newORExpr.getANDExprList().add(andExpr);
+ }
+ _stack.push(newORExpr);
+ return;
+ }
+ LOG.warn("Should never come here!");
+ }
+
+ public void enterFilter(EagleFilterParser.FilterContext ctx){
+
+ }
+
+ public void exitFilter(EagleFilterParser.FilterContext ctx){
+ // print all relations (KeyValueFilter AND KeyValueFilter) OR (KeyValueFilter AND KeyValueFilter) OR (KeyValueFilter AND KeyValueFilter)"
+ ORExpression orExpr = _stack.peek();
+ if(LOG.isDebugEnabled()) LOG.debug(orExpr.toString());
+ }
+
+ public void visitTerminal(TerminalNode node){
+
+ }
+ public void visitErrorNode(ErrorNode node){
+
+ }
+ public void enterEveryRule(ParserRuleContext ctx){
+ }
+
+ public void exitEveryRule(ParserRuleContext ctx){
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParseException.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParseException.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParseException.java
new file mode 100755
index 0000000..48fc694
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParseException.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.parser;
+
+public class EagleQueryParseException extends Exception{
+ private static final long serialVersionUID = -8440811651318471641L;
+
+ public EagleQueryParseException(String message){
+ super(message);
+ }
+
+ public EagleQueryParseException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParser.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParser.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParser.java
new file mode 100755
index 0000000..f2315b2
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParser.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.parser;
+
+import org.apache.eagle.query.antlr.generated.EagleFilterLexer;
+import org.apache.eagle.query.antlr.generated.EagleFilterParser;
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EagleQueryParser {
+ private static final Logger LOG = LoggerFactory.getLogger(EagleQueryParser.class);
+ private String _query;
+ public EagleQueryParser(String query){
+ _query = query;
+ }
+
+ public ORExpression parse() throws EagleQueryParseException{
+ try{
+ EagleFilterLexer lexer = new EagleFilterLexer(new ANTLRInputStream(_query));
+ CommonTokenStream tokens = new CommonTokenStream(lexer);
+ tokens.fill();
+ EagleFilterParser p = new EagleFilterParser(tokens);
+ p.setErrorHandler(new EagleANTLRErrorStrategy());
+ p.setBuildParseTree(true);
+ EagleQueryFilterListenerImpl listener = new EagleQueryFilterListenerImpl();
+ p.addParseListener(listener);
+ EagleFilterParser.FilterContext fc = p.filter();
+ if(fc.exception != null){
+ LOG.error("Can not successfully parse the query:" + _query, fc.exception);
+ throw fc.exception;
+ }
+ return listener.result();
+ }catch(Exception ex){
+ LOG.error("Can not successfully parse the query:", ex);
+ throw new EagleQueryParseException("can not successfully parse the query:" + _query);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/LogicalOperator.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/LogicalOperator.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/LogicalOperator.java
new file mode 100644
index 0000000..374186e
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/LogicalOperator.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.parser;
+
+public enum LogicalOperator {
+ AND,
+ OR,
+ NOT
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ORExpression.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ORExpression.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ORExpression.java
new file mode 100644
index 0000000..3a43a6d
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ORExpression.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.parser;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ORExpression {
+ private List<ANDExpression> andExprList = new ArrayList<ANDExpression>();
+
+ public List<ANDExpression> getANDExprList() {
+ return andExprList;
+ }
+
+ public void setANDExprList(List<ANDExpression> list) {
+ this.andExprList = list;
+ }
+
+ public String toString(){
+ StringBuffer sb = new StringBuffer();
+ boolean first = true;
+ for(ANDExpression andRel : andExprList){
+ if(first)
+ first = false;
+ else{
+ sb.append(" ");
+ sb.append(LogicalOperator.OR);
+ sb.append(" ");
+ }
+ sb.append("(");
+ boolean firstAND = true;
+ for(AtomicExpression kv : andRel.getAtomicExprList()){
+ if(firstAND)
+ firstAND = false;
+ else{
+ sb.append(" ");
+ sb.append(LogicalOperator.AND);
+ sb.append(" ");
+ }
+ sb.append(kv);
+ }
+ sb.append(")");
+ }
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/TokenConstant.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/TokenConstant.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/TokenConstant.java
new file mode 100755
index 0000000..f93a63e
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/TokenConstant.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.parser;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public final class TokenConstant {
+ public final static Pattern EXP_PATTERN= Pattern.compile("^EXP\\{(.+)\\}(\\s+AS\\s+)?\\s*(.+)?\\s*$",Pattern.CASE_INSENSITIVE);
+ public final static Pattern STRING_PATTERN= Pattern.compile("^(\"(.*?\n)*.*\")$");
+ public final static Pattern ARRAY_PATTERN= Pattern.compile("^(\\(.*\\))$");
+ public final static Pattern NUMBER_PATTERN= Pattern.compile("^((-|\\+)?\\s*[0-9]+(\\.[0-9]+)?)$");
+ public final static Pattern NULL_PATTERN= Pattern.compile("^(NULL|null)$");
+ public final static Pattern ID_PATTERN= Pattern.compile("^@(.+)$");
+
+ public final static String ID_PREFIX = "@";
+ public final static String WHITE_SPACE = "";
+
+ public static boolean isExpression(String query){
+ if(query == null) return false;
+ Matcher matcher = EXP_PATTERN.matcher(query);
+ return matcher.matches();
+ }
+
+ /**
+ * EXP{ expression } AS alias => expression
+ *
+ * @param expression
+ * @return
+ */
+ public static String parseExpressionContent(String expression){
+ Matcher matcher = EXP_PATTERN.matcher(expression);
+ if(matcher.find()){
+ expression = matcher.group(1);
+ }
+ return expression;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/TokenType.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/TokenType.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/TokenType.java
new file mode 100755
index 0000000..2707c60
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/TokenType.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.parser;
+
+public enum TokenType {
+ EXP, NUMBER, STRING, LIST, NULL,ID;
+
+ public static TokenType locate(String tokenText){
+ String _value = tokenText.trim();
+ if (TokenConstant.EXP_PATTERN.matcher(_value).matches()) {
+ // e.q. "value" with EXP{...}
+ return EXP;
+ }else if(TokenConstant.STRING_PATTERN.matcher(_value).matches()){
+ // e.q. "value" with quotes
+ return STRING;
+ }else if(TokenConstant.ARRAY_PATTERN.matcher(_value).matches()){
+ // e.q. (item1,item2,..)
+ return LIST;
+ }else if(TokenConstant.NUMBER_PATTERN.matcher(_value).matches()){
+ // e.q. 1.32 without quotes
+ return NUMBER;
+ }else if(TokenConstant.NULL_PATTERN.matcher(_value).matches()){
+ // e.q. null or NULL without quotes
+ return NULL;
+ } else if(TokenConstant.ID_PATTERN.matcher(_value).matches()){
+ return ID;
+ }
+ throw new IllegalArgumentException("Can't locate type of value text: "+tokenText);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/UnsupportedExpressionOperatorException.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/UnsupportedExpressionOperatorException.java b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/UnsupportedExpressionOperatorException.java
new file mode 100644
index 0000000..40997c9
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/UnsupportedExpressionOperatorException.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.eagle.query.parser;
+
+public class UnsupportedExpressionOperatorException extends RuntimeException{
+ private static final long serialVersionUID = 565210592983703093L;
+
+ public UnsupportedExpressionOperatorException(String message){
+ super(message);
+ }
+}