Search in sources :

Example 11 with TextQLParser

use of edu.uci.ics.textdb.textql.languageparser.TextQLParser in project textdb by TextDB.

the class TextQLParserTest method testRegexLiteralToString.

/**
     * Test the regexLiteralToString method of the parser.
     * It should parse a REGEX_LITERAL from the input and return it as a string.
     * @throws ParseException if an unexpected ParseException is thrown
     */
@Test
public void testRegexLiteralToString() throws ParseException {
    Assert.assertEquals((new TextQLParser(string2InputStream(" // "))).regexLiteralToString(), "");
    Assert.assertEquals((new TextQLParser(string2InputStream(" /abc/ "))).regexLiteralToString(), "abc");
    Assert.assertEquals((new TextQLParser(string2InputStream(" /d\\/e/ "))).regexLiteralToString(), "d/e");
    Assert.assertEquals((new TextQLParser(string2InputStream(" /d\\/e\\/f/ "))).regexLiteralToString(), "d/e/f");
    Assert.assertEquals((new TextQLParser(string2InputStream(" /FROM/ "))).regexLiteralToString(), "FROM");
    Assert.assertEquals((new TextQLParser(string2InputStream(" /\"/ "))).regexLiteralToString(), "\"");
    Assert.assertEquals((new TextQLParser(string2InputStream(" /\\/ "))).regexLiteralToString(), "\\");
    assertException(() -> (new TextQLParser(string2InputStream(" /21 "))).regexLiteralToString(), TokenMgrError.class);
    assertException(() -> (new TextQLParser(string2InputStream(" 2/1/ "))).regexLiteralToString(), ParseException.class);
    assertException(() -> (new TextQLParser(string2InputStream(" \"4/ "))).regexLiteralToString(), TokenMgrError.class);
    assertException(() -> (new TextQLParser(string2InputStream(" FROM// "))).regexLiteralToString(), ParseException.class);
}
Also used : TextQLParser(edu.uci.ics.textdb.textql.languageparser.TextQLParser) Test(org.junit.Test)

Example 12 with TextQLParser

use of edu.uci.ics.textdb.textql.languageparser.TextQLParser in project textdb by TextDB.

the class TextQLParserTest method testStringLiteralToString.

/**
     * Test the stringLiteralToString method of the parser.
     * It should parse a STRING_LITERAL from the input and return it as a string.
     * @throws ParseException if an unexpected ParseException is thrown
     */
@Test
public void testStringLiteralToString() throws ParseException {
    Assert.assertEquals((new TextQLParser(string2InputStream(" \"\" "))).stringLiteralToString(), "");
    Assert.assertEquals((new TextQLParser(string2InputStream(" \"abc\" "))).stringLiteralToString(), "abc");
    Assert.assertEquals((new TextQLParser(string2InputStream(" \"de f\" "))).stringLiteralToString(), "de f");
    Assert.assertEquals((new TextQLParser(string2InputStream(" \"d\\\"e\" "))).stringLiteralToString(), "d\"e");
    Assert.assertEquals((new TextQLParser(string2InputStream(" \"d\\\"e\\\"f\" "))).stringLiteralToString(), "d\"e\"f");
    Assert.assertEquals((new TextQLParser(string2InputStream(" \"\\\"\" "))).stringLiteralToString(), "\"");
    Assert.assertEquals((new TextQLParser(string2InputStream(" \"\\\" "))).stringLiteralToString(), "\\");
    assertException(() -> (new TextQLParser(string2InputStream(" \"21 "))).stringLiteralToString(), TokenMgrError.class);
    assertException(() -> (new TextQLParser(string2InputStream(" 'aa' "))).stringLiteralToString(), TokenMgrError.class);
    assertException(() -> (new TextQLParser(string2InputStream(" 2\"1\" "))).stringLiteralToString(), ParseException.class);
    assertException(() -> (new TextQLParser(string2InputStream(" 21 "))).stringLiteralToString(), ParseException.class);
    assertException(() -> (new TextQLParser(string2InputStream(" SELECTa "))).stringLiteralToString(), ParseException.class);
    assertException(() -> (new TextQLParser(string2InputStream(" abc "))).stringLiteralToString(), ParseException.class);
}
Also used : TextQLParser(edu.uci.ics.textdb.textql.languageparser.TextQLParser) Test(org.junit.Test)

