Commit f05f97c5f1cac0de6b05e9a474ff5a713eda58e0

Added ":or" and refactored code with it.
  
2626
2727(defstruct ebnf-prod symbol derives)
2828
29(defun make-or (symbol derives)
30 (mapcan
31 #'(lambda (derive)
32 (expand-ebnf symbol (if (listp derive) derive (list derive))))
33 derives))
34
2935(defun make-repeat (symbol derives)
30 (append
31 (expand-ebnf symbol derives :operation :option)
32 (list (make-ebnf-prod :symbol symbol :derives (list symbol)))))
36 (expand-ebnf symbol (list derives symbol '()) :operation :or))
3337
3438(defun make-option (symbol derives)
35 (append
36 (expand-ebnf symbol derives)
37 (list (make-ebnf-prod :symbol symbol :derives '()))))
39 (expand-ebnf symbol (list derives '()) :operation :or))
3840
3941(defun expand-ebnf (symbol derives &key (operation '()))
4042 (let ((add-prods '()))
4646 (make-repeat symbol derives))
4747 (:option
4848 (make-option symbol derives))
49 (:or
50 (make-or symbol derives))
4951 (otherwise
5052 (list
5153 (make-ebnf-prod
7171 :action action
7272 :action-form action-form))
7373 (expand-ebnf symbol derives)))
74
75(defun make-ebnf-grammar (&key name (start-symbol (required-argument)) terminals precedence productions)
76 (make-grammar :name name :start-symbol start-symbol :terminals terminals :precedence precedence :productions productions))
77
78(defun make-ebnf-parser (grammar
79 &key (discard-memos t) (muffle-conflicts nil)
80 (print-derives-epsilon nil) (print-first-terminals nil)
81 (print-states nil)
82 (print-goto-graph nil) (print-lookaheads nil))
83 (make-parser grammar
84 :discard-memos discard-memos :muffle-conflicts muffle-conflicts
85 :print-derives-epsilon print-derives-epsilon
86 :print-first-terminals print-first-terminals
87 :print-states print-states
88 :print-goto-graph print-goto-graph
89 :print-lookaheads print-lookaheads))