use of com.inova8.pathql.pathPattern.PathPatternLexer in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternTests method test_11.
/**
* Test 11.
*/
@Test
@Order(11)
void test_11() {
try {
String expression = ":Location@:appearsOn[eq id:Calc2Graph2]#";
CharStream input = CharStreams.fromString(expression);
PathPatternLexer lexer = new PathPatternLexer(input);
PathErrorListener errorListener = new PathErrorListener(expression);
lexer.removeErrorListeners();
lexer.addErrorListener(errorListener);
CommonTokenStream tokens = new CommonTokenStream(lexer);
PathPatternParser parser = new PathPatternParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
PathPatternContext pathPatternTree = parser.pathPattern();
PathPatternVisitor pathPatternVisitor = new PathPatternVisitor(repositoryContext);
PathElement element = pathPatternVisitor.visit(pathPatternTree);
assertEquals("<http://default/Location>@<http://default/appearsOn>[eq <http://id/Calc2Graph2> ]#", element.toString());
} catch (Exception e) {
assertEquals("<http://default/Location>@<http://default/appearsOn>[eq <http://id/Calc2Graph2> ;]#", "");
}
}
use of com.inova8.pathql.pathPattern.PathPatternLexer in project com.inova8.intelligentgraph by peterjohnlawrence.
the class QueryStringParserTests method prepareElement.
/**
* Prepare element.
*
* @param input the input
* @return the path element
* @throws RecognitionException the recognition exception
*/
private PathElement prepareElement(CharStream input) throws RecognitionException {
PathPatternLexer lexer = new PathPatternLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
PathPatternParser parser = new PathPatternParser(tokens);
// PathPatternContext pathPatternTree = parser.pathPattern();
QueryStringContext queryStringTree = parser.queryString();
PathPatternVisitor pathPatternVisitor = new PathPatternVisitor(repositoryContext);
PathElement element = pathPatternVisitor.visit(queryStringTree);
return element;
}
use of com.inova8.pathql.pathPattern.PathPatternLexer in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternQueryExpressionTests method test_11.
/**
* Test 11.
*/
@Test
@Order(11)
void test_11() {
try {
String expression = ":Location@:appearsOn[eq id:Calc2Graph2]#";
CharStream input = CharStreams.fromString(expression);
PathPatternLexer lexer = new PathPatternLexer(input);
PathErrorListener errorListener = new PathErrorListener(expression);
lexer.removeErrorListeners();
lexer.addErrorListener(errorListener);
CommonTokenStream tokens = new CommonTokenStream(lexer);
PathPatternParser parser = new PathPatternParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
PathPatternContext pathPatternTree = parser.pathPattern();
PathPatternVisitor pathPatternVisitor = new PathPatternVisitor(repositoryContext);
PathElement element = pathPatternVisitor.visit(pathPatternTree);
// Query.assertEqualsWOSpaces
assertEquals("Join\r\n" + " Join\r\n" + " StatementPattern\r\n" + " Variable (name=rnull)\r\n" + " Variable (name=subjectnull, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + " Variable (name=nnull)\r\n" + " StatementPattern\r\n" + " Variable (name=rnull)\r\n" + " Variable (name=propertynull, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + " Variable (name=p_nnull_nnull, value=http://default/appearsOn)\r\n" + " StatementPattern\r\n" + " Variable (name=rnull)\r\n" + " Variable (name=objectnull, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + " Variable (name=nnull, value=http://id/Calc2Graph2)\r\n" + "", element.pathPatternQuery().toString());
} catch (Exception e) {
Query.assertEqualsWOSpaces("<http://default/Location>@<http://default/appearsOn>[eq <http://id/Calc2Graph2> ;]#", "");
}
}
Aggregations