/** * Get the start state for a specific precedence value. * * @param precedence The current precedence. * @return The start state corresponding to the specified precedence, or * {@code null} if no start state exists for the specified precedence. * * @throws IllegalStateException if this is not a precedence DFA. * @see #isPrecedenceDfa() */ @SuppressWarnings("null") public final DFAState getPrecedenceStartState(int precedence, boolean fullContext) { if (!isPrecedenceDfa()) { throw new IllegalStateException("Only precedence DFAs may contain a precedence start state."); } // s0.get() and s0full.get() are never null for a precedence DFA if (fullContext) { return s0full.get().getTarget(precedence); } else { return s0.get().getTarget(precedence); } }
/** * Get an existing target state for an edge in the DFA. If the target state * for the edge has not yet been computed or is otherwise not available, * this method returns {@code null}. * * @param s The current DFA state * @param t The next input symbol * @return The existing target DFA state for the given input symbol * {@code t}, or {@code null} if the target state for this edge is not * already cached */ @Nullable protected DFAState getExistingTargetState(@NotNull DFAState s, int t) { return s.getTarget(t); }
/** * Get an existing target state for an edge in the DFA. If the target state * for the edge has not yet been computed or is otherwise not available, * this method returns {@code null}. * * @param s The current DFA state * @param t The next input symbol * @return The existing target DFA state for the given input symbol * {@code t}, or {@code null} if the target state for this edge is not * already cached */ @Nullable protected DFAState getExistingTargetState(@NotNull DFAState s, int t) { DFAState target = s.getTarget(t); if (debug && target != null) { System.out.println("reuse state "+s.stateNumber+ " edge to "+target.stateNumber); } return target; }