Skip to content

Commit

Permalink
rename other traversal evaluators to eval
Browse files Browse the repository at this point in the history
  • Loading branch information
countvajhula committed Feb 21, 2025
1 parent cf57a49 commit 30fd937
Showing 1 changed file with 67 additions and 67 deletions.
134 changes: 67 additions & 67 deletions symex-evaluator.el
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ requiring changes to higher-level code that uses the present interface."
(symex--go-down (abs move-y)))
(t symex--move-zero))))

(defun symex-execute-move (move &optional computation result)
(defun symex-eval-move (move &optional computation result)
"Execute the MOVE as a traversal.
This returns a list of moves (singleton, in this case) rather than the
Expand All @@ -73,7 +73,7 @@ Optional argument COMPUTATION currently unused."
executed-move)
computation))))

(defun symex-execute-maneuver (maneuver computation result)
(defun symex-eval-maneuver (maneuver computation result)
"Attempt to execute a given MANEUVER.
Attempts the maneuver in the order of its phases. The maneuver
Expand All @@ -88,11 +88,11 @@ Evaluates to a COMPUTATION on the traversal actually executed."
computation
result)))
(when executed-phase
(symex-execute-maneuver remaining-maneuver
computation
executed-phase))))))
(symex-eval-maneuver remaining-maneuver
computation
executed-phase))))))

(defun symex-execute-venture (venture computation result)
(defun symex-eval-venture (venture computation result)
"Attempt to execute a given VENTURE.
Similar to maneuver execution, except that it accepts partial
Expand All @@ -114,14 +114,14 @@ Evaluates to a COMPUTATION on the traversal actually executed."
result)))
(when executed-phase
(let ((accumulated-result
(symex-execute-venture remaining-venture
computation
executed-phase)))
(symex-eval-venture remaining-venture
computation
executed-phase)))
(if accumulated-result
accumulated-result
executed-phase)))))))

(defun symex-execute-circuit (circuit computation result)
(defun symex-eval-circuit (circuit computation result)
"Execute a CIRCUIT.
This repeats some traversal as specified.
Expand All @@ -136,9 +136,9 @@ Evaluates to a COMPUTATION on the traversal actually executed."
computation
result)))
(if executed-phase
(symex-execute-circuit remaining-circuit
computation
executed-phase)
(symex-eval-circuit remaining-circuit
computation
executed-phase)
(when (not times)
;; if looping indefinitely, then count 0
;; times executed as success
Expand All @@ -149,7 +149,7 @@ Evaluates to a COMPUTATION on the traversal actually executed."
;; used with Symex, e.g. in precautions, decisions, etc. Then this
;; could be implemented as a circuit repeating a precaution on an
;; underlying traversal.
(defun symex-execute-loop (loop computation result)
(defun symex-eval-loop (loop computation result)
"Execute a LOOP.
This repeats some traversal according to a condition on the computation.
Expand All @@ -163,11 +163,11 @@ Evaluates to a COMPUTATION on the traversal actually executed."
(when accumulated-result
(if (funcall condition accumulated-result)
accumulated-result
(symex-execute-loop loop
computation
accumulated-result))))))
(symex-eval-loop loop
computation
accumulated-result))))))

(defun symex-execute-detour (detour computation result)
(defun symex-eval-detour (detour computation result)
"Execute the DETOUR.
Apply a reorientation and then attempt the traversal.
Expand All @@ -188,7 +188,7 @@ Evaluates to a COMPUTATION on the traversal actually executed."
computation
executed-reorientation))))))

(defun symex-execute-precaution (precaution computation result)
(defun symex-eval-precaution (precaution computation result)
"Attempt to execute a given PRECAUTION.
The traversal is only executed if PRE-CONDITION holds, and is reversed if
Expand All @@ -205,7 +205,7 @@ Evaluates to a COMPUTATION on the traversal actually executed."
(when (funcall post-condition)
executed-traversal)))))

(defun symex-execute-protocol (protocol computation result)
(defun symex-eval-protocol (protocol computation result)
"Attempt to execute a given PROTOCOL.
Given a protocol including a set of options, attempt to execute them
Expand All @@ -220,11 +220,11 @@ Evaluates to a COMPUTATION on the traversal actually executed."
result)))
(if executed-option
executed-option
(symex-execute-protocol remaining-protocol
computation
result))))))
(symex-eval-protocol remaining-protocol
computation
result))))))