Example 13 with TextQLParser

use of edu.uci.ics.textdb.textql.languageparser.TextQLParser in project textdb by TextDB.

the class TextQLParserTest method testIdentifierLiteralToString.

/**
     * Test the identifierLiteralToString method of the parser.
     * It should parse a IDENTIFIER_LITERAL from the input and return it as a string.
     * @throws ParseException if an unexpected ParseException is thrown
     */
@Test
public void testIdentifierLiteralToString() throws ParseException {
    Assert.assertEquals((new TextQLParser(string2InputStream(" i "))).identifierLiteralToString(), "i");
    Assert.assertEquals((new TextQLParser(string2InputStream(" id "))).identifierLiteralToString(), "id");
    Assert.assertEquals((new TextQLParser(string2InputStream(" id de "))).identifierLiteralToString(), "id");
    Assert.assertEquals((new TextQLParser(string2InputStream(" id0 "))).identifierLiteralToString(), "id0");
    Assert.assertEquals((new TextQLParser(string2InputStream(" i6i8s7s "))).identifierLiteralToString(), "i6i8s7s");
    Assert.assertEquals((new TextQLParser(string2InputStream(" j7i\\8s7s "))).identifierLiteralToString(), "j7i");
    Assert.assertEquals((new TextQLParser(string2InputStream(" k8i\"8s7s "))).identifierLiteralToString(), "k8i");
    Assert.assertEquals((new TextQLParser(string2InputStream(" aFROM "))).identifierLiteralToString(), "aFROM");
    Assert.assertEquals((new TextQLParser(string2InputStream(" A "))).identifierLiteralToString(), "A");
    Assert.assertEquals((new TextQLParser(string2InputStream(" FROMa "))).identifierLiteralToString(), "FROMa");
    Assert.assertEquals((new TextQLParser(string2InputStream(" Ed0 "))).identifierLiteralToString(), "Ed0");
    assertException(() -> (new TextQLParser(string2InputStream(" 2df "))).identifierLiteralToString(), ParseException.class);
    assertException(() -> (new TextQLParser(string2InputStream(" _a "))).identifierLiteralToString(), TokenMgrError.class);
}
Also used : TextQLParser(edu.uci.ics.textdb.textql.languageparser.TextQLParser) Test(org.junit.Test)

Aggregations

TextQLParser (edu.uci.ics.textdb.textql.languageparser.TextQLParser)13 Test (org.junit.Test)13 ExtractPredicate (edu.uci.ics.textdb.textql.statements.predicates.ExtractPredicate)6 KeywordExtractPredicate (edu.uci.ics.textdb.textql.statements.predicates.KeywordExtractPredicate)6 CreateViewStatement (edu.uci.ics.textdb.textql.statements.CreateViewStatement)4 SelectStatement (edu.uci.ics.textdb.textql.statements.SelectStatement)4 Statement (edu.uci.ics.textdb.textql.statements.Statement)4 ProjectAllFieldsPredicate (edu.uci.ics.textdb.textql.statements.predicates.ProjectAllFieldsPredicate)4 ProjectPredicate (edu.uci.ics.textdb.textql.statements.predicates.ProjectPredicate)4 ProjectSomeFieldsPredicate (edu.uci.ics.textdb.textql.statements.predicates.ProjectSomeFieldsPredicate)4 ParseException (edu.uci.ics.textdb.textql.languageparser.ParseException)1 TokenMgrError (edu.uci.ics.textdb.textql.languageparser.TokenMgrError)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PipedInputStream (java.io.PipedInputStream)1 PipedOutputStream (java.io.PipedOutputStream)1 PrintStream (java.io.PrintStream)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1