/** * @deprecated Use {@link ATNDeserializer#deserialize} instead. */ @Deprecated public static ATN deserialize(char[] data) { return new ATNDeserializer().deserialize(data); }
/** * @deprecated Use {@link ATNDeserializer#checkCondition(boolean, String)} instead. */ @Deprecated public static void checkCondition(boolean condition, String message) { new ATNDeserializer().checkCondition(condition, message); }
int version = toInt(data[p++]); if (version != SERIALIZED_VERSION) { String reason = String.format(Locale.getDefault(), "Could not deserialize ATN with version %d (expected %d).", version, SERIALIZED_VERSION); UUID uuid = toUUID(data, p); p += 8; if (!SUPPORTED_UUIDS.contains(uuid)) { boolean supportsPrecedencePredicates = isFeatureSupported(ADDED_PRECEDENCE_TRANSITIONS, uuid); boolean supportsLexerActions = isFeatureSupported(ADDED_LEXER_ACTIONS, uuid); ATNType grammarType = ATNType.values()[toInt(data[p++])]; int maxTokenType = toInt(data[p++]); ATN atn = new ATN(grammarType, maxTokenType); int nstates = toInt(data[p++]); for (int i=0; i<nstates; i++) { int stype = toInt(data[p++]); int ruleIndex = toInt(data[p++]); if (ruleIndex == Character.MAX_VALUE) { ruleIndex = -1; ATNState s = stateFactory(stype, ruleIndex); if ( stype == ATNState.LOOP_END ) { // special case int loopBackStateNumber = toInt(data[p++]); loopBackStateNumbers.add(new Pair<LoopEndState, Integer>((LoopEndState)s, loopBackStateNumber)); int endStateNumber = toInt(data[p++]);
/** * @deprecated Use {@link ATNDeserializer#stateFactory} instead. */ @Deprecated public static ATNState stateFactory(int type, int ruleIndex) { return new ATNDeserializer().stateFactory(type, ruleIndex); }
int version = toInt(data[p++]); if (version != SERIALIZED_VERSION) { String reason = String.format(Locale.getDefault(), "Could not deserialize ATN with version %d (expected %d).", version, SERIALIZED_VERSION); UUID uuid = toUUID(data, p); p += 8; if (!SUPPORTED_UUIDS.contains(uuid)) { boolean supportsLexerActions = isFeatureSupported(ADDED_LEXER_ACTIONS, uuid); ATNType grammarType = ATNType.values()[toInt(data[p++])]; int maxTokenType = toInt(data[p++]); ATN atn = new ATN(grammarType, maxTokenType); int nstates = toInt(data[p++]); for (int i=0; i<nstates; i++) { int stype = toInt(data[p++]); int ruleIndex = toInt(data[p++]); if (ruleIndex == Character.MAX_VALUE) { ruleIndex = -1; ATNState s = stateFactory(stype, ruleIndex); if ( stype == ATNState.LOOP_END ) { // special case int loopBackStateNumber = toInt(data[p++]); loopBackStateNumbers.add(Tuple.create((LoopEndState)s, loopBackStateNumber)); int endStateNumber = toInt(data[p++]); endStateNumbers.add(Tuple.create((BlockStartState)s, endStateNumber));
/** * @deprecated Use {@link ATNDeserializer#edgeFactory} instead. */ @Deprecated public static Transition edgeFactory(ATN atn, int type, int src, int trg, int arg1, int arg2, int arg3, List<IntervalSet> sets) { return new ATNDeserializer().edgeFactory(atn, type, src, trg, arg1, arg2, arg3, sets); }
int version = ATNDeserializer.toInt(data[p++]); if (version != ATNDeserializer.SERIALIZED_VERSION) { String reason = String.format("Could not deserialize ATN with version %d (expected %d).", version, ATNDeserializer.SERIALIZED_VERSION); UUID uuid = ATNDeserializer.toUUID(data, p); p += 8; if (!uuid.equals(ATNDeserializer.SERIALIZED_UUID)) { int maxType = ATNDeserializer.toInt(data[p++]); buf.append("max type ").append(maxType).append("\n"); int nstates = ATNDeserializer.toInt(data[p++]); for (int i=0; i<nstates; i++) { int stype = ATNDeserializer.toInt(data[p++]); if ( stype==ATNState.INVALID_TYPE ) continue; // ignore bad type of states int ruleIndex = ATNDeserializer.toInt(data[p++]); if (ruleIndex == Character.MAX_VALUE) { ruleIndex = -1; int loopBackStateNumber = ATNDeserializer.toInt(data[p++]); arg = " "+loopBackStateNumber; int endStateNumber = ATNDeserializer.toInt(data[p++]); arg = " "+endStateNumber; int numNonGreedyStates = ATNDeserializer.toInt(data[p++]); for (int i = 0; i < numNonGreedyStates; i++) { int stateNumber = ATNDeserializer.toInt(data[p++]); int numPrecedenceStates = ATNDeserializer.toInt(data[p++]);
@Override public int readUnicode(char[] data, int p) { return toInt(data[p]); }
protected void checkCondition(boolean condition) { checkCondition(condition, null); }
int version = ATNDeserializer.toInt(data[p++]); if (version != ATNDeserializer.SERIALIZED_VERSION) { String reason = String.format("Could not deserialize ATN with version %d (expected %d).", version, ATNDeserializer.SERIALIZED_VERSION); UUID uuid = ATNDeserializer.toUUID(data, p); p += 8; if (!uuid.equals(ATNDeserializer.SERIALIZED_UUID)) { int maxType = ATNDeserializer.toInt(data[p++]); buf.append("max type ").append(maxType).append("\n"); int nstates = ATNDeserializer.toInt(data[p++]); for (int i=0; i<nstates; i++) { int stype = ATNDeserializer.toInt(data[p++]); if ( stype==ATNState.INVALID_TYPE ) continue; // ignore bad type of states int ruleIndex = ATNDeserializer.toInt(data[p++]); if (ruleIndex == Character.MAX_VALUE) { ruleIndex = -1; int loopBackStateNumber = ATNDeserializer.toInt(data[p++]); arg = " "+loopBackStateNumber; int endStateNumber = ATNDeserializer.toInt(data[p++]); arg = " "+endStateNumber; int numNonGreedyStates = ATNDeserializer.toInt(data[p++]); for (int i = 0; i < numNonGreedyStates; i++) { int stateNumber = ATNDeserializer.toInt(data[p++]); int numPrecedenceStates = ATNDeserializer.toInt(data[p++]);
/** * @deprecated Use {@link ATNDeserializer#stateFactory} instead. */ @Deprecated public static ATNState stateFactory(int type, int ruleIndex) { return new ATNDeserializer().stateFactory(type, ruleIndex); }
/** * @deprecated Use {@link ATNDeserializer#edgeFactory} instead. */ @Deprecated public static Transition edgeFactory(ATN atn, int type, int src, int trg, int arg1, int arg2, int arg3, List<IntervalSet> sets) { return new ATNDeserializer().edgeFactory(atn, type, src, trg, arg1, arg2, arg3, sets); }
int version = ATNDeserializer.toInt(data[p++]); if (version != ATNDeserializer.SERIALIZED_VERSION) { String reason = String.format("Could not deserialize ATN with version %d (expected %d).", version, ATNDeserializer.SERIALIZED_VERSION); UUID uuid = ATNDeserializer.toUUID(data, p); p += 8; if (!uuid.equals(ATNDeserializer.SERIALIZED_UUID)) { int maxType = ATNDeserializer.toInt(data[p++]); buf.append("max type ").append(maxType).append("\n"); int nstates = ATNDeserializer.toInt(data[p++]); for (int i=0; i<nstates; i++) { int stype = ATNDeserializer.toInt(data[p++]); if ( stype==ATNState.INVALID_TYPE ) continue; // ignore bad type of states int ruleIndex = ATNDeserializer.toInt(data[p++]); if (ruleIndex == Character.MAX_VALUE) { ruleIndex = -1; int loopBackStateNumber = ATNDeserializer.toInt(data[p++]); arg = " "+loopBackStateNumber; int endStateNumber = ATNDeserializer.toInt(data[p++]); arg = " "+endStateNumber; int numNonGreedyStates = ATNDeserializer.toInt(data[p++]); for (int i = 0; i < numNonGreedyStates; i++) { int stateNumber = ATNDeserializer.toInt(data[p++]); int numSllStates = ATNDeserializer.toInt(data[p++]);
/** * @deprecated Use {@link ATNDeserializer#toInt} instead. */ @Deprecated public static int toInt(char c) { return ATNDeserializer.toInt(c); }
@Override public int readUnicode(char[] data, int p) { return toInt32(data, p); }
checkCondition(state.onlyHasEpsilonTransitions() || state.getNumberOfTransitions() <= 1); checkCondition(((PlusBlockStartState)state).loopBackState != null); checkCondition(starLoopEntryState.loopBackState != null); checkCondition(starLoopEntryState.getNumberOfTransitions() == 2); checkCondition(starLoopEntryState.transition(1).target instanceof LoopEndState); checkCondition(!starLoopEntryState.nonGreedy); checkCondition(starLoopEntryState.transition(1).target instanceof StarBlockStartState); checkCondition(starLoopEntryState.nonGreedy); checkCondition(state.getNumberOfTransitions() == 1); checkCondition(state.transition(0).target instanceof StarLoopEntryState); checkCondition(((LoopEndState)state).loopBackState != null); checkCondition(((RuleStartState)state).stopState != null); checkCondition(((BlockStartState)state).endState != null); checkCondition(((BlockEndState)state).startState != null); checkCondition(decisionState.getNumberOfTransitions() <= 1 || decisionState.decision >= 0); checkCondition(state.getNumberOfTransitions() <= 1 || state instanceof RuleStopState);
int version = ATNDeserializer.toInt(data[p++]); if (version != ATNDeserializer.SERIALIZED_VERSION) { String reason = String.format("Could not deserialize ATN with version %d (expected %d).", version, ATNDeserializer.SERIALIZED_VERSION); UUID uuid = ATNDeserializer.toUUID(data, p); p += 8; if (!uuid.equals(ATNDeserializer.SERIALIZED_UUID)) { int maxType = ATNDeserializer.toInt(data[p++]); buf.append("max type ").append(maxType).append("\n"); int nstates = ATNDeserializer.toInt(data[p++]); for (int i=0; i<nstates; i++) { int stype = ATNDeserializer.toInt(data[p++]); if ( stype==ATNState.INVALID_TYPE ) continue; // ignore bad type of states int ruleIndex = ATNDeserializer.toInt(data[p++]); if (ruleIndex == Character.MAX_VALUE) { ruleIndex = -1; int loopBackStateNumber = ATNDeserializer.toInt(data[p++]); arg = " "+loopBackStateNumber; int endStateNumber = ATNDeserializer.toInt(data[p++]); arg = " "+endStateNumber; int numNonGreedyStates = ATNDeserializer.toInt(data[p++]); for (int i = 0; i < numNonGreedyStates; i++) { int stateNumber = ATNDeserializer.toInt(data[p++]); int numPrecedenceStates = ATNDeserializer.toInt(data[p++]);
/** * 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; } }
int version = toInt(data[p++]); if (version != SERIALIZED_VERSION) { String reason = String.format(Locale.getDefault(), "Could not deserialize ATN with version %d (expected %d).", version, SERIALIZED_VERSION); UUID uuid = toUUID(data, p); p += 8; if (!SUPPORTED_UUIDS.contains(uuid)) { boolean supportsPrecedencePredicates = isFeatureSupported(ADDED_PRECEDENCE_TRANSITIONS, uuid); boolean supportsLexerActions = isFeatureSupported(ADDED_LEXER_ACTIONS, uuid); ATNType grammarType = ATNType.values()[toInt(data[p++])]; int maxTokenType = toInt(data[p++]); ATN atn = new ATN(grammarType, maxTokenType); int nstates = toInt(data[p++]); for (int i=0; i<nstates; i++) { int stype = toInt(data[p++]); int ruleIndex = toInt(data[p++]); if (ruleIndex == Character.MAX_VALUE) { ruleIndex = -1; ATNState s = stateFactory(stype, ruleIndex); if ( stype == ATNState.LOOP_END ) { // special case int loopBackStateNumber = toInt(data[p++]); loopBackStateNumbers.add(new Pair<LoopEndState, Integer>((LoopEndState)s, loopBackStateNumber)); int endStateNumber = toInt(data[p++]);