[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to save annotations?



I defined a "symlink" decor for annotating my formalism, in the way it
is suggested in the manual (i.e. by extending the formalism). I
thought the advantage would be that such annotations could be stored
and restored using {tree}:save and {tree}:restore (this works for
comments, which should be implemented a similar way, aren't they?)

It seems, however, not to work for my "symlink" annotations:

;; a tree that has a "symlink" annotation
? tree
= #<Glider let_term>
? ;;;Describe object:
#<Glider let_term> is a #:tree:Glider:let_term
  name: fragment-Glider-let_term
  operator: #<operator let_term>
  sons: (#<Glider var_binding_nelist>#<Glider metavariable TERM2>)
  father: #<Trees product_every>

? ({tree}:down tree "symlink")
= #<Glider symlink>

? ({tree}:save "/tmp/toto" tree)
= #<Glider let_term>
? (setq restored-tree ({tree}:restore "toto" "/tmp"))
= #<Glider let_term>
? ;;;Describe object:
#<Glider let_term> is a #:tree:Glider:let_term
  name: fragment-Glider-let_term
  operator: #<operator let_term>
  sons: (#<Glider var_binding_nelist>#<Glider metavariable TERM2>)
  father: ()
= ()

? (eq tree restored-tree)
= ()
? ({tree}:down restored-tree "symlink")
= ()
? 

Can annotations not be stored? 
Am I missing sth.?

	Guido

P.S.: Here is the function that I use to extended my formalism,
      in order to obtain annotations:

(de :add-symlink-annotations (formalism)
  ;; Augment FORMALISM by the phylum `SYMLINK' and the operator `symlink'.
  ;; Annotate the {tree} class with a `symlink' decor.
  ;; Returns the `symlink' decor. 
  (or
   ;; Alas, `{name}:decor' produces a `not_found' exeption.
   ;; The vtp-condition-case form catches it. 
   (vtp-condition-case var
       ({name}:decor 'symlink {tree} formalism)
     (not_found nil))
      
   ;; Extend FORMALISM by a `SYMLINK' phylum and a `symlink' operator,
   ;; which then are used as annotations for any tree of FORMALISM.
   (let ((symlink-phylum
	  (or (vtp-condition-case var
		  ({name}:phylum 'SYMLINK formalism)
		(not_found nil))
	      ({phylum}:make 'SYMLINK formalism)))
	 (symlink-operator
	  (or (vtp-condition-case var
		  ({name}:operator 'symlink formalism)
		(not_found nil))
	      ({operator}:make 'symlink formalism 0 {name})))
	 (symlink-decor
	  ({tree}:new_decor 'symlink {tree} formalism)))

     ;; add the symlink-operator to the symlink-phylum
     ({phylum}:insert symlink-phylum symlink-operator)

     ({decor}:set-phylum symlink-decor symlink-phylum)

     ;; complete the modifications of the formalism
     ({formalism}:complete formalism)
     
     symlink-decor)))