maude: owise (otherwise) equations (8 tests, 229 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
Parser reads trailing eq attributes (eq L = R [owise] .) via mau/split-attrs. mau/crewrite-top is two-pass: ordinary equations first, owise last — an owise catch-all fires only when no ordinary equation applies, regardless of declaration order. Verified a catch-all declared first still defers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
;; subsort/subsorts A B < C < D .
|
||||
;; op/ops NAMES : ARITY -> RESULT [ATTRS] .
|
||||
;; var/vars NAMES : SORT .
|
||||
;; eq LHS = RHS . ceq LHS = RHS if COND .
|
||||
;; rl [L] : LHS => RHS . crl [L] : LHS => RHS if COND .
|
||||
;; eq LHS = RHS [ATTRS] . ceq LHS = RHS if COND [ATTRS] .
|
||||
;; rl [L] : LHS => RHS . crl [L] : LHS => RHS if COND .
|
||||
;;
|
||||
;; Terms: prefix application f(a,b) (op name may contain underscores, e.g.
|
||||
;; the prefix form _+_(2,3)); mixfix prefix s_ written `s X`; mixfix infix
|
||||
@@ -384,6 +384,8 @@
|
||||
(do (dict-set! acc :idem true) (loop (rest ts))))
|
||||
((= (first ts) "ctor")
|
||||
(do (dict-set! acc :ctor true) (loop (rest ts))))
|
||||
((= (first ts) "owise")
|
||||
(do (dict-set! acc :owise true) (loop (rest ts))))
|
||||
((= (first ts) "id:")
|
||||
(do
|
||||
(dict-set! acc :id (nth ts 1))
|
||||
@@ -392,6 +394,10 @@
|
||||
(do
|
||||
(dict-set! acc :prec (parse-number (nth ts 1)))
|
||||
(loop (mau/drop ts 2))))
|
||||
((= (first ts) "label")
|
||||
(do
|
||||
(dict-set! acc :label (nth ts 1))
|
||||
(loop (mau/drop ts 2))))
|
||||
(else (loop (rest ts))))))
|
||||
(do (loop toks) acc))))
|
||||
|
||||
@@ -404,6 +410,9 @@
|
||||
{}
|
||||
(mau/parse-attr-tokens (mau/strip-brackets toks)))))
|
||||
|
||||
;; Split a token sequence into {:term tokens-before-bracket :attrs parsed}.
|
||||
(define mau/split-attrs (fn (toks) {:attrs (mau/parse-attrs (mau/drop-until toks "[")) :term (mau/take-until toks "[")}))
|
||||
|
||||
;; ---------- signature collection ----------
|
||||
|
||||
(define
|
||||
@@ -514,9 +523,9 @@
|
||||
conditional?
|
||||
(let
|
||||
((rhs-toks (mau/take-until after "if"))
|
||||
(cond-toks (rest (mau/drop-until after "if"))))
|
||||
{:lhs (mau/parse-term lhs-toks grammar) :t :eq :cond (mau/parse-cond cond-toks grammar) :rhs (mau/parse-term rhs-toks grammar)})
|
||||
{:lhs (mau/parse-term lhs-toks grammar) :t :eq :cond nil :rhs (mau/parse-term after grammar)}))))
|
||||
(cond-raw (rest (mau/drop-until after "if"))))
|
||||
(let ((csplit (mau/split-attrs cond-raw))) {:lhs (mau/parse-term lhs-toks grammar) :t :eq :cond (mau/parse-cond (get csplit :term) grammar) :rhs (mau/parse-term rhs-toks grammar) :owise (= (get (get csplit :attrs) :owise) true)}))
|
||||
(let ((rsplit (mau/split-attrs after))) {:lhs (mau/parse-term lhs-toks grammar) :t :eq :cond nil :rhs (mau/parse-term (get rsplit :term) grammar) :owise (= (get (get rsplit :attrs) :owise) true)})))))
|
||||
|
||||
(define
|
||||
mau/strip-label
|
||||
@@ -548,8 +557,8 @@
|
||||
(let
|
||||
((rhs-toks (mau/take-until after "if"))
|
||||
(cond-toks (rest (mau/drop-until after "if"))))
|
||||
{:lhs (mau/parse-term lhs-toks grammar) :label label :t :rule :cond (mau/parse-cond cond-toks grammar) :rhs (mau/parse-term rhs-toks grammar)})
|
||||
{:lhs (mau/parse-term lhs-toks grammar) :label label :t :rule :cond nil :rhs (mau/parse-term after grammar)}))))))
|
||||
{:lhs (mau/parse-term lhs-toks grammar) :label label :t :rule :cond (mau/parse-cond (get (mau/split-attrs cond-toks) :term) grammar) :rhs (mau/parse-term rhs-toks grammar)})
|
||||
{:lhs (mau/parse-term lhs-toks grammar) :label label :t :rule :cond nil :rhs (mau/parse-term (get (mau/split-attrs after) :term) grammar)}))))))
|
||||
|
||||
(define
|
||||
mau/collect-rules!
|
||||
|
||||
Reference in New Issue
Block a user