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

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

Introduction

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

Prototype

public Token getStop() 

Source Link

Document

Get the final token in this context.

Usage

From source file:com.twosigma.beaker.autocomplete.AutocompleteResult.java

License:Apache License

public static int getStartIndex(ParserRuleContext ctx) {
    return ctx.getStop().getStartIndex();
}

From source file:edu.clemson.cs.r2jt.absynnew.TreeBuildingVisitor.java

License:Open Source License

private InitFinalAST buildImplModuleInitFinal(ParserRuleContext ctx,
        List<ResolveParser.VariableDeclGroupContext> v, ParseTree requires, ParseTree ensures, Type t) {
    sanityCheckInitFinal(ctx);//from w  ww  . j av  a  2s .com
    List<VariableAST> variables = new ArrayList<VariableAST>();

    for (ResolveParser.VariableDeclGroupContext grp : v) {
        variables.addAll(getAll(VariableAST.class, grp.Identifier()));
    }
    return new InitFinalAST(ctx.getStart(), ctx.getStop(), get(ExprAST.class, requires),
            get(ExprAST.class, ensures), variables, new ArrayList<StmtAST>(), t);
}

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() });
    }/* www  . java2s .c  o m*/
}

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);
    }//from   w ww  . j a va  2 s. com
    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:net.certiv.json.converter.JsonPhaseBase.java

License:Open Source License

public String commentRight(ParserRuleContext rc) {
    int tdx = rc.getStop().getTokenIndex();
    int jdx = tdx + 1;
    boolean onlyWS = true;
    boolean done = false;
    while (!done) {
        switch (this.state.tokens.get(jdx).getType()) {
        case JsonLexer.CommentLine:
            onlyWS = false;/*from  w  ww.  java 2 s  .  c  o  m*/
        case JsonLexer.HorzWS:
            jdx++;
            break;
        case JsonLexer.EOF:
            done = true;
            break;
        default:
            done = true;
        }
    }
    if (onlyWS)
        return "";
    if (this.state.commentMarkers.contains(jdx)) {
        return "";
    } else {
        this.state.commentMarkers.add(jdx);
    }

    StringBuilder sb = new StringBuilder();
    for (tdx++; tdx <= jdx; tdx++) {
        sb.append(this.state.tokens.get(tdx).getText());
    }
    return sb.toString();
}

From source file:net.maritimecloud.internal.msdl.parser.SourceTagHolder.java

License:Apache License

SourceTagHolder(ParsedMsdlFile file, ParserRuleContext c) {
    this.file = requireNonNull(file);
    this.startLine = c.getStart().getLine();
    this.startCharPosition = c.getStart().getCharPositionInLine();
    this.stopLine = c.getStop().getLine();
    this.stopCharPosition = c.getStop().getCharPositionInLine();
}

From source file:nl.lxtreme.libtdl.grammar.adv.AdvTdlSemanticAnalyzer.java

License:Apache License

private boolean validateRange(ParserRuleContext lower, ParserRuleContext upper, String msg) {
    Long lowerBound = decode(lower.getText());
    Long upperBound = decode(upper.getText());

    boolean valid = (lowerBound != null) && (upperBound != null) && (lowerBound.compareTo(upperBound) < 0);

    if (!valid) {
        int offset = lower.getStart().getStartIndex();
        int length = lower.getStop().getStopIndex() - offset;

        MarkerBuilder builder = new MarkerBuilder();
        Marker marker = builder//from  w w  w .  j a v  a  2 s.c o  m
                .setCategory(Category.SEMANTIC).setType(Type.ERROR).setLocation(offset, length,
                        lower.getStart().getLine(), lower.getStart().getCharPositionInLine())
                .setDescription(msg).build();

        m_problemReporter.report(marker);
    }

    return valid;
}