Example usage for org.antlr.v4.runtime ParserRuleContext getStart

List of usage examples for org.antlr.v4.runtime ParserRuleContext getStart

Introduction

In this page you can find the example usage for org.antlr.v4.runtime ParserRuleContext getStart.

Prototype

public Token getStart() 

Source Link

Document

Get the initial token in this context.

Usage

From source file:io.prestosql.sql.parser.AstBuilder.java

License:Apache License

private static ParsingException parseError(String message, ParserRuleContext context) {
    return new ParsingException(message, null, context.getStart().getLine(),
            context.getStart().getCharPositionInLine());
}

From source file:io.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl.java

License:Open Source License

public SiddhiParserException newSiddhiParserException(ParserRuleContext context) {
    return new SiddhiParserException("Syntax error in SiddhiQL, near '" + context.getText() + "'.",
            new int[] { context.getStart().getLine(), context.getStart().getCharPositionInLine() },
            new int[] { context.getStop().getLine(), context.getStop().getCharPositionInLine() });
}

From source file:io.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl.java

License:Open Source License

public SiddhiParserException newSiddhiParserException(ParserRuleContext context, String message) {
    return new SiddhiParserException(
            "Syntax error in SiddhiQL, near '" + context.getText() + "', " + message + ".",
            new int[] { context.getStart().getLine(), context.getStart().getCharPositionInLine() },
            new int[] { context.getStop().getLine(), context.getStop().getCharPositionInLine() });
}

From source file:io.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl.java

License:Open Source License

public SiddhiParserException newSiddhiParserException(ParserRuleContext context, String message, Throwable t) {
    return new SiddhiParserException(
            "Syntax error in SiddhiQL, near '" + context.getText() + "', " + message + ".", t,
            new int[] { context.getStart().getLine(), context.getStart().getCharPositionInLine() },
            new int[] { context.getStop().getLine(), context.getStop().getCharPositionInLine() });
}

From source file:io.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl.java

License:Open Source License

private void populateQueryContext(SiddhiElement siddhiElement, @NotNull ParserRuleContext ctx) {
    if (siddhiElement != null && siddhiElement.getQueryContextStartIndex() == null
            && siddhiElement.getQueryContextEndIndex() == null) {
        siddhiElement.setQueryContextStartIndex(
                new int[] { ctx.getStart().getLine(), ctx.getStart().getCharPositionInLine() });
        siddhiElement.setQueryContextEndIndex(
                new int[] { ctx.getStop().getLine(), ctx.getStop().getCharPositionInLine() + 1
                        + ctx.getStop().getStopIndex() - ctx.getStop().getStartIndex() });
    }/*from   ww w  .j  a v a  2s.  c o m*/
}

From source file:jetbrick.template.parser.AstCodeVisitor.java

License:Open Source License

private Position pos(ParserRuleContext ctx, int childIndex) {
    ParseTree node = ctx.getChild(childIndex);
    if (node instanceof TerminalNode) {
        Token token = ((TerminalNode) node).getSymbol();
        return new Position(token.getLine(), token.getCharPositionInLine());
    } else if (node instanceof ParserRuleContext) {
        Token token = ctx.getStart();
        return new Position(token.getLine(), token.getCharPositionInLine());
    }/*from  w  ww . ja va2 s .  co m*/
    throw new UnsupportedOperationException();
}

From source file:joanakeyrefactoring.javaforkeycreator.javatokeypipeline.CopyKeyCompatibleListener.java

private String extractStringInBetween(ParserRuleContext ctx) {
    int startLine = ctx.getStart().getLine();
    int startCharPositionInLine = ctx.getStart().getCharPositionInLine();
    int stopLine = ctx.getStop().getLine();
    int stopCharPositionInLine = ctx.getStop().getCharPositionInLine();

    String s = "";
    if (startLine == stopLine) {
        return classCodeAsLines.get(startLine - 1).substring(startCharPositionInLine, stopCharPositionInLine);
    }/* w  ww .j  a  v a 2 s.c o m*/
    for (int i = startLine - 1; i < stopLine; ++i) {
        if (i == startLine) {
            s += classCodeAsLines.get(i).substring(startCharPositionInLine - 1,
                    classCodeAsLines.get(i).length()) + '\n';
        } else if (i == stopLine) {
            s += classCodeAsLines.get(i).substring(0, stopCharPositionInLine - 1);
        } else {
            s += classCodeAsLines.get(i) + '\n';
        }
    }

    return s;
}

From source file:mbtarranger.BadBank.java

License:Open Source License

protected static void _report(Throwable e, ParserRuleContext ctx, File filePath) {
    report(e, ctx.getStart().getLine(), filePath);
}

From source file:mbtarranger.BadBank.java

License:Open Source License

public static void report(Throwable e, IFile file, ParserRuleContext ctx) {
    report(e, file, ctx.getStart().getLine());

}

From source file:mbtarranger.BadBank.java

License:Open Source License

public static void reportProblem(ParserRuleContext userInputScope, File arrFile, String messageToUser) {
    reportProblem(userInputScope.getStart().getLine(), arrFile, messageToUser);

}