anchor.diff:  ;;;   - prod -> (left-hand-side &rest expansion
   
   
  +(defun gsymbol-name (gsym)
  +  (format nil "~A" gsym))
   
   (defun grammar-map (result function grammar)
     "Applies function to each production in grammar.
  
positive.code:   "Attempt to convert this grammar to right-regular form."
    ;; TODO: prune epsilons, singletons, and redundant nonterminals
    ;;       do this using same steps an CNF conversion
    (let ((new-grammar (make-finite-set))
          (terminals (grammar-terminals grammar))
          (nonterminals (grammar-nonterminals grammar)))
      (labels ((add-production (lhs rhs)
                 (setq new-grammar (finite-set-add new-grammar
                                                   (cons lhs rhs))))
               (add-nonterminal (nonterm)
                 (setq nonterminals (finite-set-add nonterminals nonterm)))
               (simplify (lhs rhs)
                 (cond
                   ;; A -> a | B | :epsilon
                   ((and (= 1 (length rhs)))
                    (add-production lhs rhs))
                   ;; A -> a B
                   ((and (= 2 (length rhs))
                         (finite-set-member terminals (first rhs))
                         (finite-set-member nonterminals (second rhs)))
                    (add-production lhs rhs))
                   ;; A -> a b ALPHA
                   ((and (<= 2 (length rhs))
                         (finite-set-member terminals (first rhs))
                         (finite-set-member terminals (second rhs)))
                    (let ((new-nonterm (gensym "GRAMMAR->RIGHT-REGULAR")))
                      (add-production lhs (list (first rhs) new-nonterm))
                      (add-nonterminal new-nonterm)
                      (simplify new-nonterm (rest rhs))))
                   (t (error "Can't handle ~A => ~A" lhs rhs)))))
        ;; simplify initially
        (grammar-map nil #'simplify grammar))
      (cons (list (gensym "START") (grammar-start-nonterminal grammar))
            new-grammar)))
  
  
  (defun grammar->fa (grammar)
    (unless (grammar-right-regular-p grammar)
      (setq grammar (grammar->right-regular grammar)))
    (let ((terminals (grammar-terminals grammar))
          (nonterminals (grammar-nonterminals grammar))
          (edges)
          (start (caar grammar))
          (accept (gensym "ACCEPT-STATE")))
      (grammar-map nil
                   (lambda (lhs rhs)
                     (cond
  
negative.code: 
  
  (defun grammar-start-nonterminal (grammar)
  "Return the starting nonterminal of GRAMMAR."
    (caar grammar))
  
  (defun grammar-substitute-terminal-list
  