Get the state transitions which the string-matching automaton
shall make when a partial match proves false.
169659
protected function computeNoTransitions() {
		$queue = [];
		$this->noTransitions = [];

		foreach ( $this->yesTransitions[0] as $ch => $toState ) {
			$queue[] = $toState;
			$this->noTransitions[$toState] = 0;
		}

		while ( true ) {
			$fromState = array_shift( $queue );
			if ( $fromState === null ) {
				break;
			}
			foreach ( $this->yesTransitions[$fromState] as $ch => $toState ) {
				$queue[] = $toState;
				$state = $this->noTransitions[$fromState];

				while ( $state !== 0 && empty( $this->yesTransitions[$state][$ch] ) ) {
					$state = $this->noTransitions[$state];
				}

				if ( isset( $this->yesTransitions[$state][$ch] ) ) {
					$noState = $this->yesTransitions[$state][$ch];
				} else {
					$noState = 0;
				}

				$this->noTransitions[$toState] = $noState;
				$this->outputs[$toState] = array_merge(
					$this->outputs[$toState], $this->outputs[$noState] );
			}
		}
	}
628349
function (input, stateMachine) {
      if (!input) { return []; }
      if (stateMachine === undefined) { stateMachine = 'ce'; }
      var state = '0';

      //
      // String buffers for parsing:
      //
      // buffer.a == amount
      // buffer.o == element
      // buffer.b == left-side superscript
      // buffer.p == left-side subscript
      // buffer.q == right-side subscript
      // buffer.d == right-side superscript
      //
      // buffer.r == arrow
      // buffer.rdt == arrow, script above, type
      // buffer.rd == arrow, script above, content
      // buffer.rqt == arrow, script below, type
      // buffer.rq == arrow, script below, content
      //
      // buffer.text_
      // buffer.rm
      // etc.
      //
      // buffer.parenthesisLevel == int, starting at 0
      // buffer.sb == bool, space before
      // buffer.beginsWithBond == bool
      //
      // These letters are also used as state names.
      //
      // Other states:
      // 0 == begin of main part (arrow/operator unlikely)
      // 1 == next entity
      // 2 == next entity (arrow/operator unlikely)
      // 3 == next atom
      // c == macro
      //
      /** @type {Buffer} */
      var buffer = {};
      buffer['parenthesisLevel'] = 0;

      input = input.replace(/\n/g, " ");
      input = input.replace(/[\u2212\u2013\u2014\u2010]/g, "-");
      input = input.replace(/[\u2026]/g, "...");

      //
      // Looks through mhchemParser.transitions, to execute a matching action
      // (recursive)
      //
      var lastInput;
      var watchdog = 10;
      /** @type {ParserOutput[]} */
      var output = [];
      while (true) {
        if (lastInput !== input) {
          watchdog = 10;
          lastInput = input;
        } else {
          watchdog--;
        }
        //
        // Find actions in transition table
        //
        var machine = mhchemParser.stateMachines[stateMachine];
        var t = machine.transitions[state] || machine.transitions['*'];
        iterateTransitions:
        for (var i=0; i<t.length; i++) {
          var matches = mhchemParser.patterns.match_(t[i].pattern, input);
          if (matches) {
            //
            // Execute actions
            //
            var task = t[i].task;
            for (var iA=0; iA<task.action_.length; iA++) {
              var o;
              //
              // Find and execute action
              //
              if (machine.actions[task.action_[iA].type_]) {
                o = machine.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option);
              } else if (mhchemParser.actions[task.action_[iA].type_]) {
                o = mhchemParser.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option);
              } else {
                throw ["MhchemBugA", "mhchem bug A. Please report. (" + task.action_[iA].type_ + ")"];  // Trying to use non-existing action
              }
              //
              // Add output
              //
              mhchemParser.concatArray(output, o);
            }
            //
            // Set next state,
            // Shorten input,
            // Continue with next character
            //   (= apply only one transition per position)
            //
            state = task.nextState || state;
            if (input.length > 0) {
              if (!task.revisit) {
                input = matches.remainder;
              }
              if (!task.toContinue) {
                break iterateTransitions;
              }
            } else {
              return output;
            }
          }
        }
        //
        // Prevent infinite loop
        //
        if (watchdog <= 0) {
          throw ["MhchemBugU", "mhchem bug U. Please report."];  // Unexpected character
        }
      }
    }
987603
def transition(name, states = self::STATES, transitions = self::TRANSITIONS)
      self.state_machines ||= {}
      self.state_machines[name] = { states: states.values, transitions: transitions }
      self.state_machines[name][:states].each do |this_state|
        method_name = "#{this_state}?".to_sym
        raise 'Method already defined' if self.instance_methods(false).include?(method_name)
        define_method method_name do
          current_state_based_on(this_state) == this_state
        end
      end
    end
833503
def dfa(self, ttab: TransitionTable, init: int = 0) -> int:
        
        state = init
        while True:
            disp = ttab[state]
            ch = self.peek()
            state = disp.get(ch, disp[""])()
            if state < 0:
                return state
            self.offset += 1
318585
void optimizeTransitions()
    {
        HashMap<DFAState<T>,RangeSet> hml = new HashMap<>();
        for (Transition<DFAState<T>> t : transitions.values())
        {
            RangeSet rs = hml.get(t.getTo());
            if (rs == null)
            {
                rs = new RangeSet();
                hml.put(t.getTo(), rs);
            }
            rs.add(t.getCondition());
        }
        transitions.clear();
        for (DFAState<T> dfa : hml.keySet())
        {
            RangeSet rs = RangeSet.merge(hml.get(dfa));
            for (CharRange r : rs)
            {
                addTransition(r, dfa);
            }
        }
    }
