116 | 116 |
(t (setf result (make-bconst-term *syntax-err-sort*
|
117 | 117 |
(if res
|
118 | 118 |
res
|
119 | |
preterm)))
|
120 | |
))
|
|
119 |
preterm)))))
|
121 | 120 |
;;
|
122 | 121 |
(setq *parse-raw-parse* result)
|
123 | 122 |
(when (term-ill-defined result)
|
124 | 123 |
(with-output-simple-msg ()
|
125 | 124 |
(format t "~&[Error] no successful parse")
|
126 | |
(print-next)
|
127 | |
;; (print-term-tree result t)
|
128 | |
;; (term-print result)
|
129 | |
))
|
130 | |
(parse-convert result module))))
|
131 | |
))
|
|
125 |
(print-next)))
|
|
126 |
(parse-convert result module))))))
|
132 | 127 |
|
133 | 128 |
(defun select-parse (module final &optional print-warning)
|
134 | 129 |
(declare (type module module)
|
|
179 | 174 |
(nth (1- choise) final)))
|
180 | 175 |
(progn
|
181 | 176 |
(parse-show-diff final)
|
182 | |
(make-bconst-term *syntax-err-sort* "ambiguous term")
|
183 | |
))
|
184 | |
))
|
|
177 |
(make-bconst-term *syntax-err-sort* "ambiguous term")))))
|
185 | 178 |
|
186 | 179 |
(defun pre-choose-final-sub (module final)
|
187 | 180 |
(declare (type module module)
|
|
265 | 258 |
result)
|
266 | 259 |
res)
|
267 | 260 |
(setq result res))
|
268 | |
|
269 | 261 |
(t (setq gen-op (choose-most-general-op mslist))
|
270 | 262 |
;; then select most general one
|
271 | 263 |
(when gen-op
|
272 | 264 |
(push (find-if #'(lambda (x) (method= gen-op (term-head x))) result)
|
273 | 265 |
res)
|
274 | 266 |
(setq result res)))))))
|
275 | |
(pre-choose-final-sub module result)))
|
|
267 |
(if result
|
|
268 |
(pre-choose-final-sub module result)
|
|
269 |
(pre-choose-final-sub module final))))
|
276 | 270 |
|
277 | 271 |
;;; NOT USED NOW.
|
278 | 272 |
(defun parser-diagnose (module preterm sort)
|
|
535 | 529 |
(defun parser-find-rule-pair (module lhslst rhslst)
|
536 | 530 |
(declare (type module module)
|
537 | 531 |
(type list lhslst rhslst))
|
538 | |
(let ((*current-module* module))
|
|
532 |
(with-in-module (module)
|
539 | 533 |
(let ((so (module-sort-order module))
|
540 | 534 |
(ok nil)
|
541 | |
(retr nil)
|
542 | |
(ill nil))
|
|
535 |
(retr nil))
|
|
536 |
;; foreach lhs:lhslst {
|
|
537 |
;; foreach rhs:rhslst {
|
543 | 538 |
(dolist (lhs lhslst)
|
544 | |
(let ((sl (term-sort lhs)))
|
545 | |
(dolist (rhs rhslst)
|
546 | |
(let ((sr (term-sort rhs)))
|
547 | |
(if (term-ill-defined lhs)
|
548 | |
(push (list lhs rhs) ill)
|
549 | |
(if (term-head-is-error lhs)
|
550 | |
(if (is-in-same-connected-component sl sr so)
|
551 | |
(push (list lhs rhs) retr)
|
552 | |
;; else, completely bad, unacceptable
|
553 | |
())
|
554 | |
;; lhs is proper term
|
555 | |
(if (sort<= sr sl so)
|
556 | |
(if (term-ill-defined rhs)
|
557 | |
(push (list lhs rhs) ill)
|
558 | |
(push (list lhs rhs) ok))
|
559 | |
(if (is-in-same-connected-component sl sr so)
|
560 | |
(if (term-ill-defined rhs)
|
561 | |
(push (list lhs rhs) ill)
|
562 | |
(push (list lhs rhs) retr))
|
563 | |
;; lhs and rhs is not in same compo.
|
564 | |
()
|
565 | |
)
|
566 | |
))))
|
567 | |
)))
|
568 | |
(if ok
|
569 | |
ok
|
570 | |
(if retr
|
571 | |
retr
|
572 | |
nil))
|
573 | |
)))
|
|
539 |
(block cont-lhs
|
|
540 |
(when *on-axiom-debug*
|
|
541 |
(format t "~%lhs: ")
|
|
542 |
(term-print-with-sort lhs))
|
|
543 |
(when (term-ill-defined lhs)
|
|
544 |
(return-from cont-lhs)) ; skip it and continue
|
|
545 |
(let ((sl (term-sort lhs)))
|
|
546 |
(dolist (rhs rhslst)
|
|
547 |
(block cont-rhs
|
|
548 |
(when *on-axiom-debug*
|
|
549 |
(format t "~&rhs: ")
|
|
550 |
(term-print-with-sort rhs))
|
|
551 |
(when (term-ill-defined rhs)
|
|
552 |
(return-from cont-rhs)) ; continue it and continue
|
|
553 |
(let ((sr (term-sort rhs)))
|
|
554 |
(if (sort<= sr sl so)
|
|
555 |
(push (list lhs rhs) ok)
|
|
556 |
(when (is-in-same-connected-component sl sr so)
|
|
557 |
(push (list lhs rhs) retr)))))))))
|
|
558 |
;;
|
|
559 |
(or ok retr nil))))
|
574 | 560 |
|
575 | 561 |
;;; used in modexp-compute-op-mapping
|
576 | 562 |
;;;
|