Search in sources :

Example 1 with CypherLexer

use of org.vertexium.cypher.CypherLexer in project vertexium by visallo.

the class CypherAstParser method parseExpression.

public CypherAstBase parseExpression(String expressionString) {
    CypherLexer lexer = new CypherLexer(CharStreams.fromString(expressionString));
    CypherParser parser = new CypherParser(new CommonTokenStream(lexer));
    parser.setErrorHandler(new ParserErrorHandler(expressionString));
    CypherParser.ExpressionContext expressionContext = parser.expression();
    return new CypherCstToAstVisitor().visitExpression(expressionContext);
}
Also used : CypherParser(org.vertexium.cypher.CypherParser) CypherLexer(org.vertexium.cypher.CypherLexer)

Example 2 with CypherLexer

use of org.vertexium.cypher.CypherLexer in project vertexium by visallo.

the class CypherAstParser method parse.

public CypherStatement parse(CypherCompilerContext ctx, String code) {
    CodePointCharStream input = CharStreams.fromString(code);
    CypherLexer lexer = new CypherLexer(input);
    CypherParser parser = new CypherParser(new CommonTokenStream(lexer));
    parser.setErrorHandler(new ParserErrorHandler(code));
    CypherParser.CypherContext tree = parser.cypher();
    if (!tree.getText().equals(code)) {
        throw new VertexiumCypherSyntaxErrorException("Parsing error, \"" + code.substring(tree.getText().length()) + "\"");
    }
    return new CypherCstToAstVisitor(ctx).visitCypher(tree);
}
Also used : CypherParser(org.vertexium.cypher.CypherParser) CypherLexer(org.vertexium.cypher.CypherLexer) VertexiumCypherSyntaxErrorException(org.vertexium.cypher.exceptions.VertexiumCypherSyntaxErrorException)

Aggregations

CypherLexer (org.vertexium.cypher.CypherLexer)2 CypherParser (org.vertexium.cypher.CypherParser)2 VertexiumCypherSyntaxErrorException (org.vertexium.cypher.exceptions.VertexiumCypherSyntaxErrorException)1