13311
public boolean hasBoundaryMatches()
    {
        for (Transition<DFAState<T>> t : transitions.values())
        {
            CharRange range = t.getCondition();
            if (range.getFrom() < 0)
            {
                return true;
            }
        }
        return false;
    }
435580
public Set<Transition<NFAState<T>>> getSingleTransitionTo(NFAState<T> state)
    {
        Set<Transition<NFAState<T>>> set = new HashSet<>();
        if  (transitions.size() != 1)
        {
            return null;
        }
        for (CharRange range : transitions.keySet())
        {
            Set<Transition<NFAState<T>>> s = transitions.get(range);
            for (Transition<NFAState<T>> tr : s)
            {
                if (state.equals(tr.getTo()))
                {
                    set.add(tr);
                }
                else
                {
                    return null;    // to somewhere else
                }
            }
        }
        if (set.isEmpty())
        {
            return null;
        }
        else
        {
            return set;
        }
    }
900496
public Automaton getTransitionPlanned(String name) {
        for (Automaton ps : pendingTransitions) {

            if (ps.name.equals(name)) {
                return ps;
            }
        }
        if (currentState != null && currentState.name.equals(name)) {
            return currentState;
        }
        return null;
    }
774519
private static Transition makeTransitionToJsStringLiteral(
      String literal, final HtmlContext state) {
    return new Transition(literal) {
      @Override
      Context computeNextContext(Context prior, Matcher matcher) {
        return prior
            .toBuilder()
            .withState(state)
            .withSlashType(Context.JsFollowingSlash.NONE)
            .withUriPart(UriPart.NONE)
            .build();
      }
    };
  }
376354
def outputForInput(self, inState, inputSymbol):
        
        for (anInState, anInputSymbol,
             outState, outputSymbols) in self._transitions:
            if (inState, inputSymbol) == (anInState, anInputSymbol):
                return (outState, list(outputSymbols))
        raise NoTransition(state=inState, symbol=inputSymbol)
1078340
def getWmState(self, win, str=False):
        
        states = self._getProperty('_NET_WM_STATE', win) or []
        if not str:
            return states
        return [self._getAtomName(s) for s in states]
790100
public String splitSpecialStateSwitch(String specialStateTransition){
		Matcher transformedSpecialStateMatcher =
				TRANSORMED_SPECIAL_STATE_TRANSITION_METHOD.matcher(specialStateTransition);
		if( !transformedSpecialStateMatcher.find() ){
			return specialStateTransition;
		}
		
		String specialStateSwitch = transformedSpecialStateMatcher.group(3);
		
		Matcher transformedCaseMatcher = TRANSFORMED_CASE_PATTERN.matcher(specialStateSwitch);
		
		StringBuffer switchReplacementBuffer = new StringBuffer();
		StringBuffer extractedMethods = new StringBuffer();
		List<String> extractedCasesList = new ArrayList<String>();

		switchReplacementBuffer.append("$2\n");
		
		boolean methodExtracted = false;
		boolean isFirst = true;
		String from = "0";
		String to = "0";
		//Process individual case statements
		while(transformedCaseMatcher.find()){
			if(isFirst){
				isFirst = false;
				from = transformedCaseMatcher.group(2);
			}
			to = transformedCaseMatcher.group(2);
			extractedCasesList.add(transformedCaseMatcher.group());
			//If the list of not processed extracted cases exceeds the maximal allowed number
			//generate individual method for those cases
			if (extractedCasesList.size() >= casesPerSpecialStateSwitch ){
				generateExtractedSwitch(extractedCasesList, from, to, extractedMethods, switchReplacementBuffer);
				extractedCasesList.clear();
				isFirst = true;
				methodExtracted = true;
			}
		}
		
		//If no method was extracted return the input unchanged
		//or process rest of cases by generating method for them
		if(!methodExtracted){
			return specialStateTransition;
		}else if(!extractedCasesList.isEmpty() && methodExtracted){
			generateExtractedSwitch(extractedCasesList, from, to, extractedMethods, switchReplacementBuffer);
		}
		switchReplacementBuffer.append("$5");
		
		StringBuffer result = new StringBuffer();
		transformedSpecialStateMatcher.appendReplacement( result, switchReplacementBuffer.toString());
		result.append(extractedMethods);
		transformedSpecialStateMatcher.appendTail(result);
		return result.toString();
	}
1045327
public int getTransitionSelectivity()
    {
        int count = 0;
        for (Transition<DFAState<T>> t : transitions.values())
        {
            CharRange range = t.getCondition();
            count += range.getTo()-range.getFrom();
        }
        return count/transitions.size();
    }
851234
private Transition find(String name) {
        for (Transition t : transitions) {
            if (t.getName().matches(name)) {
                return t;
            }
        }
        return null;
    }
559615
def transition(prior_state, next_state):
    
    if next_state not in STATES[prior_state][TRANSITION]:
        acceptable = STATES[prior_state][TRANSITION]
        err = "cannot {}->{} may only {}->{}".format(prior_state,
                                                     next_state,
                                                     prior_state,
                                                     acceptable)
        raise InvalidStateTransition(err)
    return next_state
168490
def state(name):
    '''
    
    '''
    try:
        cmd = 'show {0} --property=State'.format(name)
        return _machinectl(cmd, ignore_retcode=True)['stdout'].split('=')[-1]
    except IndexError:
        return 'stopped'
771394
def get_cont_state(self, string, backward=False):
        
        if string is None:
            return ()
        for _ in self.parser(self.scanner(string, True), True):
            if backward and len(self.parser.state[0]):
                break
        state = tuple(self.parser.state)
        self.scanner.reset()
        self.parser.reset()
        return state