The interpreter tool

In the Exp environment, we must subtype the standard Typol tool class to allow the interpreter tool to memorize information required for its normal operation. In addition to the source tree (available through the source ctedit), the tool must keep track of an initial environment tree. Rather than store just the tree, we prefer to store a Centaur variable structure because later we will want to modify the input Vtp tree and this should be performed through the Centaur variable interface.

Tool classes are defined as Le-Lisp structures, so we define a subtype of the standard Typol class with the following code:


;;;;;;;;;;;;;;
;;Tool creation
;;;;;;;;;;;;;;
(setq #:sys-package:colon '#:Exp:interpreter)

(eval-when (load eval compile)
   (defstruct #:centaur-tool:formalism:typol:std:Exp 
              initial-environment))

;;We could also pass an initial environment tree to the
;;following function.

(de :tool:create (ctedit)
  (let ((new (#:centaur-tool:formalism:typol:std:Exp:make))
        (variable ({variable}:make ()))
        )
     ;;Create the variable network [not done by
     ;;the {variable}:make function].
     ({#:stnode:variable}:create variable)
     ;;Initialize tool.
     (send 'name new 'interpreter)
     (send 'formalism-name new 'Exp)
     (send 'source new ctedit)
     (#:centaur-tool:formalism:typol:std:Exp:initial-environment
           new variable)
     new))

(de :tool:get-source (tool)
    ({variable}:root ({ctedit}:subject (send 'source tool))))

(de :tool:get-initial-env (tool)
    ({variable}:root (send 'initial-environment tool)))

(de :tool:set-initial-env (tool env-tree)
    (let ((variable (send 'initial-environment tool)))
      ;;This call provokes a redisplay in any ctedits
      ;;containing this variable.
      ({variable}:change variable
                         ({variable}:root variable)
                         env-tree)))

We have also defined a convenient functions to create an initial tool, get the source tree, and get and set the tree used as the initial environment.


Tutorial