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

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

Introduction

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

Prototype

@Override
public String getText() 

Source Link

Document

Return the combined text of all child nodes.

Usage

From source file:com.github.jknack.handlebars.internal.TemplateBuilder.java

License:Apache License

/**
 * @param ctx The char literal context.//www . j a  va  2s. co  m
 * @return A char literal.
 */
private String charLiteral(final RuleContext ctx) {
    return ctx.getText().replace("\\\'", "\'");
}

From source file:com.github.jknack.handlebars.internal.TemplateBuilder.java

License:Apache License

/**
 * @param ctx The string literal context.
 * @return A string literal./*from  www  .j a v  a 2s  .  c  o m*/
 */
private String stringLiteral(final RuleContext ctx) {
    return ctx.getText().replace("\\\"", "\"");
}

From source file:de.up.ling.irtg.codec.CodecUtilities.java

public static String extractName(RuleContext context, boolean isQuoted) {
    if (isQuoted) {
        String s = context.getText();
        return stripOuterChars(s);
    } else {/*from  w w w.  ja  v  a  2 s  .  c  om*/
        return context.getText();
    }
}

From source file:org.hawkular.inventory.rest.Traverser.java

License:Apache License

private <C extends RuleContext> Map<String, List<ValueAndPos>> extractFilters(List<C> filterContexts,
        Function<C, RuleContext> filterName, Function<C, RuleContext> filterValue) {

    Map<String, List<ValueAndPos>> ret = new LinkedHashMap<>();

    int pos = 0;/*w w w .  j  a  va  2  s  . c o m*/
    for (C ctx : filterContexts) {
        RuleContext nameCtx = filterName.apply(ctx);
        RuleContext valueCtx = filterValue.apply(ctx);

        String name = nameCtx.getText();
        String value = valueCtx.getText();

        List<ValueAndPos> values = ret.get(name);
        if (values == null) {
            values = new ArrayList<>();
            ret.put(name, values);
        }

        values.add(new ValueAndPos(value, pos++));
    }

    return ret;
}