Example usage for org.antlr.v4.runtime.atn Transition RANGE

List of usage examples for org.antlr.v4.runtime.atn Transition RANGE

Introduction

In this page you can find the example usage for org.antlr.v4.runtime.atn Transition RANGE.

Prototype

int RANGE

To view the source code for org.antlr.v4.runtime.atn Transition RANGE.

Click Source Link

Usage

From source file:org.tvl.goworks.editor.go.highlighter.GoHighlighterLexer.java

License:Open Source License

private static Transition patchTransition(Transition transition, IntervalSet digitChars,
        IntervalSet letterChars) {/*ww  w.j a  v  a  2  s .co m*/
    switch (transition.getSerializationType()) {
    case Transition.ATOM:
    case Transition.RANGE:
    case Transition.SET:
        break;

    default:
        return null;
    }

    IntervalSet label = transition.label();
    if (label == null) {
        return null;
    }

    IntervalSet updated = null;
    if (label.contains(unicodeDigitPlaceholder)) {
        updated = new IntervalSet(label);
        updated.addAll(digitChars);
        if (updated.size() == digitChars.size()) {
            updated = digitChars;
        }
    }

    if (label.contains(unicodeLetterPlaceholder)) {
        if (updated != null) {
            updated.addAll(label);
        } else {
            updated = new IntervalSet(label);
        }

        updated.addAll(letterChars);
        if (updated.size() == letterChars.size()) {
            updated = letterChars;
        }
    }

    if (updated == null) {
        return null;
    }

    return new SetTransition(transition.target, updated);
}