Class FiniteAutomaton.Automaton<E>

  • Type Parameters:
    E -
    Enclosing class:
    FiniteAutomaton

    public static class FiniteAutomaton.Automaton<E>
    extends java.lang.Object
    A component automaton with a single start state and a single end state.
    • Method Detail

      • apply

        public boolean apply​(java.util.List<E> tokens)
      • minMatchingLength

        public int minMatchingLength()
      • lookingAt

        public Match.FinalMatch<E> lookingAt​(java.util.List<E> tokens,
                                             int startIndex)
        Returns:
        null if no match, otherwise a representation of the match
      • buildMatch

        private FiniteAutomaton.State<E> buildMatch​(java.util.Iterator<E> tokenIterator,
                                                    Expression<E> expression,
                                                    java.util.concurrent.atomic.AtomicInteger index,
                                                    FiniteAutomaton.State<E> state,
                                                    java.util.Iterator<FiniteAutomaton.AbstractEdge<E>> edgeIterator,
                                                    Match.IntermediateMatch<E> match)
        Retrace the path through the NFA and produce an object that represents the match.
        Parameters:
        tokenIterator - an iterator over the tokens.
        expression - the expression to match.
        index - the present index.
        state - the present state.
        edgeIterator - an iterator over the edges in the solution.
        match - the solution.
        Returns:
      • expandEpsilons

        private void expandEpsilons​(java.util.List<FiniteAutomaton.Automaton.Step<E>> steps)
        Expand all epsilon transitions for the supplied steps. That is, add all states available via an epsilon transition from a supplied state to the list.
        Parameters:
        steps -
      • expandAssertions

        private void expandAssertions​(java.util.List<FiniteAutomaton.Automaton.Step<E>> steps,
                                      java.util.List<FiniteAutomaton.Automaton.Step<E>> newsteps,
                                      boolean hasStart,
                                      java.util.List<E> tokens,
                                      int totalTokens)
        Expand any state that has an assertion edge if the assertion passes given the present state.
        Parameters:
        steps -
        newsteps -
        hasStart - true iff the tokens contains the start token.
        tokens -
        totalTokens -
      • evaluate

        private FiniteAutomaton.Automaton.Step<E> evaluate​(java.util.List<E> tokens,
                                                           java.util.List<FiniteAutomaton.Automaton.Step<E>> steps,
                                                           boolean hasStart)
        Evaluate the NFA against the list of tokens using the Thompson NFA algorithm.
        Parameters:
        tokens - the tokens to evaluate against
        steps - present list of accessible states.
        hasStart - true iff tokens contains the start token.
        Returns:
        a Step object representing the last transition or null.