Search in sources :

Example 1 with StringLiteralAstNode

use of com.linkedin.pinot.pql.parsers.pql2.ast.StringLiteralAstNode in project pinot by linkedin.

the class Pql2AstListener method enterStringLiteral.

@Override
public void enterStringLiteral(@NotNull PQL2Parser.StringLiteralContext ctx) {
    String text = ctx.getText();
    int textLength = text.length();
    // users can write 'Martha''s Vineyard' or """foo"""
    if (text.charAt(0) == '\'') {
        pushNode(new StringLiteralAstNode(text.substring(1, textLength - 1).replaceAll("''", "'")));
    } else if (text.charAt(0) == '"') {
        pushNode(new StringLiteralAstNode(text.substring(1, textLength - 1).replaceAll("\"\"", "\"")));
    } else {
        throw new Pql2CompilationException("String literal does not start with either '  or \"");
    }
}
Also used : StringLiteralAstNode(com.linkedin.pinot.pql.parsers.pql2.ast.StringLiteralAstNode)

Aggregations

StringLiteralAstNode (com.linkedin.pinot.pql.parsers.pql2.ast.StringLiteralAstNode)1