diff --git a/README.md b/README.md
index d37ba20..b1abf12 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,48 @@
-# VamdcSqlRequestComparator
-Comparator of VAMDC requests.
+VamdcSqlRequestComparator
+===========
+
+File List
+=======
+
+**antlr-gen/** - generated source code from Grammar
+
+**bin/** - compiled files for IDE
+
+**build.xml** - ant build
+
+**.classpath**
+
+**grammar/** - Grammar definition, lexer, parser and tokens
+
+**lib/** - containes all needed libraries (junit + antlr)
+
+**.project**
+
+**README.md**
+
+**.settings**
+
+**src/** - Source code
+
+
+How to Build/Clean project
+==========
+
+You can build project with apache **ant** command from terminal. Also you can use **Eclipse**/**Intellij Idea** or other IDE.
+
+List of Main Targets
+========
+
+**ant build** - Creates build/ folder. First runs Antlr and generates Lexer,Parser and tokens from grammar. After compiles generated and source code.
+
+**ant build-all** - Creates build/ folder. Compiles generated and source code. Also creates a JAR file (build/jar/VamdcSqlRequestComparator.jar).
+
+**ant clean-all** - Deletes build/ folder.
+
+**ant jar** - Creates jar file -> build/jar/VamdcSqlRequestComparator.jar
+
+**ant doc** - Generates javadoc -> build/doc/
+
+**ant junit** - Runs JUnit Tests.
+
+**ant run -Dreq1="req1" -Dreq2="req2"** - Compares req1 and req2. Shows true/false or grammar error.
\ No newline at end of file
diff --git a/antlr-gen/vamdcsqlcomparator/VamdcSqlRequestBaseListener.java b/antlr-gen/vamdcsqlcomparator/VamdcSqlRequestBaseListener.java
new file mode 100644
index 0000000..754feec
--- /dev/null
+++ b/antlr-gen/vamdcsqlcomparator/VamdcSqlRequestBaseListener.java
@@ -0,0 +1,125 @@
+// Generated from VamdcSqlRequest.g4 by ANTLR 4.5.3
+
+package vamdcsqlcomparator;
+
+
+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 VamdcSqlRequestListener},
+ * which can be extended to create a listener which only needs to handle a subset
+ * of the available methods.
+ */
+public class VamdcSqlRequestBaseListener implements VamdcSqlRequestListener {
+ /**
+ * {@inheritDoc}
+ *
+ *
The default implementation does nothing.
+ */
+ @Override public void enterSelect(VamdcSqlRequestParser.SelectContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitSelect(VamdcSqlRequestParser.SelectContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterExpr(VamdcSqlRequestParser.ExprContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitExpr(VamdcSqlRequestParser.ExprContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterFactor(VamdcSqlRequestParser.FactorContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitFactor(VamdcSqlRequestParser.FactorContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterTerm(VamdcSqlRequestParser.TermContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitTerm(VamdcSqlRequestParser.TermContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterCompexp(VamdcSqlRequestParser.CompexpContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitCompexp(VamdcSqlRequestParser.CompexpContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterList(VamdcSqlRequestParser.ListContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitList(VamdcSqlRequestParser.ListContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterName(VamdcSqlRequestParser.NameContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitName(VamdcSqlRequestParser.NameContext ctx) { }
+
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterEveryRule(ParserRuleContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitEveryRule(ParserRuleContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void visitTerminal(TerminalNode node) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void visitErrorNode(ErrorNode node) { }
+}
\ No newline at end of file
diff --git a/antlr-gen/vamdcsqlcomparator/VamdcSqlRequestLexer.java b/antlr-gen/vamdcsqlcomparator/VamdcSqlRequestLexer.java
new file mode 100644
index 0000000..8bb9292
--- /dev/null
+++ b/antlr-gen/vamdcsqlcomparator/VamdcSqlRequestLexer.java
@@ -0,0 +1,140 @@
+// Generated from VamdcSqlRequest.g4 by ANTLR 4.5.3
+
+package vamdcsqlcomparator;
+
+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 VamdcSqlRequestLexer extends Lexer {
+ static { RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); }
+
+ protected static final DFA[] _decisionToDFA;
+ protected static final PredictionContextCache _sharedContextCache =
+ new PredictionContextCache();
+ public static final int
+ T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
+ T__9=10, BOOLEAN_OP=11, NUM=12, ID=13, WS=14;
+ public static String[] modeNames = {
+ "DEFAULT_MODE"
+ };
+
+ public static final String[] ruleNames = {
+ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
+ "T__9", "BOOLEAN_OP", "NUM", "ID", "WS"
+ };
+
+ private static final String[] _LITERAL_NAMES = {
+ null, "'select'", "'*'", "'all'", "'where'", "'or'", "'and'", "'('", "')'",
+ "','", "'.'"
+ };
+ private static final String[] _SYMBOLIC_NAMES = {
+ null, null, null, null, null, null, null, null, null, null, null, "BOOLEAN_OP",
+ "NUM", "ID", "WS"
+ };
+ 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] = "";
+ }
+ }
+ }
+
+ @Override
+ @Deprecated
+ public String[] getTokenNames() {
+ return tokenNames;
+ }
+
+ @Override
+
+ public Vocabulary getVocabulary() {
+ return VOCABULARY;
+ }
+
+
+ public VamdcSqlRequestLexer(CharStream input) {
+ super(input);
+ _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
+ }
+
+ @Override
+ public String getGrammarFileName() { return "VamdcSqlRequest.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\20\u0086\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\3\2\3\2\3\2\3\2\3\2\3\2\3"+
+ "\2\3\3\3\3\3\4\3\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\7\3\7"+
+ "\3\7\3\7\3\b\3\b\3\t\3\t\3\n\3\n\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\f"+
+ "\3\f\3\f\3\f\3\f\5\fM\n\f\3\r\6\rP\n\r\r\r\16\rQ\3\r\3\r\6\rV\n\r\r\r"+
+ "\16\rW\5\rZ\n\r\3\r\3\r\5\r^\n\r\3\r\6\ra\n\r\r\r\16\rb\5\re\n\r\3\r\3"+
+ "\r\3\r\3\r\5\rk\n\r\3\16\5\16n\n\16\3\16\3\16\7\16r\n\16\f\16\16\16u\13"+
+ "\16\3\16\5\16x\n\16\3\16\3\16\3\16\3\16\5\16~\n\16\3\17\6\17\u0081\n\17"+
+ "\r\17\16\17\u0082\3\17\3\17\2\2\20\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\17\35\20\3\2\7\3\2\62;\4\2GGgg\4\2--//\5\2/"+
+ "/\62;c|\5\2\13\f\17\17\"\"\u0095\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\33\3\2\2\2\2\35\3\2\2\2"+
+ "\3\37\3\2\2\2\5&\3\2\2\2\7(\3\2\2\2\t,\3\2\2\2\13\62\3\2\2\2\r\65\3\2"+
+ "\2\2\179\3\2\2\2\21;\3\2\2\2\23=\3\2\2\2\25?\3\2\2\2\27L\3\2\2\2\31j\3"+
+ "\2\2\2\33}\3\2\2\2\35\u0080\3\2\2\2\37 \7u\2\2 !\7g\2\2!\"\7n\2\2\"#\7"+
+ "g\2\2#$\7e\2\2$%\7v\2\2%\4\3\2\2\2&\'\7,\2\2\'\6\3\2\2\2()\7c\2\2)*\7"+
+ "n\2\2*+\7n\2\2+\b\3\2\2\2,-\7y\2\2-.\7j\2\2./\7g\2\2/\60\7t\2\2\60\61"+
+ "\7g\2\2\61\n\3\2\2\2\62\63\7q\2\2\63\64\7t\2\2\64\f\3\2\2\2\65\66\7c\2"+
+ "\2\66\67\7p\2\2\678\7f\2\28\16\3\2\2\29:\7*\2\2:\20\3\2\2\2;<\7+\2\2<"+
+ "\22\3\2\2\2=>\7.\2\2>\24\3\2\2\2?@\7\60\2\2@\26\3\2\2\2AM\4>@\2BC\7>\2"+
+ "\2CM\7?\2\2DE\7@\2\2EM\7?\2\2FG\7k\2\2GM\7p\2\2HI\7n\2\2IJ\7k\2\2JK\7"+
+ "m\2\2KM\7g\2\2LA\3\2\2\2LB\3\2\2\2LD\3\2\2\2LF\3\2\2\2LH\3\2\2\2M\30\3"+
+ "\2\2\2NP\t\2\2\2ON\3\2\2\2PQ\3\2\2\2QO\3\2\2\2QR\3\2\2\2RY\3\2\2\2SU\7"+
+ "\60\2\2TV\t\2\2\2UT\3\2\2\2VW\3\2\2\2WU\3\2\2\2WX\3\2\2\2XZ\3\2\2\2YS"+
+ "\3\2\2\2YZ\3\2\2\2Zd\3\2\2\2[]\t\3\2\2\\^\t\4\2\2]\\\3\2\2\2]^\3\2\2\2"+
+ "^`\3\2\2\2_a\t\2\2\2`_\3\2\2\2ab\3\2\2\2b`\3\2\2\2bc\3\2\2\2ce\3\2\2\2"+
+ "d[\3\2\2\2de\3\2\2\2ek\3\2\2\2fg\7)\2\2gh\5\31\r\2hi\7)\2\2ik\3\2\2\2"+
+ "jO\3\2\2\2jf\3\2\2\2k\32\3\2\2\2ln\7`\2\2ml\3\2\2\2mn\3\2\2\2no\3\2\2"+
+ "\2os\4c|\2pr\t\5\2\2qp\3\2\2\2ru\3\2\2\2sq\3\2\2\2st\3\2\2\2tw\3\2\2\2"+
+ "us\3\2\2\2vx\7\'\2\2wv\3\2\2\2wx\3\2\2\2x~\3\2\2\2yz\7)\2\2z{\5\33\16"+
+ "\2{|\7)\2\2|~\3\2\2\2}m\3\2\2\2}y\3\2\2\2~\34\3\2\2\2\177\u0081\t\6\2"+
+ "\2\u0080\177\3\2\2\2\u0081\u0082\3\2\2\2\u0082\u0080\3\2\2\2\u0082\u0083"+
+ "\3\2\2\2\u0083\u0084\3\2\2\2\u0084\u0085\b\17\2\2\u0085\36\3\2\2\2\20"+
+ "\2LQWY]bdjmsw}\u0082\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
diff --git a/antlr-gen/vamdcsqlcomparator/VamdcSqlRequestListener.java b/antlr-gen/vamdcsqlcomparator/VamdcSqlRequestListener.java
new file mode 100644
index 0000000..f6aed66
--- /dev/null
+++ b/antlr-gen/vamdcsqlcomparator/VamdcSqlRequestListener.java
@@ -0,0 +1,82 @@
+// Generated from VamdcSqlRequest.g4 by ANTLR 4.5.3
+
+package vamdcsqlcomparator;
+
+import org.antlr.v4.runtime.tree.ParseTreeListener;
+
+/**
+ * This interface defines a complete listener for a parse tree produced by
+ * {@link VamdcSqlRequestParser}.
+ */
+public interface VamdcSqlRequestListener extends ParseTreeListener {
+ /**
+ * Enter a parse tree produced by {@link VamdcSqlRequestParser#select}.
+ * @param ctx the parse tree
+ */
+ void enterSelect(VamdcSqlRequestParser.SelectContext ctx);
+ /**
+ * Exit a parse tree produced by {@link VamdcSqlRequestParser#select}.
+ * @param ctx the parse tree
+ */
+ void exitSelect(VamdcSqlRequestParser.SelectContext ctx);
+ /**
+ * Enter a parse tree produced by {@link VamdcSqlRequestParser#expr}.
+ * @param ctx the parse tree
+ */
+ void enterExpr(VamdcSqlRequestParser.ExprContext ctx);
+ /**
+ * Exit a parse tree produced by {@link VamdcSqlRequestParser#expr}.
+ * @param ctx the parse tree
+ */
+ void exitExpr(VamdcSqlRequestParser.ExprContext ctx);
+ /**
+ * Enter a parse tree produced by {@link VamdcSqlRequestParser#factor}.
+ * @param ctx the parse tree
+ */
+ void enterFactor(VamdcSqlRequestParser.FactorContext ctx);
+ /**
+ * Exit a parse tree produced by {@link VamdcSqlRequestParser#factor}.
+ * @param ctx the parse tree
+ */
+ void exitFactor(VamdcSqlRequestParser.FactorContext ctx);
+ /**
+ * Enter a parse tree produced by {@link VamdcSqlRequestParser#term}.
+ * @param ctx the parse tree
+ */
+ void enterTerm(VamdcSqlRequestParser.TermContext ctx);
+ /**
+ * Exit a parse tree produced by {@link VamdcSqlRequestParser#term}.
+ * @param ctx the parse tree
+ */
+ void exitTerm(VamdcSqlRequestParser.TermContext ctx);
+ /**
+ * Enter a parse tree produced by {@link VamdcSqlRequestParser#compexp}.
+ * @param ctx the parse tree
+ */
+ void enterCompexp(VamdcSqlRequestParser.CompexpContext ctx);
+ /**
+ * Exit a parse tree produced by {@link VamdcSqlRequestParser#compexp}.
+ * @param ctx the parse tree
+ */
+ void exitCompexp(VamdcSqlRequestParser.CompexpContext ctx);
+ /**
+ * Enter a parse tree produced by {@link VamdcSqlRequestParser#list}.
+ * @param ctx the parse tree
+ */
+ void enterList(VamdcSqlRequestParser.ListContext ctx);
+ /**
+ * Exit a parse tree produced by {@link VamdcSqlRequestParser#list}.
+ * @param ctx the parse tree
+ */
+ void exitList(VamdcSqlRequestParser.ListContext ctx);
+ /**
+ * Enter a parse tree produced by {@link VamdcSqlRequestParser#name}.
+ * @param ctx the parse tree
+ */
+ void enterName(VamdcSqlRequestParser.NameContext ctx);
+ /**
+ * Exit a parse tree produced by {@link VamdcSqlRequestParser#name}.
+ * @param ctx the parse tree
+ */
+ void exitName(VamdcSqlRequestParser.NameContext ctx);
+}
\ No newline at end of file
diff --git a/antlr-gen/vamdcsqlcomparator/VamdcSqlRequestParser.java b/antlr-gen/vamdcsqlcomparator/VamdcSqlRequestParser.java
new file mode 100644
index 0000000..58d9cc1
--- /dev/null
+++ b/antlr-gen/vamdcsqlcomparator/VamdcSqlRequestParser.java
@@ -0,0 +1,619 @@
+// Generated from VamdcSqlRequest.g4 by ANTLR 4.5.3
+
+package vamdcsqlcomparator;
+
+import org.antlr.v4.runtime.atn.*;
+import org.antlr.v4.runtime.dfa.DFA;
+import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.misc.*;
+import org.antlr.v4.runtime.tree.*;
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
+public class VamdcSqlRequestParser extends Parser {
+ static { RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); }
+
+ protected static final DFA[] _decisionToDFA;
+ protected static final PredictionContextCache _sharedContextCache =
+ new PredictionContextCache();
+ public static final int
+ T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
+ T__9=10, BOOLEAN_OP=11, NUM=12, ID=13, WS=14;
+ public static final int
+ RULE_select = 0, RULE_expr = 1, RULE_factor = 2, RULE_term = 3, RULE_compexp = 4,
+ RULE_list = 5, RULE_name = 6;
+ public static final String[] ruleNames = {
+ "select", "expr", "factor", "term", "compexp", "list", "name"
+ };
+
+ private static final String[] _LITERAL_NAMES = {
+ null, "'select'", "'*'", "'all'", "'where'", "'or'", "'and'", "'('", "')'",
+ "','", "'.'"
+ };
+ private static final String[] _SYMBOLIC_NAMES = {
+ null, null, null, null, null, null, null, null, null, null, null, "BOOLEAN_OP",
+ "NUM", "ID", "WS"
+ };
+ 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] = "";
+ }
+ }
+ }
+
+ @Override
+ @Deprecated
+ public String[] getTokenNames() {
+ return tokenNames;
+ }
+
+ @Override
+
+ public Vocabulary getVocabulary() {
+ return VOCABULARY;
+ }
+
+ @Override
+ public String getGrammarFileName() { return "VamdcSqlRequest.g4"; }
+
+ @Override
+ public String[] getRuleNames() { return ruleNames; }
+
+ @Override
+ public String getSerializedATN() { return _serializedATN; }
+
+ @Override
+ public ATN getATN() { return _ATN; }
+
+ public VamdcSqlRequestParser(TokenStream input) {
+ super(input);
+ _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
+ }
+ public static class SelectContext extends ParserRuleContext {
+ public ListContext selectList;
+ public Token where;
+ public TerminalNode EOF() { return getToken(VamdcSqlRequestParser.EOF, 0); }
+ public ListContext list() {
+ return getRuleContext(ListContext.class,0);
+ }
+ public ExprContext expr() {
+ return getRuleContext(ExprContext.class,0);
+ }
+ public SelectContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_select; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).enterSelect(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).exitSelect(this);
+ }
+ }
+
+ public final SelectContext select() throws RecognitionException {
+ SelectContext _localctx = new SelectContext(_ctx, getState());
+ enterRule(_localctx, 0, RULE_select);
+ int _la;
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(14);
+ match(T__0);
+ setState(18);
+ switch (_input.LA(1)) {
+ case ID:
+ {
+ setState(15);
+ ((SelectContext)_localctx).selectList = list();
+ }
+ break;
+ case T__1:
+ {
+ setState(16);
+ match(T__1);
+ }
+ break;
+ case T__2:
+ {
+ setState(17);
+ match(T__2);
+ }
+ break;
+ default:
+ throw new NoViableAltException(this);
+ }
+ setState(22);
+ _la = _input.LA(1);
+ if (_la==T__3) {
+ {
+ setState(20);
+ ((SelectContext)_localctx).where = match(T__3);
+ setState(21);
+ expr(0);
+ }
+ }
+
+ setState(24);
+ match(EOF);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class ExprContext extends ParserRuleContext {
+ public FactorContext factor() {
+ return getRuleContext(FactorContext.class,0);
+ }
+ public ExprContext expr() {
+ return getRuleContext(ExprContext.class,0);
+ }
+ public ExprContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_expr; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).enterExpr(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).exitExpr(this);
+ }
+ }
+
+ public final ExprContext expr() throws RecognitionException {
+ return expr(0);
+ }
+
+ private ExprContext expr(int _p) throws RecognitionException {
+ ParserRuleContext _parentctx = _ctx;
+ int _parentState = getState();
+ ExprContext _localctx = new ExprContext(_ctx, _parentState);
+ ExprContext _prevctx = _localctx;
+ int _startState = 2;
+ enterRecursionRule(_localctx, 2, RULE_expr, _p);
+ try {
+ int _alt;
+ enterOuterAlt(_localctx, 1);
+ {
+ {
+ setState(27);
+ factor();
+ }
+ _ctx.stop = _input.LT(-1);
+ setState(34);
+ _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;
+ {
+ {
+ _localctx = new ExprContext(_parentctx, _parentState);
+ pushNewRecursionContext(_localctx, _startState, RULE_expr);
+ setState(29);
+ if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)");
+ setState(30);
+ match(T__4);
+ setState(31);
+ factor();
+ }
+ }
+ }
+ setState(36);
+ _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 FactorContext extends ParserRuleContext {
+ public TermContext term() {
+ return getRuleContext(TermContext.class,0);
+ }
+ public FactorContext factor() {
+ return getRuleContext(FactorContext.class,0);
+ }
+ public FactorContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_factor; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).enterFactor(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).exitFactor(this);
+ }
+ }
+
+ public final FactorContext factor() throws RecognitionException {
+ FactorContext _localctx = new FactorContext(_ctx, getState());
+ enterRule(_localctx, 4, RULE_factor);
+ try {
+ setState(42);
+ _errHandler.sync(this);
+ switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) {
+ case 1:
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(37);
+ term();
+ setState(38);
+ match(T__5);
+ setState(39);
+ factor();
+ }
+ break;
+ case 2:
+ enterOuterAlt(_localctx, 2);
+ {
+ setState(41);
+ term();
+ }
+ break;
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class TermContext extends ParserRuleContext {
+ public NameContext name() {
+ return getRuleContext(NameContext.class,0);
+ }
+ public CompexpContext compexp() {
+ return getRuleContext(CompexpContext.class,0);
+ }
+ public ExprContext expr() {
+ return getRuleContext(ExprContext.class,0);
+ }
+ public TermContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_term; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).enterTerm(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).exitTerm(this);
+ }
+ }
+
+ public final TermContext term() throws RecognitionException {
+ TermContext _localctx = new TermContext(_ctx, getState());
+ enterRule(_localctx, 6, RULE_term);
+ try {
+ setState(50);
+ _errHandler.sync(this);
+ switch ( getInterpreter().adaptivePredict(_input,4,_ctx) ) {
+ case 1:
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(44);
+ name();
+ }
+ break;
+ case 2:
+ enterOuterAlt(_localctx, 2);
+ {
+ setState(45);
+ compexp();
+ }
+ break;
+ case 3:
+ enterOuterAlt(_localctx, 3);
+ {
+ setState(46);
+ match(T__6);
+ setState(47);
+ expr(0);
+ setState(48);
+ match(T__7);
+ }
+ break;
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class CompexpContext extends ParserRuleContext {
+ public NameContext left;
+ public NameContext right;
+ public TerminalNode BOOLEAN_OP() { return getToken(VamdcSqlRequestParser.BOOLEAN_OP, 0); }
+ public List name() {
+ return getRuleContexts(NameContext.class);
+ }
+ public NameContext name(int i) {
+ return getRuleContext(NameContext.class,i);
+ }
+ public CompexpContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_compexp; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).enterCompexp(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).exitCompexp(this);
+ }
+ }
+
+ public final CompexpContext compexp() throws RecognitionException {
+ CompexpContext _localctx = new CompexpContext(_ctx, getState());
+ enterRule(_localctx, 8, RULE_compexp);
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(52);
+ ((CompexpContext)_localctx).left = name();
+ setState(53);
+ match(BOOLEAN_OP);
+ setState(54);
+ ((CompexpContext)_localctx).right = name();
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class ListContext extends ParserRuleContext {
+ public TerminalNode ID() { return getToken(VamdcSqlRequestParser.ID, 0); }
+ public ListContext list() {
+ return getRuleContext(ListContext.class,0);
+ }
+ public ListContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_list; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).enterList(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).exitList(this);
+ }
+ }
+
+ public final ListContext list() throws RecognitionException {
+ ListContext _localctx = new ListContext(_ctx, getState());
+ enterRule(_localctx, 10, RULE_list);
+ try {
+ setState(60);
+ _errHandler.sync(this);
+ switch ( getInterpreter().adaptivePredict(_input,5,_ctx) ) {
+ case 1:
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(56);
+ match(ID);
+ }
+ break;
+ case 2:
+ enterOuterAlt(_localctx, 2);
+ {
+ {
+ setState(57);
+ match(ID);
+ setState(58);
+ match(T__8);
+ setState(59);
+ list();
+ }
+ }
+ break;
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class NameContext extends ParserRuleContext {
+ public TerminalNode ID() { return getToken(VamdcSqlRequestParser.ID, 0); }
+ public TerminalNode NUM() { return getToken(VamdcSqlRequestParser.NUM, 0); }
+ public NameContext name() {
+ return getRuleContext(NameContext.class,0);
+ }
+ public NameContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_name; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).enterName(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).exitName(this);
+ }
+ }
+
+ public final NameContext name() throws RecognitionException {
+ NameContext _localctx = new NameContext(_ctx, getState());
+ enterRule(_localctx, 12, RULE_name);
+ try {
+ setState(74);
+ _errHandler.sync(this);
+ switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) {
+ case 1:
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(62);
+ match(ID);
+ }
+ break;
+ case 2:
+ enterOuterAlt(_localctx, 2);
+ {
+ setState(63);
+ match(NUM);
+ }
+ break;
+ case 3:
+ enterOuterAlt(_localctx, 3);
+ {
+ {
+ setState(64);
+ match(ID);
+ setState(65);
+ match(T__9);
+ setState(66);
+ name();
+ }
+ }
+ break;
+ case 4:
+ enterOuterAlt(_localctx, 4);
+ {
+ setState(67);
+ match(T__6);
+ setState(68);
+ name();
+ setState(69);
+ match(T__7);
+ }
+ break;
+ case 5:
+ enterOuterAlt(_localctx, 5);
+ {
+ {
+ setState(71);
+ match(ID);
+ setState(72);
+ match(T__8);
+ setState(73);
+ name();
+ }
+ }
+ break;
+ }
+ }
+ 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 expr_sempred((ExprContext)_localctx, predIndex);
+ }
+ return true;
+ }
+ private boolean expr_sempred(ExprContext _localctx, int predIndex) {
+ switch (predIndex) {
+ case 0:
+ return precpred(_ctx, 1);
+ }
+ return true;
+ }
+
+ public static final String _serializedATN =
+ "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3\20O\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\3\2\3\2\3\2\3\2\5\2\25\n\2"+
+ "\3\2\3\2\5\2\31\n\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\7\3#\n\3\f\3\16\3"+
+ "&\13\3\3\4\3\4\3\4\3\4\3\4\5\4-\n\4\3\5\3\5\3\5\3\5\3\5\3\5\5\5\65\n\5"+
+ "\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\5\7?\n\7\3\b\3\b\3\b\3\b\3\b\3\b\3\b"+
+ "\3\b\3\b\3\b\3\b\3\b\5\bM\n\b\3\b\2\3\4\t\2\4\6\b\n\f\16\2\2S\2\20\3\2"+
+ "\2\2\4\34\3\2\2\2\6,\3\2\2\2\b\64\3\2\2\2\n\66\3\2\2\2\f>\3\2\2\2\16L"+
+ "\3\2\2\2\20\24\7\3\2\2\21\25\5\f\7\2\22\25\7\4\2\2\23\25\7\5\2\2\24\21"+
+ "\3\2\2\2\24\22\3\2\2\2\24\23\3\2\2\2\25\30\3\2\2\2\26\27\7\6\2\2\27\31"+
+ "\5\4\3\2\30\26\3\2\2\2\30\31\3\2\2\2\31\32\3\2\2\2\32\33\7\2\2\3\33\3"+
+ "\3\2\2\2\34\35\b\3\1\2\35\36\5\6\4\2\36$\3\2\2\2\37 \f\3\2\2 !\7\7\2\2"+
+ "!#\5\6\4\2\"\37\3\2\2\2#&\3\2\2\2$\"\3\2\2\2$%\3\2\2\2%\5\3\2\2\2&$\3"+
+ "\2\2\2\'(\5\b\5\2()\7\b\2\2)*\5\6\4\2*-\3\2\2\2+-\5\b\5\2,\'\3\2\2\2,"+
+ "+\3\2\2\2-\7\3\2\2\2.\65\5\16\b\2/\65\5\n\6\2\60\61\7\t\2\2\61\62\5\4"+
+ "\3\2\62\63\7\n\2\2\63\65\3\2\2\2\64.\3\2\2\2\64/\3\2\2\2\64\60\3\2\2\2"+
+ "\65\t\3\2\2\2\66\67\5\16\b\2\678\7\r\2\289\5\16\b\29\13\3\2\2\2:?\7\17"+
+ "\2\2;<\7\17\2\2<=\7\13\2\2=?\5\f\7\2>:\3\2\2\2>;\3\2\2\2?\r\3\2\2\2@M"+
+ "\7\17\2\2AM\7\16\2\2BC\7\17\2\2CD\7\f\2\2DM\5\16\b\2EF\7\t\2\2FG\5\16"+
+ "\b\2GH\7\n\2\2HM\3\2\2\2IJ\7\17\2\2JK\7\13\2\2KM\5\16\b\2L@\3\2\2\2LA"+
+ "\3\2\2\2LB\3\2\2\2LE\3\2\2\2LI\3\2\2\2M\17\3\2\2\2\t\24\30$,\64>L";
+ 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
diff --git a/bin/vamdcsqlcomparator/Main.class b/bin/vamdcsqlcomparator/Main.class
new file mode 100644
index 0000000..81ea4f1
Binary files /dev/null and b/bin/vamdcsqlcomparator/Main.class differ
diff --git a/bin/vamdcsqlcomparator/ThrowingErrorListener.class b/bin/vamdcsqlcomparator/ThrowingErrorListener.class
new file mode 100644
index 0000000..1f0c22b
Binary files /dev/null and b/bin/vamdcsqlcomparator/ThrowingErrorListener.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcRequestNode.class b/bin/vamdcsqlcomparator/VamdcRequestNode.class
new file mode 100644
index 0000000..a153255
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcRequestNode.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcRequestTree.class b/bin/vamdcsqlcomparator/VamdcRequestTree.class
new file mode 100644
index 0000000..7855b40
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcRequestTree.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcSqlRequestBaseListener.class b/bin/vamdcsqlcomparator/VamdcSqlRequestBaseListener.class
new file mode 100644
index 0000000..b3ad85a
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcSqlRequestBaseListener.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcSqlRequestComparator.class b/bin/vamdcsqlcomparator/VamdcSqlRequestComparator.class
new file mode 100644
index 0000000..44562f3
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcSqlRequestComparator.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcSqlRequestLexer.class b/bin/vamdcsqlcomparator/VamdcSqlRequestLexer.class
new file mode 100644
index 0000000..54a357f
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcSqlRequestLexer.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcSqlRequestListener.class b/bin/vamdcsqlcomparator/VamdcSqlRequestListener.class
new file mode 100644
index 0000000..2a5e595
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcSqlRequestListener.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcSqlRequestParser$CompexpContext.class b/bin/vamdcsqlcomparator/VamdcSqlRequestParser$CompexpContext.class
new file mode 100644
index 0000000..10bca29
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcSqlRequestParser$CompexpContext.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcSqlRequestParser$ExprContext.class b/bin/vamdcsqlcomparator/VamdcSqlRequestParser$ExprContext.class
new file mode 100644
index 0000000..e119102
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcSqlRequestParser$ExprContext.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcSqlRequestParser$FactorContext.class b/bin/vamdcsqlcomparator/VamdcSqlRequestParser$FactorContext.class
new file mode 100644
index 0000000..f504472
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcSqlRequestParser$FactorContext.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcSqlRequestParser$ListContext.class b/bin/vamdcsqlcomparator/VamdcSqlRequestParser$ListContext.class
new file mode 100644
index 0000000..8fe9423
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcSqlRequestParser$ListContext.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcSqlRequestParser$NameContext.class b/bin/vamdcsqlcomparator/VamdcSqlRequestParser$NameContext.class
new file mode 100644
index 0000000..4a275f1
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcSqlRequestParser$NameContext.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcSqlRequestParser$SelectContext.class b/bin/vamdcsqlcomparator/VamdcSqlRequestParser$SelectContext.class
new file mode 100644
index 0000000..c9a003e
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcSqlRequestParser$SelectContext.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcSqlRequestParser$TermContext.class b/bin/vamdcsqlcomparator/VamdcSqlRequestParser$TermContext.class
new file mode 100644
index 0000000..f25c79d
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcSqlRequestParser$TermContext.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcSqlRequestParser.class b/bin/vamdcsqlcomparator/VamdcSqlRequestParser.class
new file mode 100644
index 0000000..fa67b5f
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcSqlRequestParser.class differ
diff --git a/bin/vamdcsqlcomparator/VamdcSqlRequestWalker.class b/bin/vamdcsqlcomparator/VamdcSqlRequestWalker.class
new file mode 100644
index 0000000..b5c49f8
Binary files /dev/null and b/bin/vamdcsqlcomparator/VamdcSqlRequestWalker.class differ
diff --git a/bin/vamdcsqlcomparator/tests/AssociativityTest.class b/bin/vamdcsqlcomparator/tests/AssociativityTest.class
new file mode 100644
index 0000000..9e817f4
Binary files /dev/null and b/bin/vamdcsqlcomparator/tests/AssociativityTest.class differ
diff --git a/bin/vamdcsqlcomparator/tests/CommutativityTest.class b/bin/vamdcsqlcomparator/tests/CommutativityTest.class
new file mode 100644
index 0000000..f9b954f
Binary files /dev/null and b/bin/vamdcsqlcomparator/tests/CommutativityTest.class differ
diff --git a/bin/vamdcsqlcomparator/tests/GeneralTest.class b/bin/vamdcsqlcomparator/tests/GeneralTest.class
new file mode 100644
index 0000000..d193ac1
Binary files /dev/null and b/bin/vamdcsqlcomparator/tests/GeneralTest.class differ
diff --git a/bin/vamdcsqlcomparator/tests/GrammarTest.class b/bin/vamdcsqlcomparator/tests/GrammarTest.class
new file mode 100644
index 0000000..feaae5d
Binary files /dev/null and b/bin/vamdcsqlcomparator/tests/GrammarTest.class differ
diff --git a/bin/vamdcsqlcomparator/tests/SelectColumnTest.class b/bin/vamdcsqlcomparator/tests/SelectColumnTest.class
new file mode 100644
index 0000000..684017f
Binary files /dev/null and b/bin/vamdcsqlcomparator/tests/SelectColumnTest.class differ
diff --git a/build.xml b/build.xml
new file mode 100644
index 0000000..b96ff21
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,130 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/grammar/VamdcSqlRequest.g4 b/grammar/VamdcSqlRequest.g4
new file mode 100644
index 0000000..4714b1b
--- /dev/null
+++ b/grammar/VamdcSqlRequest.g4
@@ -0,0 +1,40 @@
+// Define a grammar called VamdcSqlRequest
+grammar VamdcSqlRequest;
+
+
+@header {
+package vamdcsqlcomparator;
+}
+
+
+// Define Select command
+select : 'select' (selectList = list | '*' | 'all' ) (where = 'where' expr)? EOF;
+
+
+// Define expression
+expr : factor | expr 'or' factor;
+factor : term 'and' factor | term;
+term : name | compexp | '(' expr ')';
+compexp : left = name BOOLEAN_OP right = name;
+
+
+// List of boolean operations
+BOOLEAN_OP
+ : '<'
+ | '>'
+ | '='
+ | '<='
+ | '>='
+ | 'in'
+ | 'like'
+ ;
+
+
+list : ID | (ID ',' list);
+name : ID | NUM | (ID '.' name) | '(' name ')' | (ID ',' name);
+
+
+NUM : [0-9]+ ('.' [0-9]+)? ([eE] [+-]? [0-9]+)? | '\'' NUM '\'';
+ID : ('^')?('a'..'z')('a'..'z'|'0'..'9'|'-')*('%')? | '\'' ID '\'';
+WS : [ \t\r\n]+ -> skip;
+
diff --git a/grammar/VamdcSqlRequest.tokens b/grammar/VamdcSqlRequest.tokens
new file mode 100644
index 0000000..e658b52
--- /dev/null
+++ b/grammar/VamdcSqlRequest.tokens
@@ -0,0 +1,24 @@
+T__0=1
+T__1=2
+T__2=3
+T__3=4
+T__4=5
+T__5=6
+T__6=7
+T__7=8
+T__8=9
+T__9=10
+BOOLEAN_OP=11
+NUM=12
+ID=13
+WS=14
+'select'=1
+'*'=2
+'all'=3
+'where'=4
+'or'=5
+'and'=6
+'('=7
+')'=8
+','=9
+'.'=10
diff --git a/grammar/VamdcSqlRequestBaseListener.java b/grammar/VamdcSqlRequestBaseListener.java
new file mode 100644
index 0000000..754feec
--- /dev/null
+++ b/grammar/VamdcSqlRequestBaseListener.java
@@ -0,0 +1,125 @@
+// Generated from VamdcSqlRequest.g4 by ANTLR 4.5.3
+
+package vamdcsqlcomparator;
+
+
+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 VamdcSqlRequestListener},
+ * which can be extended to create a listener which only needs to handle a subset
+ * of the available methods.
+ */
+public class VamdcSqlRequestBaseListener implements VamdcSqlRequestListener {
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterSelect(VamdcSqlRequestParser.SelectContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitSelect(VamdcSqlRequestParser.SelectContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterExpr(VamdcSqlRequestParser.ExprContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitExpr(VamdcSqlRequestParser.ExprContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterFactor(VamdcSqlRequestParser.FactorContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitFactor(VamdcSqlRequestParser.FactorContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterTerm(VamdcSqlRequestParser.TermContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitTerm(VamdcSqlRequestParser.TermContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterCompexp(VamdcSqlRequestParser.CompexpContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitCompexp(VamdcSqlRequestParser.CompexpContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterList(VamdcSqlRequestParser.ListContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitList(VamdcSqlRequestParser.ListContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterName(VamdcSqlRequestParser.NameContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitName(VamdcSqlRequestParser.NameContext ctx) { }
+
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterEveryRule(ParserRuleContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitEveryRule(ParserRuleContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void visitTerminal(TerminalNode node) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void visitErrorNode(ErrorNode node) { }
+}
\ No newline at end of file
diff --git a/grammar/VamdcSqlRequestLexer.java b/grammar/VamdcSqlRequestLexer.java
new file mode 100644
index 0000000..8bb9292
--- /dev/null
+++ b/grammar/VamdcSqlRequestLexer.java
@@ -0,0 +1,140 @@
+// Generated from VamdcSqlRequest.g4 by ANTLR 4.5.3
+
+package vamdcsqlcomparator;
+
+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 VamdcSqlRequestLexer extends Lexer {
+ static { RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); }
+
+ protected static final DFA[] _decisionToDFA;
+ protected static final PredictionContextCache _sharedContextCache =
+ new PredictionContextCache();
+ public static final int
+ T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
+ T__9=10, BOOLEAN_OP=11, NUM=12, ID=13, WS=14;
+ public static String[] modeNames = {
+ "DEFAULT_MODE"
+ };
+
+ public static final String[] ruleNames = {
+ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
+ "T__9", "BOOLEAN_OP", "NUM", "ID", "WS"
+ };
+
+ private static final String[] _LITERAL_NAMES = {
+ null, "'select'", "'*'", "'all'", "'where'", "'or'", "'and'", "'('", "')'",
+ "','", "'.'"
+ };
+ private static final String[] _SYMBOLIC_NAMES = {
+ null, null, null, null, null, null, null, null, null, null, null, "BOOLEAN_OP",
+ "NUM", "ID", "WS"
+ };
+ 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] = "";
+ }
+ }
+ }
+
+ @Override
+ @Deprecated
+ public String[] getTokenNames() {
+ return tokenNames;
+ }
+
+ @Override
+
+ public Vocabulary getVocabulary() {
+ return VOCABULARY;
+ }
+
+
+ public VamdcSqlRequestLexer(CharStream input) {
+ super(input);
+ _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
+ }
+
+ @Override
+ public String getGrammarFileName() { return "VamdcSqlRequest.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\20\u0086\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\3\2\3\2\3\2\3\2\3\2\3\2\3"+
+ "\2\3\3\3\3\3\4\3\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\7\3\7"+
+ "\3\7\3\7\3\b\3\b\3\t\3\t\3\n\3\n\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\f"+
+ "\3\f\3\f\3\f\3\f\5\fM\n\f\3\r\6\rP\n\r\r\r\16\rQ\3\r\3\r\6\rV\n\r\r\r"+
+ "\16\rW\5\rZ\n\r\3\r\3\r\5\r^\n\r\3\r\6\ra\n\r\r\r\16\rb\5\re\n\r\3\r\3"+
+ "\r\3\r\3\r\5\rk\n\r\3\16\5\16n\n\16\3\16\3\16\7\16r\n\16\f\16\16\16u\13"+
+ "\16\3\16\5\16x\n\16\3\16\3\16\3\16\3\16\5\16~\n\16\3\17\6\17\u0081\n\17"+
+ "\r\17\16\17\u0082\3\17\3\17\2\2\20\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\17\35\20\3\2\7\3\2\62;\4\2GGgg\4\2--//\5\2/"+
+ "/\62;c|\5\2\13\f\17\17\"\"\u0095\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\33\3\2\2\2\2\35\3\2\2\2"+
+ "\3\37\3\2\2\2\5&\3\2\2\2\7(\3\2\2\2\t,\3\2\2\2\13\62\3\2\2\2\r\65\3\2"+
+ "\2\2\179\3\2\2\2\21;\3\2\2\2\23=\3\2\2\2\25?\3\2\2\2\27L\3\2\2\2\31j\3"+
+ "\2\2\2\33}\3\2\2\2\35\u0080\3\2\2\2\37 \7u\2\2 !\7g\2\2!\"\7n\2\2\"#\7"+
+ "g\2\2#$\7e\2\2$%\7v\2\2%\4\3\2\2\2&\'\7,\2\2\'\6\3\2\2\2()\7c\2\2)*\7"+
+ "n\2\2*+\7n\2\2+\b\3\2\2\2,-\7y\2\2-.\7j\2\2./\7g\2\2/\60\7t\2\2\60\61"+
+ "\7g\2\2\61\n\3\2\2\2\62\63\7q\2\2\63\64\7t\2\2\64\f\3\2\2\2\65\66\7c\2"+
+ "\2\66\67\7p\2\2\678\7f\2\28\16\3\2\2\29:\7*\2\2:\20\3\2\2\2;<\7+\2\2<"+
+ "\22\3\2\2\2=>\7.\2\2>\24\3\2\2\2?@\7\60\2\2@\26\3\2\2\2AM\4>@\2BC\7>\2"+
+ "\2CM\7?\2\2DE\7@\2\2EM\7?\2\2FG\7k\2\2GM\7p\2\2HI\7n\2\2IJ\7k\2\2JK\7"+
+ "m\2\2KM\7g\2\2LA\3\2\2\2LB\3\2\2\2LD\3\2\2\2LF\3\2\2\2LH\3\2\2\2M\30\3"+
+ "\2\2\2NP\t\2\2\2ON\3\2\2\2PQ\3\2\2\2QO\3\2\2\2QR\3\2\2\2RY\3\2\2\2SU\7"+
+ "\60\2\2TV\t\2\2\2UT\3\2\2\2VW\3\2\2\2WU\3\2\2\2WX\3\2\2\2XZ\3\2\2\2YS"+
+ "\3\2\2\2YZ\3\2\2\2Zd\3\2\2\2[]\t\3\2\2\\^\t\4\2\2]\\\3\2\2\2]^\3\2\2\2"+
+ "^`\3\2\2\2_a\t\2\2\2`_\3\2\2\2ab\3\2\2\2b`\3\2\2\2bc\3\2\2\2ce\3\2\2\2"+
+ "d[\3\2\2\2de\3\2\2\2ek\3\2\2\2fg\7)\2\2gh\5\31\r\2hi\7)\2\2ik\3\2\2\2"+
+ "jO\3\2\2\2jf\3\2\2\2k\32\3\2\2\2ln\7`\2\2ml\3\2\2\2mn\3\2\2\2no\3\2\2"+
+ "\2os\4c|\2pr\t\5\2\2qp\3\2\2\2ru\3\2\2\2sq\3\2\2\2st\3\2\2\2tw\3\2\2\2"+
+ "us\3\2\2\2vx\7\'\2\2wv\3\2\2\2wx\3\2\2\2x~\3\2\2\2yz\7)\2\2z{\5\33\16"+
+ "\2{|\7)\2\2|~\3\2\2\2}m\3\2\2\2}y\3\2\2\2~\34\3\2\2\2\177\u0081\t\6\2"+
+ "\2\u0080\177\3\2\2\2\u0081\u0082\3\2\2\2\u0082\u0080\3\2\2\2\u0082\u0083"+
+ "\3\2\2\2\u0083\u0084\3\2\2\2\u0084\u0085\b\17\2\2\u0085\36\3\2\2\2\20"+
+ "\2LQWY]bdjmsw}\u0082\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
diff --git a/grammar/VamdcSqlRequestLexer.tokens b/grammar/VamdcSqlRequestLexer.tokens
new file mode 100644
index 0000000..e658b52
--- /dev/null
+++ b/grammar/VamdcSqlRequestLexer.tokens
@@ -0,0 +1,24 @@
+T__0=1
+T__1=2
+T__2=3
+T__3=4
+T__4=5
+T__5=6
+T__6=7
+T__7=8
+T__8=9
+T__9=10
+BOOLEAN_OP=11
+NUM=12
+ID=13
+WS=14
+'select'=1
+'*'=2
+'all'=3
+'where'=4
+'or'=5
+'and'=6
+'('=7
+')'=8
+','=9
+'.'=10
diff --git a/grammar/VamdcSqlRequestListener.java b/grammar/VamdcSqlRequestListener.java
new file mode 100644
index 0000000..f6aed66
--- /dev/null
+++ b/grammar/VamdcSqlRequestListener.java
@@ -0,0 +1,82 @@
+// Generated from VamdcSqlRequest.g4 by ANTLR 4.5.3
+
+package vamdcsqlcomparator;
+
+import org.antlr.v4.runtime.tree.ParseTreeListener;
+
+/**
+ * This interface defines a complete listener for a parse tree produced by
+ * {@link VamdcSqlRequestParser}.
+ */
+public interface VamdcSqlRequestListener extends ParseTreeListener {
+ /**
+ * Enter a parse tree produced by {@link VamdcSqlRequestParser#select}.
+ * @param ctx the parse tree
+ */
+ void enterSelect(VamdcSqlRequestParser.SelectContext ctx);
+ /**
+ * Exit a parse tree produced by {@link VamdcSqlRequestParser#select}.
+ * @param ctx the parse tree
+ */
+ void exitSelect(VamdcSqlRequestParser.SelectContext ctx);
+ /**
+ * Enter a parse tree produced by {@link VamdcSqlRequestParser#expr}.
+ * @param ctx the parse tree
+ */
+ void enterExpr(VamdcSqlRequestParser.ExprContext ctx);
+ /**
+ * Exit a parse tree produced by {@link VamdcSqlRequestParser#expr}.
+ * @param ctx the parse tree
+ */
+ void exitExpr(VamdcSqlRequestParser.ExprContext ctx);
+ /**
+ * Enter a parse tree produced by {@link VamdcSqlRequestParser#factor}.
+ * @param ctx the parse tree
+ */
+ void enterFactor(VamdcSqlRequestParser.FactorContext ctx);
+ /**
+ * Exit a parse tree produced by {@link VamdcSqlRequestParser#factor}.
+ * @param ctx the parse tree
+ */
+ void exitFactor(VamdcSqlRequestParser.FactorContext ctx);
+ /**
+ * Enter a parse tree produced by {@link VamdcSqlRequestParser#term}.
+ * @param ctx the parse tree
+ */
+ void enterTerm(VamdcSqlRequestParser.TermContext ctx);
+ /**
+ * Exit a parse tree produced by {@link VamdcSqlRequestParser#term}.
+ * @param ctx the parse tree
+ */
+ void exitTerm(VamdcSqlRequestParser.TermContext ctx);
+ /**
+ * Enter a parse tree produced by {@link VamdcSqlRequestParser#compexp}.
+ * @param ctx the parse tree
+ */
+ void enterCompexp(VamdcSqlRequestParser.CompexpContext ctx);
+ /**
+ * Exit a parse tree produced by {@link VamdcSqlRequestParser#compexp}.
+ * @param ctx the parse tree
+ */
+ void exitCompexp(VamdcSqlRequestParser.CompexpContext ctx);
+ /**
+ * Enter a parse tree produced by {@link VamdcSqlRequestParser#list}.
+ * @param ctx the parse tree
+ */
+ void enterList(VamdcSqlRequestParser.ListContext ctx);
+ /**
+ * Exit a parse tree produced by {@link VamdcSqlRequestParser#list}.
+ * @param ctx the parse tree
+ */
+ void exitList(VamdcSqlRequestParser.ListContext ctx);
+ /**
+ * Enter a parse tree produced by {@link VamdcSqlRequestParser#name}.
+ * @param ctx the parse tree
+ */
+ void enterName(VamdcSqlRequestParser.NameContext ctx);
+ /**
+ * Exit a parse tree produced by {@link VamdcSqlRequestParser#name}.
+ * @param ctx the parse tree
+ */
+ void exitName(VamdcSqlRequestParser.NameContext ctx);
+}
\ No newline at end of file
diff --git a/grammar/VamdcSqlRequestParser.java b/grammar/VamdcSqlRequestParser.java
new file mode 100644
index 0000000..58d9cc1
--- /dev/null
+++ b/grammar/VamdcSqlRequestParser.java
@@ -0,0 +1,619 @@
+// Generated from VamdcSqlRequest.g4 by ANTLR 4.5.3
+
+package vamdcsqlcomparator;
+
+import org.antlr.v4.runtime.atn.*;
+import org.antlr.v4.runtime.dfa.DFA;
+import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.misc.*;
+import org.antlr.v4.runtime.tree.*;
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
+public class VamdcSqlRequestParser extends Parser {
+ static { RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); }
+
+ protected static final DFA[] _decisionToDFA;
+ protected static final PredictionContextCache _sharedContextCache =
+ new PredictionContextCache();
+ public static final int
+ T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
+ T__9=10, BOOLEAN_OP=11, NUM=12, ID=13, WS=14;
+ public static final int
+ RULE_select = 0, RULE_expr = 1, RULE_factor = 2, RULE_term = 3, RULE_compexp = 4,
+ RULE_list = 5, RULE_name = 6;
+ public static final String[] ruleNames = {
+ "select", "expr", "factor", "term", "compexp", "list", "name"
+ };
+
+ private static final String[] _LITERAL_NAMES = {
+ null, "'select'", "'*'", "'all'", "'where'", "'or'", "'and'", "'('", "')'",
+ "','", "'.'"
+ };
+ private static final String[] _SYMBOLIC_NAMES = {
+ null, null, null, null, null, null, null, null, null, null, null, "BOOLEAN_OP",
+ "NUM", "ID", "WS"
+ };
+ 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] = "";
+ }
+ }
+ }
+
+ @Override
+ @Deprecated
+ public String[] getTokenNames() {
+ return tokenNames;
+ }
+
+ @Override
+
+ public Vocabulary getVocabulary() {
+ return VOCABULARY;
+ }
+
+ @Override
+ public String getGrammarFileName() { return "VamdcSqlRequest.g4"; }
+
+ @Override
+ public String[] getRuleNames() { return ruleNames; }
+
+ @Override
+ public String getSerializedATN() { return _serializedATN; }
+
+ @Override
+ public ATN getATN() { return _ATN; }
+
+ public VamdcSqlRequestParser(TokenStream input) {
+ super(input);
+ _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
+ }
+ public static class SelectContext extends ParserRuleContext {
+ public ListContext selectList;
+ public Token where;
+ public TerminalNode EOF() { return getToken(VamdcSqlRequestParser.EOF, 0); }
+ public ListContext list() {
+ return getRuleContext(ListContext.class,0);
+ }
+ public ExprContext expr() {
+ return getRuleContext(ExprContext.class,0);
+ }
+ public SelectContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_select; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).enterSelect(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).exitSelect(this);
+ }
+ }
+
+ public final SelectContext select() throws RecognitionException {
+ SelectContext _localctx = new SelectContext(_ctx, getState());
+ enterRule(_localctx, 0, RULE_select);
+ int _la;
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(14);
+ match(T__0);
+ setState(18);
+ switch (_input.LA(1)) {
+ case ID:
+ {
+ setState(15);
+ ((SelectContext)_localctx).selectList = list();
+ }
+ break;
+ case T__1:
+ {
+ setState(16);
+ match(T__1);
+ }
+ break;
+ case T__2:
+ {
+ setState(17);
+ match(T__2);
+ }
+ break;
+ default:
+ throw new NoViableAltException(this);
+ }
+ setState(22);
+ _la = _input.LA(1);
+ if (_la==T__3) {
+ {
+ setState(20);
+ ((SelectContext)_localctx).where = match(T__3);
+ setState(21);
+ expr(0);
+ }
+ }
+
+ setState(24);
+ match(EOF);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class ExprContext extends ParserRuleContext {
+ public FactorContext factor() {
+ return getRuleContext(FactorContext.class,0);
+ }
+ public ExprContext expr() {
+ return getRuleContext(ExprContext.class,0);
+ }
+ public ExprContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_expr; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).enterExpr(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).exitExpr(this);
+ }
+ }
+
+ public final ExprContext expr() throws RecognitionException {
+ return expr(0);
+ }
+
+ private ExprContext expr(int _p) throws RecognitionException {
+ ParserRuleContext _parentctx = _ctx;
+ int _parentState = getState();
+ ExprContext _localctx = new ExprContext(_ctx, _parentState);
+ ExprContext _prevctx = _localctx;
+ int _startState = 2;
+ enterRecursionRule(_localctx, 2, RULE_expr, _p);
+ try {
+ int _alt;
+ enterOuterAlt(_localctx, 1);
+ {
+ {
+ setState(27);
+ factor();
+ }
+ _ctx.stop = _input.LT(-1);
+ setState(34);
+ _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;
+ {
+ {
+ _localctx = new ExprContext(_parentctx, _parentState);
+ pushNewRecursionContext(_localctx, _startState, RULE_expr);
+ setState(29);
+ if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)");
+ setState(30);
+ match(T__4);
+ setState(31);
+ factor();
+ }
+ }
+ }
+ setState(36);
+ _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 FactorContext extends ParserRuleContext {
+ public TermContext term() {
+ return getRuleContext(TermContext.class,0);
+ }
+ public FactorContext factor() {
+ return getRuleContext(FactorContext.class,0);
+ }
+ public FactorContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_factor; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).enterFactor(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).exitFactor(this);
+ }
+ }
+
+ public final FactorContext factor() throws RecognitionException {
+ FactorContext _localctx = new FactorContext(_ctx, getState());
+ enterRule(_localctx, 4, RULE_factor);
+ try {
+ setState(42);
+ _errHandler.sync(this);
+ switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) {
+ case 1:
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(37);
+ term();
+ setState(38);
+ match(T__5);
+ setState(39);
+ factor();
+ }
+ break;
+ case 2:
+ enterOuterAlt(_localctx, 2);
+ {
+ setState(41);
+ term();
+ }
+ break;
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class TermContext extends ParserRuleContext {
+ public NameContext name() {
+ return getRuleContext(NameContext.class,0);
+ }
+ public CompexpContext compexp() {
+ return getRuleContext(CompexpContext.class,0);
+ }
+ public ExprContext expr() {
+ return getRuleContext(ExprContext.class,0);
+ }
+ public TermContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_term; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).enterTerm(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).exitTerm(this);
+ }
+ }
+
+ public final TermContext term() throws RecognitionException {
+ TermContext _localctx = new TermContext(_ctx, getState());
+ enterRule(_localctx, 6, RULE_term);
+ try {
+ setState(50);
+ _errHandler.sync(this);
+ switch ( getInterpreter().adaptivePredict(_input,4,_ctx) ) {
+ case 1:
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(44);
+ name();
+ }
+ break;
+ case 2:
+ enterOuterAlt(_localctx, 2);
+ {
+ setState(45);
+ compexp();
+ }
+ break;
+ case 3:
+ enterOuterAlt(_localctx, 3);
+ {
+ setState(46);
+ match(T__6);
+ setState(47);
+ expr(0);
+ setState(48);
+ match(T__7);
+ }
+ break;
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class CompexpContext extends ParserRuleContext {
+ public NameContext left;
+ public NameContext right;
+ public TerminalNode BOOLEAN_OP() { return getToken(VamdcSqlRequestParser.BOOLEAN_OP, 0); }
+ public List name() {
+ return getRuleContexts(NameContext.class);
+ }
+ public NameContext name(int i) {
+ return getRuleContext(NameContext.class,i);
+ }
+ public CompexpContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_compexp; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).enterCompexp(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).exitCompexp(this);
+ }
+ }
+
+ public final CompexpContext compexp() throws RecognitionException {
+ CompexpContext _localctx = new CompexpContext(_ctx, getState());
+ enterRule(_localctx, 8, RULE_compexp);
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(52);
+ ((CompexpContext)_localctx).left = name();
+ setState(53);
+ match(BOOLEAN_OP);
+ setState(54);
+ ((CompexpContext)_localctx).right = name();
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class ListContext extends ParserRuleContext {
+ public TerminalNode ID() { return getToken(VamdcSqlRequestParser.ID, 0); }
+ public ListContext list() {
+ return getRuleContext(ListContext.class,0);
+ }
+ public ListContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_list; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).enterList(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).exitList(this);
+ }
+ }
+
+ public final ListContext list() throws RecognitionException {
+ ListContext _localctx = new ListContext(_ctx, getState());
+ enterRule(_localctx, 10, RULE_list);
+ try {
+ setState(60);
+ _errHandler.sync(this);
+ switch ( getInterpreter().adaptivePredict(_input,5,_ctx) ) {
+ case 1:
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(56);
+ match(ID);
+ }
+ break;
+ case 2:
+ enterOuterAlt(_localctx, 2);
+ {
+ {
+ setState(57);
+ match(ID);
+ setState(58);
+ match(T__8);
+ setState(59);
+ list();
+ }
+ }
+ break;
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class NameContext extends ParserRuleContext {
+ public TerminalNode ID() { return getToken(VamdcSqlRequestParser.ID, 0); }
+ public TerminalNode NUM() { return getToken(VamdcSqlRequestParser.NUM, 0); }
+ public NameContext name() {
+ return getRuleContext(NameContext.class,0);
+ }
+ public NameContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_name; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).enterName(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof VamdcSqlRequestListener ) ((VamdcSqlRequestListener)listener).exitName(this);
+ }
+ }
+
+ public final NameContext name() throws RecognitionException {
+ NameContext _localctx = new NameContext(_ctx, getState());
+ enterRule(_localctx, 12, RULE_name);
+ try {
+ setState(74);
+ _errHandler.sync(this);
+ switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) {
+ case 1:
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(62);
+ match(ID);
+ }
+ break;
+ case 2:
+ enterOuterAlt(_localctx, 2);
+ {
+ setState(63);
+ match(NUM);
+ }
+ break;
+ case 3:
+ enterOuterAlt(_localctx, 3);
+ {
+ {
+ setState(64);
+ match(ID);
+ setState(65);
+ match(T__9);
+ setState(66);
+ name();
+ }
+ }
+ break;
+ case 4:
+ enterOuterAlt(_localctx, 4);
+ {
+ setState(67);
+ match(T__6);
+ setState(68);
+ name();
+ setState(69);
+ match(T__7);
+ }
+ break;
+ case 5:
+ enterOuterAlt(_localctx, 5);
+ {
+ {
+ setState(71);
+ match(ID);
+ setState(72);
+ match(T__8);
+ setState(73);
+ name();
+ }
+ }
+ break;
+ }
+ }
+ 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 expr_sempred((ExprContext)_localctx, predIndex);
+ }
+ return true;
+ }
+ private boolean expr_sempred(ExprContext _localctx, int predIndex) {
+ switch (predIndex) {
+ case 0:
+ return precpred(_ctx, 1);
+ }
+ return true;
+ }
+
+ public static final String _serializedATN =
+ "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3\20O\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\3\2\3\2\3\2\3\2\5\2\25\n\2"+
+ "\3\2\3\2\5\2\31\n\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\7\3#\n\3\f\3\16\3"+
+ "&\13\3\3\4\3\4\3\4\3\4\3\4\5\4-\n\4\3\5\3\5\3\5\3\5\3\5\3\5\5\5\65\n\5"+
+ "\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\5\7?\n\7\3\b\3\b\3\b\3\b\3\b\3\b\3\b"+
+ "\3\b\3\b\3\b\3\b\3\b\5\bM\n\b\3\b\2\3\4\t\2\4\6\b\n\f\16\2\2S\2\20\3\2"+
+ "\2\2\4\34\3\2\2\2\6,\3\2\2\2\b\64\3\2\2\2\n\66\3\2\2\2\f>\3\2\2\2\16L"+
+ "\3\2\2\2\20\24\7\3\2\2\21\25\5\f\7\2\22\25\7\4\2\2\23\25\7\5\2\2\24\21"+
+ "\3\2\2\2\24\22\3\2\2\2\24\23\3\2\2\2\25\30\3\2\2\2\26\27\7\6\2\2\27\31"+
+ "\5\4\3\2\30\26\3\2\2\2\30\31\3\2\2\2\31\32\3\2\2\2\32\33\7\2\2\3\33\3"+
+ "\3\2\2\2\34\35\b\3\1\2\35\36\5\6\4\2\36$\3\2\2\2\37 \f\3\2\2 !\7\7\2\2"+
+ "!#\5\6\4\2\"\37\3\2\2\2#&\3\2\2\2$\"\3\2\2\2$%\3\2\2\2%\5\3\2\2\2&$\3"+
+ "\2\2\2\'(\5\b\5\2()\7\b\2\2)*\5\6\4\2*-\3\2\2\2+-\5\b\5\2,\'\3\2\2\2,"+
+ "+\3\2\2\2-\7\3\2\2\2.\65\5\16\b\2/\65\5\n\6\2\60\61\7\t\2\2\61\62\5\4"+
+ "\3\2\62\63\7\n\2\2\63\65\3\2\2\2\64.\3\2\2\2\64/\3\2\2\2\64\60\3\2\2\2"+
+ "\65\t\3\2\2\2\66\67\5\16\b\2\678\7\r\2\289\5\16\b\29\13\3\2\2\2:?\7\17"+
+ "\2\2;<\7\17\2\2<=\7\13\2\2=?\5\f\7\2>:\3\2\2\2>;\3\2\2\2?\r\3\2\2\2@M"+
+ "\7\17\2\2AM\7\16\2\2BC\7\17\2\2CD\7\f\2\2DM\5\16\b\2EF\7\t\2\2FG\5\16"+
+ "\b\2GH\7\n\2\2HM\3\2\2\2IJ\7\17\2\2JK\7\13\2\2KM\5\16\b\2L@\3\2\2\2LA"+
+ "\3\2\2\2LB\3\2\2\2LE\3\2\2\2LI\3\2\2\2M\17\3\2\2\2\t\24\30$,\64>L";
+ 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
diff --git a/lib/antlr-4.5.3-complete.jar b/lib/antlr-4.5.3-complete.jar
new file mode 100644
index 0000000..8203e15
Binary files /dev/null and b/lib/antlr-4.5.3-complete.jar differ
diff --git a/lib/hamcrest-core-1.3.jar b/lib/hamcrest-core-1.3.jar
new file mode 100644
index 0000000..9d5fe16
Binary files /dev/null and b/lib/hamcrest-core-1.3.jar differ
diff --git a/lib/junit-4.12.jar b/lib/junit-4.12.jar
new file mode 100644
index 0000000..3a7fc26
Binary files /dev/null and b/lib/junit-4.12.jar differ
diff --git a/src/vamdcsqlcomparator/Main.java b/src/vamdcsqlcomparator/Main.java
new file mode 100644
index 0000000..2df0f31
--- /dev/null
+++ b/src/vamdcsqlcomparator/Main.java
@@ -0,0 +1,49 @@
+package vamdcsqlcomparator;
+
+import org.antlr.v4.runtime.misc.ParseCancellationException;
+
+public class Main {
+
+
+ public static void main(String args[]) {
+
+ // two sql requests
+ //String req1 = args[0];
+ //String req2 = args[1];
+
+
+
+ // VamdcSqlRequestComparator.compare --> throws ParseCancellationException
+ /*
+ try{
+ System.out.println(VamdcSqlRequestComparator.compare(req1,req2));
+ }catch(ParseCancellationException ex){
+ //ex.printStackTrace();
+ System.out.println(ex.getMessage());
+ }catch (Exception ex) {
+ ex.printStackTrace();
+ //System.out.println(ex.getMessage());
+ }
+ */
+
+
+ String req = "select f1,f2,f3 where RadTransWavelength<=5.6380000000000000E3 and RadTransWavelength<=56000000000 and InchiKey='LBVWYGNGGJURHQ-UHFFFAOYSA-N' or a<1";
+
+
+ try{
+ System.out.println(VamdcSqlRequestComparator.canonicalForm(req));
+ }catch(ParseCancellationException ex){
+ //ex.printStackTrace();
+ System.out.println(ex.getMessage());
+ }catch (Exception ex) {
+ ex.printStackTrace();
+ //System.out.println(ex.getMessage());
+ }
+
+ }
+
+}
+
+
+
+
diff --git a/src/vamdcsqlcomparator/ThrowingErrorListener.java b/src/vamdcsqlcomparator/ThrowingErrorListener.java
new file mode 100644
index 0000000..82b288f
--- /dev/null
+++ b/src/vamdcsqlcomparator/ThrowingErrorListener.java
@@ -0,0 +1,33 @@
+/**
+ * Created by Levan Loria on 15/09/16.
+ */
+
+package vamdcsqlcomparator;
+
+import org.antlr.v4.runtime.BaseErrorListener;
+import org.antlr.v4.runtime.RecognitionException;
+import org.antlr.v4.runtime.Recognizer;
+import org.antlr.v4.runtime.misc.ParseCancellationException;
+
+/**
+ * This class changes the default behavior of syntax error handling.
+ */
+public class ThrowingErrorListener extends BaseErrorListener{
+
+ /**
+ * Instance of ThrowingErrorListener class.
+ */
+ public static final ThrowingErrorListener instance = new ThrowingErrorListener();
+
+
+ /**
+ * Redefines syntaxError function and throws ParseCancellationException instead of getting error message.
+ * @throws ParseCancellationException Cancellation of parsing, after syntax error occurred.
+ */
+ @Override
+ public void syntaxError(Recognizer,?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) throws ParseCancellationException {
+ throw new ParseCancellationException("line" + line + ":" + charPositionInLine + " " + msg);
+ }
+
+
+}
diff --git a/src/vamdcsqlcomparator/VamdcRequestNode.java b/src/vamdcsqlcomparator/VamdcRequestNode.java
new file mode 100644
index 0000000..72209b4
--- /dev/null
+++ b/src/vamdcsqlcomparator/VamdcRequestNode.java
@@ -0,0 +1,80 @@
+/**
+ * Created by Levan Loria on 14/09/16.
+ */
+
+package vamdcsqlcomparator;
+
+
+/**
+ * This class is a node of the binary tree.
+ */
+public class VamdcRequestNode {
+
+ private String value;
+ private VamdcRequestNode left;
+ private VamdcRequestNode right;
+ private int nbrChild;
+ private int nbrAndOrChild;
+
+
+
+ public VamdcRequestNode(){
+
+ }
+
+ public VamdcRequestNode(String value){
+ this.value = value;
+ this.nbrChild = 0;
+ this.nbrAndOrChild = 0;
+ }
+
+
+ public VamdcRequestNode(String value,VamdcRequestNode left, VamdcRequestNode right){
+ this.value = value;
+ this.left = left;
+ this.right = right;
+ this.nbrChild = 0;
+ this.nbrAndOrChild = 0;
+ }
+
+ public VamdcRequestNode getLeft() {
+ return left;
+ }
+
+ public void setLeft(VamdcRequestNode left) {
+ this.left = left;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public VamdcRequestNode getRight() {
+ return right;
+ }
+
+ public void setRight(VamdcRequestNode right) {
+ this.right = right;
+ }
+
+ public int getNbrAndOrChild() {
+ return nbrAndOrChild;
+ }
+
+ public void setNbrAndOrChild(int nbrAndOrChild) {
+ this.nbrAndOrChild = nbrAndOrChild;
+ }
+
+ public int getNbrChild() {
+ return nbrChild;
+ }
+
+ public void setNbrChild(int nbrChild) {
+ this.nbrChild = nbrChild;
+ }
+
+}
diff --git a/src/vamdcsqlcomparator/VamdcRequestTree.java b/src/vamdcsqlcomparator/VamdcRequestTree.java
new file mode 100644
index 0000000..51842ef
--- /dev/null
+++ b/src/vamdcsqlcomparator/VamdcRequestTree.java
@@ -0,0 +1,370 @@
+/**
+ * Created by Levan Loria on 14/09/16.
+ */
+
+package vamdcsqlcomparator;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * This class is an implementation of almost binary tree.
+ */
+public class VamdcRequestTree {
+
+ /**
+ * Root of the tree.
+ */
+ private VamdcRequestNode root;
+
+ /**
+ *
+ */
+ private List columnList;
+
+
+ public VamdcRequestTree(){
+ columnList = new ArrayList();
+ }
+
+
+ /**
+ * Adding column to list.
+ * @param column Column to add.
+ */
+ public void addColumnList(String column){
+
+ this.columnList.add(column);
+
+ }
+
+
+
+ /**
+ * Adds new node to root.
+ * @param node Node to add.
+ */
+ public void addNode(VamdcRequestNode node){
+
+
+
+ if(this.root == null){
+ this.root = node;
+ return;
+ }
+
+
+
+ VamdcRequestNode current = root;
+ VamdcRequestNode parent = null;
+
+ //System.out.println(current.getValue());
+ while(true) {
+
+ parent = current;
+
+
+ if (current.getLeft() == null) {
+
+ current.setLeft(node);
+
+ if(node.getValue().equals("and") || node.getValue().equals("or")){
+ parent.setNbrChild(parent.getNbrChild() + 1);
+ parent.setNbrAndOrChild(parent.getNbrAndOrChild() + 1);
+ }else{
+ parent.setNbrChild(parent.getNbrChild() + 1);
+ }
+
+ return;
+
+ } else {
+
+
+ if(!current.getLeft().getValue().equals("and") && !current.getLeft().getValue().equals("or")){
+ current = current.getRight();
+
+ if(current == null){
+ parent.setRight(node);
+
+
+ if(node.getValue().equals("and") || node.getValue().equals("or")){
+ parent.setNbrChild(parent.getNbrChild() + 1);
+ parent.setNbrAndOrChild(parent.getNbrAndOrChild() + 1);
+ }else{
+ parent.setNbrChild(parent.getNbrChild() + 1);
+ }
+
+ return;
+ }
+
+ if(node.getValue().equals("and") || node.getValue().equals("or")){
+ parent.setNbrChild(parent.getNbrChild() + 1);
+ parent.setNbrAndOrChild(parent.getNbrAndOrChild() + 1);
+ }else{
+ parent.setNbrChild(parent.getNbrChild() + 1);
+ }
+
+
+
+ }else{
+
+
+ //if left part is full, new node will be added to the right sub-tree
+
+ if((current.getLeft().getNbrAndOrChild() + 1) * 2 == current.getLeft().getNbrChild()) {
+ current = current.getRight();
+
+ if(current == null){
+ parent.setRight(node);
+
+ if(node.getValue().equals("and") || node.getValue().equals("or")){
+ parent.setNbrChild(parent.getNbrChild() + 1);
+ parent.setNbrAndOrChild(parent.getNbrAndOrChild() + 1);
+ }else{
+ parent.setNbrChild(parent.getNbrChild() + 1);
+ }
+
+ return;
+ }
+
+ if(node.getValue().equals("and") || node.getValue().equals("or")){
+ parent.setNbrChild(parent.getNbrChild() + 1);
+ parent.setNbrAndOrChild(parent.getNbrAndOrChild() + 1);
+ }else{
+ parent.setNbrChild(parent.getNbrChild() + 1);
+ }
+
+ }else{ // if left in not full, new node will be added to the left sub-tree
+
+ current = current.getLeft();
+
+ if(node.getValue().equals("and") || node.getValue().equals("or")){
+ parent.setNbrChild(parent.getNbrChild() + 1);
+ parent.setNbrAndOrChild(parent.getNbrAndOrChild() + 1);
+ }else{
+ parent.setNbrChild(parent.getNbrChild() + 1);
+ }
+
+ }
+
+
+ }
+
+
+
+ }
+
+ }
+
+ }
+
+
+
+
+ /**
+ * Function applies distributive property to node.
+ * @param node Node to apply distributive property.
+ * @return VamdcRequestNode
+ */
+ public VamdcRequestNode distributivity(VamdcRequestNode node){
+
+
+ if(isLeaf(node)) return node;
+
+ if(node.getValue().equals("or")){
+ node.setLeft(distributivity(node.getLeft()));
+ node.setRight(distributivity(node.getRight()));
+ return node;
+ }
+
+ if(node.getValue().equals("and")){
+
+
+ if(node.getLeft().getValue().equals("or")){
+
+ VamdcRequestNode tmpNode = new VamdcRequestNode();
+
+ tmpNode.setValue("or");
+ tmpNode.setLeft(new VamdcRequestNode());
+ tmpNode.setRight(new VamdcRequestNode());
+
+
+ tmpNode.getLeft().setValue("and");
+ tmpNode.getLeft().setLeft(distributivity(node.getLeft().getLeft()));
+ tmpNode.getLeft().setRight(distributivity(node.getRight()));
+
+ tmpNode.getRight().setValue("and");
+ tmpNode.getRight().setLeft(distributivity(node.getLeft().getRight()));
+ tmpNode.getRight().setRight(distributivity(node.getRight()));
+
+
+ node.setValue(tmpNode.getValue());
+ node.setLeft(tmpNode.getLeft());
+ node.setRight(tmpNode.getRight());
+ node.setLeft(distributivity(node.getLeft()));
+ node.setRight(distributivity(node.getRight()));
+
+
+ }else if(node.getRight().getValue().equals("or")){
+
+ VamdcRequestNode tmpNode = new VamdcRequestNode();
+
+ tmpNode.setValue("or");
+ tmpNode.setLeft(new VamdcRequestNode());
+ tmpNode.setRight(new VamdcRequestNode());
+
+ tmpNode.getLeft().setValue("and");
+ tmpNode.getLeft().setLeft(distributivity(node.getRight().getLeft()));
+ tmpNode.getLeft().setRight(distributivity(node.getLeft()));
+
+ tmpNode.getRight().setValue("and");
+ tmpNode.getRight().setLeft(distributivity(node.getRight().getRight()));
+ tmpNode.getRight().setRight(distributivity(node.getLeft()));
+
+
+ node.setValue(tmpNode.getValue());
+ node.setLeft(tmpNode.getLeft());
+ node.setRight(tmpNode.getRight());
+ node.setLeft(distributivity(node.getLeft()));
+ node.setRight(distributivity(node.getRight()));
+
+
+ }else {
+ node.setLeft(distributivity(node.getLeft()));
+ node.setRight(distributivity(node.getRight()));
+
+ if(node.getLeft().getValue().equals("or") || node.getRight().getValue().equals("or")){
+ return distributivity(node);
+ }
+ }
+
+ }
+
+ return node;
+ }
+
+
+ /**
+ * Generates list of boolean expressions. (expressions are separated by 'OR').
+ * @param node Generates list of boolean expressions from node.
+ * @return List
+ */
+ public List generateOrElements(VamdcRequestNode node){
+
+ List list;
+
+ if(isLeaf(node)){
+ list = new ArrayList();
+ list.add(node.getValue());
+
+ return list;
+ }
+
+
+ if(node.getValue().equals("or")){
+ List list1 = generateOrElements(node.getLeft());
+ List list2 = generateOrElements(node.getRight());
+
+
+ list = new ArrayList();
+ list.addAll(list1);
+ list.addAll(list2);
+
+
+ }else{
+
+ list = new ArrayList();
+ String multString = "";
+
+ List listMult = mult(node);
+ Collections.sort(listMult);
+
+
+ for(int i=0;i mult(VamdcRequestNode node){
+
+ List list;
+
+ if(isLeaf(node)){
+
+ list = new ArrayList();
+ list.add(node.getValue());
+
+ return list;
+
+ }else{
+
+ list = new ArrayList();
+
+ list.addAll(mult(node.getLeft()));
+ list.addAll(mult(node.getRight()));
+
+ }
+
+ return list;
+ }
+
+
+
+
+ /**
+ * Checks if node is an operation and/or.
+ * @param node Checks if node is an operation ('AND' / 'OR').
+ * @return boolean
+ */
+ public boolean isOperation(VamdcRequestNode node){
+
+ if(node.getValue().equals("and") || node.getValue().equals("or")){
+ return true;
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Checks if node is a leaf.
+ * @param node Checks if node is a leaf.
+ * @return boolean
+ */
+ public boolean isLeaf(VamdcRequestNode node){
+
+ if(node.getLeft() == null) return true;
+
+ return false;
+ }
+
+
+ public VamdcRequestNode getRoot(){
+ return this.root;
+ }
+
+ public List getColumnList(){
+ return this.columnList;
+ }
+
+}
diff --git a/src/vamdcsqlcomparator/VamdcSqlRequestComparator.java b/src/vamdcsqlcomparator/VamdcSqlRequestComparator.java
new file mode 100644
index 0000000..94f5a7c
--- /dev/null
+++ b/src/vamdcsqlcomparator/VamdcSqlRequestComparator.java
@@ -0,0 +1,268 @@
+package vamdcsqlcomparator;
+/**
+ * Created by Levan Loria on 14/09/16.
+ */
+
+
+import java.util.Collections;
+import java.util.List;
+
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.misc.ParseCancellationException;
+import org.antlr.v4.runtime.tree.ParseTree;
+import org.antlr.v4.runtime.tree.ParseTreeWalker;
+
+
+
+/**
+ * This class contains only one static method, which compares two VAMDC SQL requests.
+ */
+public class VamdcSqlRequestComparator {
+
+ /**
+ * Compares two sql requests.
+ * @param req1 First Sql request to compare.
+ * @param req2 Second Sql request to compare.
+ * @return boolean Returns true if the comparator founds that requests are equal.
+ * @throws ParseCancellationException Cancellation of parsing, after syntax error occurred.
+ * @throws Exception Other exception.
+ */
+ public static boolean compare(String req1, String req2) throws ParseCancellationException,Exception {
+
+
+ String request1 = req1.replace('\n',' ').toLowerCase();
+ String request2 = req2.replace('\n',' ').toLowerCase();
+
+
+
+
+ ANTLRInputStream stream;
+ VamdcSqlRequestLexer lexer;
+ CommonTokenStream tokens;
+ VamdcSqlRequestParser parser;
+ ParseTree tree;
+ ParseTreeWalker walker;
+ VamdcSqlRequestWalker parserWalker;
+
+
+
+ VamdcRequestTree requestTree1 = new VamdcRequestTree();
+ VamdcRequestTree requestTree2 = new VamdcRequestTree();
+ VamdcRequestNode root1 = new VamdcRequestNode();
+ VamdcRequestNode root2 = new VamdcRequestNode();
+
+ /* --------------------------------- First request ------------------------------------------------------------- */
+
+ try{
+ stream = new ANTLRInputStream(request1);
+ lexer = new VamdcSqlRequestLexer(stream);
+ lexer.removeErrorListeners();
+ lexer.addErrorListener(ThrowingErrorListener.instance);
+ tokens = new CommonTokenStream(lexer);
+ parser = new VamdcSqlRequestParser(tokens);
+ parser.removeErrorListeners();
+ parser.addErrorListener(ThrowingErrorListener.instance);
+ tree = parser.select(); // parsing select
+ walker = new ParseTreeWalker();
+ parserWalker = new VamdcSqlRequestWalker();
+ walker.walk(parserWalker,tree); // constructing VamdcRequestTree
+
+ requestTree1 = parserWalker.getTree();
+ root1 = requestTree1.getRoot();
+ }catch(Exception ex){
+ throw ex;
+ }
+
+
+ /* --------------------------------- Second request ------------------------------------------------------------- */
+
+ try{
+ stream = new ANTLRInputStream(request2);
+ lexer = new VamdcSqlRequestLexer(stream);
+ lexer.removeErrorListeners();
+ lexer.addErrorListener(ThrowingErrorListener.instance);
+ tokens = new CommonTokenStream(lexer);
+ parser = new VamdcSqlRequestParser(tokens);
+ parser.removeErrorListeners();
+ parser.addErrorListener(ThrowingErrorListener.instance);
+ tree = parser.select(); // parsing select
+ walker = new ParseTreeWalker();
+ parserWalker = new VamdcSqlRequestWalker();
+ walker.walk(parserWalker,tree); // constructing VamdcRequestTree
+
+ requestTree2 = parserWalker.getTree();
+ root2 = requestTree2.getRoot();
+ }catch(Exception ex){
+ throw ex;
+ }
+
+
+ /* --------------------------------- End of initialization ------------------------------------------------------------- */
+
+
+ if(request1.equals(request2) && request1 != null){
+ return true;
+ }
+
+ /* comparing list of columns */
+ List columns1 = requestTree1.getColumnList();
+ List columns2 = requestTree2.getColumnList();
+
+ Collections.sort(columns1);
+ Collections.sort(columns2);
+
+ if(columns1.size() != columns2.size()) {
+ return false;
+ }
+
+ for(int i=0;i list1 = requestTree1.generateOrElements(tmpNode1);
+ List list2 = requestTree2.generateOrElements(tmpNode2);
+
+ // result from request ----> expr1 OR expr2 OR ... OR exprN
+ Collections.sort(list1);
+ Collections.sort(list2);
+
+ if(list1.size() != list2.size()) {
+ return false;
+ }
+
+ for(int i=0;i columns = requestTree.getColumnList();
+
+ Collections.sort(columns);
+
+ canonicalForm += "select ";
+ for(int i=0;i list = requestTree.generateOrElements(tmpNode);
+
+ // result from request ----> expr1 OR expr2 OR ... OR exprN
+ Collections.sort(list);
+
+
+ for(int i=0;i inList = new ArrayList();
+ inList = Arrays.asList(right.replace("(", "").replace(")", "").split("\\s*,\\s*"));
+ Collections.sort(inList);
+ //System.out.println(inList.toString() +"\n\n");
+ node = new VamdcRequestNode(left + " " + op + " " + inList);
+
+ }
+
+
+
+
+ this.tree.addNode(node);
+ }
+
+
+ public VamdcRequestTree getTree(){
+ return this.tree;
+ }
+
+}
diff --git a/src/vamdcsqlcomparator/tests/AssociativityTest.java b/src/vamdcsqlcomparator/tests/AssociativityTest.java
new file mode 100644
index 0000000..8666ec8
--- /dev/null
+++ b/src/vamdcsqlcomparator/tests/AssociativityTest.java
@@ -0,0 +1,75 @@
+package vamdcsqlcomparator.tests;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.antlr.v4.runtime.misc.ParseCancellationException;
+import org.junit.Test;
+
+import vamdcsqlcomparator.VamdcSqlRequestComparator;
+
+public class AssociativityTest {
+
+ @Test
+ public void associativityTest_1(){
+
+ boolean result = false;
+
+ String r1 = "select * where (a<2 or (a<3 or a<1))or a<4";
+ String r2 = "select * where (a<1 or (a<2 or a<3))or a<4";
+
+
+ try{
+ result = VamdcSqlRequestComparator.compare(r1, r2);
+ }catch(ParseCancellationException ex){
+ fail("Grammatical Error!!!");
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }
+
+ assertTrue("Associativity Test_1 Failed!!!",result);
+
+ }
+
+ @Test
+ public void associativityTest_2(){
+
+ boolean result = false;
+
+ String r1 = "select * where (a<2 and (a<3 and a<1))or a<4";
+ String r2 = "select * where (a<1 and (a<2 and a<3))or a<4";
+
+ try{
+ result = VamdcSqlRequestComparator.compare(r1, r2);
+ }catch(ParseCancellationException ex){
+ fail("Grammatical Error!!!");
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }
+
+ assertTrue("Associativity Test_2 Failed!!!",result);
+
+ }
+
+
+ @Test
+ public void associativityTest_3(){
+
+ boolean result = false;
+
+
+ String r1 = "select * where ((e<1 and (c<1 and d<1 or (a<1 or b<1))) and ((f<1 or g<1) and x<1 and y<1)) and z<1";
+ String r2 = "select * where (z<1 and (e<1 and ((a<1 or b<1) or c<1 and d<1))) and ((g<1 or f<1) and y<1 and x<1)" ;
+
+ try{
+ result = VamdcSqlRequestComparator.compare(r1, r2);
+ }catch(ParseCancellationException ex){
+ fail("Grammatical Error!!!");
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }
+
+ assertTrue("Associativity Test_3 Failed!!!",result);
+
+ }
+}
diff --git a/src/vamdcsqlcomparator/tests/CommutativityTest.java b/src/vamdcsqlcomparator/tests/CommutativityTest.java
new file mode 100644
index 0000000..45bd503
--- /dev/null
+++ b/src/vamdcsqlcomparator/tests/CommutativityTest.java
@@ -0,0 +1,171 @@
+package vamdcsqlcomparator.tests;
+
+import static org.junit.Assert.*;
+
+import org.antlr.v4.runtime.misc.ParseCancellationException;
+import org.junit.Test;
+
+import vamdcsqlcomparator.VamdcSqlRequestComparator;
+
+
+public class CommutativityTest {
+
+ @Test
+ public void commutativityTest_1(){
+
+ boolean result = false;
+
+
+ String r1 = "select * where RadTransWavelength>=900.0 AND RadTransWavelength<=3000.0";
+ String r2 = "select * where RadTransWavelength<=3000.0 AND RadTransWavelength>=900.0";
+
+ try{
+ result = VamdcSqlRequestComparator.compare(r1, r2);
+ }catch(ParseCancellationException ex){
+ fail("Grammatical Error!!!");
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }
+
+ assertTrue("Commutativiy Test_1 Failed!!!",result);
+
+ }
+
+
+
+ @Test
+ public void commutativityTest_2(){
+
+ boolean result = false;
+
+
+ String r1 = "select * where RadTransWavelength>=5629.0 AND RadTransWavelength<=5638.0 AND InchiKey='LBVWYGNGGJURHQ-UHFFFAOYSA-N'";
+ String r2 = "select * where InchiKey='LBVWYGNGGJURHQ-UHFFFAOYSA-N' AND RadTransWavelength>=5629.0 AND RadTransWavelength<=5638.0";
+
+ try{
+ result = VamdcSqlRequestComparator.compare(r1, r2);
+ }catch(ParseCancellationException ex){
+ fail("Grammatical Error!!!");
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }
+
+ assertTrue("Commutativiy Test_2 Failed!!!",result);
+
+ }
+
+
+ @Test
+ public void commutativityTest_3(){
+
+ boolean result = false;
+
+
+ String r1 = "SELECT ALL WHERE SpeciesID=29 OR SpeciesID=31 OR SpeciesID=48 OR InchiKey='QGZKDVFQNNGYKY-UHFFFAOYSA-N'";
+ String r2 = "SELECT ALL WHERE InchiKey='QGZKDVFQNNGYKY-UHFFFAOYSA-N' OR SpeciesID=29 OR SpeciesID=31 OR SpeciesID=48";
+
+ try{
+ result = VamdcSqlRequestComparator.compare(r1, r2);
+ }catch(ParseCancellationException ex){
+ fail("Grammatical Error!!!");
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }
+
+ assertTrue("Commutativiy Test_3 Failed!!!",result);
+
+ }
+
+ @Test
+ public void commutativityTest_4(){
+
+ boolean result = false;
+
+
+ String r1 = "select * where RadTransWavelength>=3.747405725E7 AND RadTransWavelength<=5.99584916E7 AND upper.StateEnergy>=0.0 AND upper.StateEnergy<=500.0 AND lower.StateEnergy>=0.0 AND lower.StateEnergy<=500.0";
+ String r2 = "select * where upper.StateEnergy>=0.0 AND upper.StateEnergy<=500.0 AND lower.StateEnergy>=0.0 AND lower.StateEnergy<=500.0 AND RadTransWavelength>=3.747405725E7 AND RadTransWavelength<=5.99584916E7";
+
+ try{
+ result = VamdcSqlRequestComparator.compare(r1, r2);
+ }catch(ParseCancellationException ex){
+ fail("Grammatical Error!!!");
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }
+
+ assertTrue("Commutativiy Test_4 Failed!!!",result);
+
+ }
+
+
+ @Test
+ public void commutativityTest_5(){
+
+ boolean result = false;
+
+
+ String r1 = "SELECT ALL WHERE SpeciesID=19 OR SpeciesID=28";
+ String r2 = "SELECT ALL WHERE SpeciesID=28 OR SpeciesID=19";
+
+ try{
+ result = VamdcSqlRequestComparator.compare(r1, r2);
+ }catch(ParseCancellationException ex){
+ fail("Grammatical Error!!!");
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }
+
+ assertTrue("Commutativiy Test_5 Failed!!!",result);
+
+ }
+
+ @Test
+ public void commutativityTest_6(){
+
+ boolean result = false;
+
+
+
+ String r1 = "SELECT ALL WHERE SpeciesID=1 OR InchiKey='MRJFCQHWODZEPM-MICDWDOJSA-N' OR InchiKey='KEJOCWOXCDWNID-UHFFFAOYSA-N'";
+ String r2 = "SELECT ALL WHERE InchiKey='KEJOCWOXCDWNID-UHFFFAOYSA-N' OR SpeciesID=1 OR InchiKey='MRJFCQHWODZEPM-MICDWDOJSA-N'";
+
+ try{
+ result = VamdcSqlRequestComparator.compare(r1, r2);
+ }catch(ParseCancellationException ex){
+ fail("Grammatical Error!!!");
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }
+
+ assertTrue("Commutativiy Test_6 Failed!!!",result);
+
+ }
+
+
+
+ @Test
+ public void commutativityTest_7(){
+
+ boolean result = false;
+
+
+
+ String r1 = "select * where (RadTransWavelength >= 2.4982704833333332E7 AND RadTransWavelength <= 3.3310273111111112E7) AND ((InchiKey IN ('UGFAIRIUMAVXCW-RGIGPVFXSA-N','UGFAIRIUMAVXCW-ZDOIIHCHSA-N','UGFAIRIUMAVXCW-HQMMCQRPSA-N','UGFAIRIUMAVXCW-VQEHIDDOSA-N','UGFAIRIUMAVXCW-UHFFFAOYSA-N','UGFAIRIUMAVXCW-OUBTZVSYSA-N')))";
+ String r2 = "select * where ((InchiKey IN ('UGFAIRIUMAVXCW-RGIGPVFXSA-N','UGFAIRIUMAVXCW-ZDOIIHCHSA-N','UGFAIRIUMAVXCW-HQMMCQRPSA-N','UGFAIRIUMAVXCW-VQEHIDDOSA-N','UGFAIRIUMAVXCW-UHFFFAOYSA-N','UGFAIRIUMAVXCW-OUBTZVSYSA-N'))) and (RadTransWavelength >= 2.4982704833333332E7 AND RadTransWavelength <= 3.3310273111111112E7)";
+
+ try{
+ result = VamdcSqlRequestComparator.compare(r1, r2);
+ }catch(ParseCancellationException ex){
+ fail("Grammatical Error!!!");
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }
+
+ assertTrue("Commutativiy Test_7 Failed!!!",result);
+
+ }
+
+
+
+
+}
diff --git a/src/vamdcsqlcomparator/tests/GeneralTest.java b/src/vamdcsqlcomparator/tests/GeneralTest.java
new file mode 100644
index 0000000..5c59877
--- /dev/null
+++ b/src/vamdcsqlcomparator/tests/GeneralTest.java
@@ -0,0 +1,34 @@
+package vamdcsqlcomparator.tests;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.antlr.v4.runtime.misc.ParseCancellationException;
+import org.junit.Test;
+
+import vamdcsqlcomparator.VamdcSqlRequestComparator;
+
+public class GeneralTest {
+
+ @Test
+ public void numberTest_1(){
+
+ boolean result = false;
+
+
+ String r1 = "select * where x>=128.14 AND y<=1";
+ String r2 = "select * where x>=1.2814e2 AND y<=1.000";
+
+ try{
+ result = VamdcSqlRequestComparator.compare(r1, r2);
+ }catch(ParseCancellationException ex){
+ fail("Grammatical Error!!!");
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }
+
+ assertTrue("Number Test_1 Failed!!!",result);
+
+ }
+
+}
diff --git a/src/vamdcsqlcomparator/tests/GrammarTest.java b/src/vamdcsqlcomparator/tests/GrammarTest.java
new file mode 100644
index 0000000..60e88a1
--- /dev/null
+++ b/src/vamdcsqlcomparator/tests/GrammarTest.java
@@ -0,0 +1,20 @@
+package vamdcsqlcomparator.tests;
+
+import org.antlr.v4.runtime.misc.ParseCancellationException;
+import org.junit.Test;
+
+import vamdcsqlcomparator.VamdcSqlRequestComparator;
+
+public class GrammarTest {
+
+ /*
+ * must throw ParseCancellationException, otherwise error
+ */
+ @Test (expected = ParseCancellationException.class)
+ public void syntaxTest() throws Exception {
+
+ VamdcSqlRequestComparator.compare("select f1 where ...", "select f2 where...");
+
+ }
+
+}
diff --git a/src/vamdcsqlcomparator/tests/SelectColumnTest.java b/src/vamdcsqlcomparator/tests/SelectColumnTest.java
new file mode 100644
index 0000000..69acbb8
--- /dev/null
+++ b/src/vamdcsqlcomparator/tests/SelectColumnTest.java
@@ -0,0 +1,77 @@
+package vamdcsqlcomparator.tests;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.antlr.v4.runtime.misc.ParseCancellationException;
+import org.junit.Test;
+
+import vamdcsqlcomparator.VamdcSqlRequestComparator;
+
+public class SelectColumnTest {
+
+
+ @Test
+ public void selectColumnTest_1(){
+
+ boolean result = false;
+
+
+ String r1 = "SELECT ALL WHERE SpeciesID=19 OR SpeciesID=28";
+ String r2 = "SELECT * WHERE SpeciesID=19 OR SpeciesID=28";
+
+ try{
+ result = VamdcSqlRequestComparator.compare(r1, r2);
+ }catch(ParseCancellationException ex){
+ fail("Grammatical Error!!!");
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }
+
+ assertTrue("SelectColumn Test_1 Failled!!!",result);
+
+ }
+
+ @Test
+ public void selectColumnTest_2(){
+
+ boolean result = false;
+
+
+ String r1 = "SELECT f1,f2,f3,f4 WHERE SpeciesID=19 OR SpeciesID=28";
+ String r2 = "SELECT f4,f2,f3,f1 WHERE SpeciesID=19 OR SpeciesID=28";
+
+ try{
+ result = VamdcSqlRequestComparator.compare(r1, r2);
+ }catch(ParseCancellationException ex){
+ fail("Grammatical Error!!!");
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }
+
+ assertTrue("SelectColumn Test_2 Failled!!!",result);
+
+ }
+
+ @Test
+ public void selectColumnTest_3(){
+
+ boolean result = false;
+
+
+ String r1 = "SELECT f1,f2,f3,f4";
+ String r2 = "SELECT f4,f2,f3,f1";
+
+ try{
+ result = VamdcSqlRequestComparator.compare(r1, r2);
+ }catch(ParseCancellationException ex){
+ fail("Grammatical Error!!!");
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }
+
+ assertTrue("SelectColumn Test_3 Failled!!!",result);
+
+ }
+
+}