[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to save annotations?
- Subject: Re: how to save annotations?
- From: prunet@oaxaca.inria.fr (Vincent Prunet)
- Date: 24 Nov 92 15:46:58 GMT
In article <34580@sophia.inria.fr>, Guido.Bosch@loria.fr (Guido Bosch) writes:
|> 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:
|> [...]
|> Can annotations not be stored?
|> Am I missing sth.?
Annotations can be stored, provided that the "sauver" control flag is set on
the decor.
({decor}:control <decor> 'sauver t)
See the Vtp manual page 10.
|>
|> 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)))
|>
|>
The SYMLINK phylum and operator are not necessary. An annotation value may
belong to any know vtp class, including {name}.
Create the decor by :
(setq decor ({tree}:new_decor 'symlink {name} formalism))
Set the sauver flag:
({decor}:control decor 'sauver t)
Then you may annotate a tree with a name value, save and then restore the
annotated tree.
Get a tree ,
set a value:
({tree}:change_son tree "value of the annotation" 'symlink)
get the value:
({tree}:down tree 'symlink)
save and restore the tree.
Warning: It is unsafe to add operators and phyla to a formalism and then use
polish files. When a tree is stored using polish notation, operator names
are encoded by numbers. These numbers are computed from the current
formalism tables. If the formalism is modified, the index of operators may
be changed, and old polish files cannot be read.
--
Vincent Prunet, Sema Group Sophia Antipolis
INRIA BP 93 06902 SOPHIA ANTIPOLIS Cedex FRANCE
prunet@sophia.inria.fr, (33) 93 65 78 42, Fax:(33) 93 65 77 66