Search in sources :

Example 1 with ATNDeserializationOptions

use of org.antlr.v4.runtime.atn.ATNDeserializationOptions in project antlr4 by antlr.

the class Parser method getATNWithBypassAlts.

/**
	 * The ATN with bypass alternatives is expensive to create so we create it
	 * lazily.
	 *
	 * @throws UnsupportedOperationException if the current parser does not
	 * implement the {@link #getSerializedATN()} method.
	 */
public ATN getATNWithBypassAlts() {
    String serializedAtn = getSerializedATN();
    if (serializedAtn == null) {
        throw new UnsupportedOperationException("The current parser does not support an ATN with bypass alternatives.");
    }
    synchronized (bypassAltsAtnCache) {
        ATN result = bypassAltsAtnCache.get(serializedAtn);
        if (result == null) {
            ATNDeserializationOptions deserializationOptions = new ATNDeserializationOptions();
            deserializationOptions.setGenerateRuleBypassTransitions(true);
            result = new ATNDeserializer(deserializationOptions).deserialize(serializedAtn.toCharArray());
            bypassAltsAtnCache.put(serializedAtn, result);
        }
        return result;
    }
}
Also used : ATNDeserializer(org.antlr.v4.runtime.atn.ATNDeserializer) ATNDeserializationOptions(org.antlr.v4.runtime.atn.ATNDeserializationOptions) ATN(org.antlr.v4.runtime.atn.ATN)

Aggregations

ATN (org.antlr.v4.runtime.atn.ATN)1 ATNDeserializationOptions (org.antlr.v4.runtime.atn.ATNDeserializationOptions)1 ATNDeserializer (org.antlr.v4.runtime.atn.ATNDeserializer)1