(defun symex-execute-decision (decision computation result)
(defun symex-eval-decision (decision computation result)
"Attempt to execute a given DECISION.
The consequent traversal is executed if the condition holds, and the
Expand All @@ -242,7 +242,7 @@ Evaluates to a COMPUTATION on the traversal actually executed."
computation
result))))

(defun symex-execute-deletion (deletion computation result)
(defun symex-eval-deletion (deletion computation result)
"Attempt to execute a given DELETION.
This could delete `this`, `previous` or `next`. Of these, favor the
Expand All @@ -264,7 +264,7 @@ Evaluates to a COMPUTATION on the traversal actually executed."
(when this-result
result))))

(defun symex-execute-paste (paste computation result)
(defun symex-eval-paste (paste computation result)
"Attempt to execute a given PASTE.
Evaluates to a COMPUTATION on the traversal actually executed."
Expand All @@ -274,7 +274,7 @@ Evaluates to a COMPUTATION on the traversal actually executed."
(when this-result
result))))

(defun symex-execute-effect (effect computation result)
(defun symex-eval-effect (effect computation result)
"Attempt to execute a given EFFECT.
Evaluates to a COMPUTATION on the traversal actually executed."
Expand All @@ -288,56 +288,56 @@ Evaluates to a COMPUTATION on the traversal actually executed."
;; ignore the result of the effect
executed-traversal)))))

(defun symex--execute-traversal (traversal computation result)
(defun symex--eval (traversal computation result)
"Helper to execute TRAVERSAL and perform COMPUTATION."
(cond ((symex-maneuver-p traversal)
(symex-execute-maneuver traversal
computation
result))
(symex-eval-maneuver traversal
computation
result))
((symex-venture-p traversal)
(symex-execute-venture traversal
computation
result))
(symex-eval-venture traversal
computation
result))
((symex-circuit-p traversal)
(symex-execute-circuit traversal
computation
result))
((symex-loop-p traversal)
(symex-execute-loop traversal
(symex-eval-circuit traversal
computation
result))
((symex-loop-p traversal)
(symex-eval-loop traversal
computation
result))
((symex-protocol-p traversal)
(symex-execute-protocol traversal
computation
result))
(symex-eval-protocol traversal
computation
result))
((symex-precaution-p traversal)
(symex-execute-precaution traversal
computation
result))
(symex-eval-precaution traversal
computation
result))
((symex-detour-p traversal)
(symex-execute-detour traversal
computation
result))
(symex-eval-detour traversal
computation
result))
((symex-decision-p traversal)
(symex-execute-decision traversal
computation
result))
(symex-eval-decision traversal
computation
result))
((symex-move-p traversal)
(symex-execute-move traversal
computation
result))
(symex-eval-move traversal
computation
result))
((symex-delete-p traversal)
(symex-execute-deletion traversal
computation
result))
((symex-paste-p traversal)
(symex-execute-paste traversal
(symex-eval-deletion traversal
computation
result))
((symex-paste-p traversal)
(symex-eval-paste traversal
computation
result))
((symex-effect-p traversal)
(symex-execute-effect traversal
computation
result))
(symex-eval-effect traversal
computation
result))
;; TODO: return accumulated result
;; and ignore result of function invocation
(t (funcall traversal))))
Expand All @@ -357,18 +357,18 @@ Evaluates to a COMPUTATION on the traversal actually executed."
computation
symex--computation-default))
(result (or result
(symex-execute-move symex--move-zero
computation))))
(symex-eval-move symex--move-zero
computation))))
;; TODO: a macro similar to `symex-save-excursion`
;; where it conditionally returns to the original
;; point / node depending on whether BODY succeeds
;; or which tests for success before moving point
(let ((original-location (point))
(original-point-height-offset
(symex--point-height-offset))
(new-result (symex--execute-traversal traversal
computation
result)))
(new-result (symex--eval traversal
computation
result)))
(if new-result
new-result
;; TODO: simply returning to the original location
Expand Down

0 comments on commit 30fd937

Please sign in to comment.