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

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

Introduction

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

Prototype

int SET

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

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) {/*w  w w  .  j  ava  2s .  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);
}