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

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

Introduction

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

Prototype

@Override
public String getText() 

Source Link

Document

Return the combined text of all child nodes.

Usage

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:nanoverse.compiler.pipeline.interpret.visitors.helpers.NanoBlockHelper.java

License:Open Source License

public Stream<ASTNode> doVisit(ParserRuleContext ctx, int start, int end) {
    logger.debug("Visiting block: {}", ctx.getText());

    return IntStream.range(start, end).mapToObj(ctx::getChild).map(this::verifyAndAccept);
}

From source file:net.cpollet.thorium.analysis.ObserverRegistry.java

License:Apache License

private void log(String prefix, ParserRuleContext observer, T observable) {
    LOG.debug(prefix + " " + observer.getClass().getSimpleName() + observer.toString() + "@"
            + System.identityHashCode(observer) + ": " + observer.getText() + " for " + observable.toString());
}

From source file:nl.basjes.parse.useragent.analyze.treewalker.steps.WalkList.java

License:Apache License

public WalkList(ParserRuleContext requiredPattern, Map<String, Map<String, String>> lookups, boolean verbose) {
    this.lookups = lookups;
    this.verbose = verbose;
    // Generate the walkList from the requiredPattern
    new WalkListBuilder().visit(requiredPattern);
    linkSteps();//from  w  ww . j  a  va2 s . c o  m

    int i = 1;
    if (verbose) {
        LOG.info("------------------------------------");
        LOG.info("Required: " + requiredPattern.getText());
        for (Step step : steps) {
            step.setVerbose(true);
            LOG.info("{}: {}", i++, step);
        }
    }
}

From source file:nl.basjes.parse.useragent.utils.AntlrUtils.java

License:Apache License

public static String getSourceText(ParserRuleContext ctx) {
    if (ctx.start == null) {
        return null; // Invalid
    }//w ww.  ja  v  a  2s.  co m
    if (ctx.stop == null) {
        return ctx.getText();
    }
    int startIndex = ctx.start.getStartIndex();
    int stopIndex = ctx.stop.getStopIndex();
    if (stopIndex < startIndex) {
        return ctx.getText();
    }
    CharStream inputStream = ctx.start.getInputStream();
    return inputStream.getText(new Interval(startIndex, stopIndex));
}

From source file:nl.knaw.huygens.alexandria.query.TAGQLQueryListener.java

License:Apache License

private int toInteger(ParserRuleContext ctx) {
    return Integer.valueOf(ctx.getText());
}

From source file:nl.knaw.huygens.alexandria.query.TAGQLQueryListener.java

License:Apache License

private String stringLiteral(ParserRuleContext ctx) {
    return ctx.getText();
}

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 ww .j a v  a 2s  . co 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;
}