anchor.diff:  ;;;;   EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   
   
  -;;; DFA
  -;;;  -(Q, E, d, q0, F),
  -;;;    - Q: states
  -;;;    - E: alphabet
  -;;;    - d: Q*E :-> Q
  -;;;    - q0: start state
  -;;;    - F: accept state
  -
  -
  -(defun dfa-dot (d &key output final start)
  +;;; FA
  +;;;  -(states, tokens, edges, start, accept),
  +;;;    - edges: (list state-0 token state-1)
  +
  +(defstruct (fa (:constructor %make-fa))
  +  states
  +  tokens
  +  edges
  +  start
  +  accept
  +  reject)
  +
  +(defun make-fa (edges start accept)
  +  (let (states tokens)
  +    (map nil (lambda (x)
  +               (destructuring-bind (q0 z q1) x
  +                 (pushnew q0 states :test #'equal)
  +                 (pushnew q1 states :test #'equal)
  +                 (pushnew z tokens :test #'equal)))
  +         edges)
  +    (%make-fa :states states
  +              :tokens tokens
  +              :edges edges
  +              :start (alexandria:ensure-list start)
  +              :accept (alexandria:ensure-list accept))))
  +
  +
  +(defun fa-dot (fa &optional output )
     "Graphviz output of dfa.
   d: list of transitions '((state-0 token state-1)...)
   final: list of accept states
  
positive.code:                state-hash)
        (maphash (lambda (n d) (setf (aref token-array d) n))
                 token-hash)
        (values nedges (gethash start state-hash)
                state-array token-array))))
  
  (defun nfa-et-closure (states z mover)
  "Epsilon-closure for list states transitioning by token z.
  STATES: list of states
  Z: token
  MOVER: fuction from (state token) => (list states)"
    (let ((stack (copy-list states))
          (closure nil))
      (loop
  
negative.code:            while (< mark (length d-states))
             for ds = (aref d-states mark)
             do (progn
                  (loop
                     for i-z below (length i-tokens)
                     for u = (sort (nfa-et-closure ds i-z mover) #'<)
  