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

Re: probleme



In article <DSTMay24.184209.18830@sophia.inria.fr>, fevrier@chambord-gw.univ-orleans.fr writes:

|> Permettez-moi de vous presenter le probleme sous un autre angle.
|> Je developpe un langage L. Lors de l'evaluation en TYPOL,
|> j'ai envie (en fait j'ai besoin) d'attacher diverses informations
|> aux noeuds de l'arbre abstrait sous la forme d'annotations.
|> 
|> Pour cela, il faut que je prenne ma variable TYPOL, que je
|> la convertisse en arbre VTP.
|> 
|> Oui, mais... je n'y arrive pas.
|> 
|> Par exemple la regle TYPOL suivante :
|>  sendtree("test",PGM)  &
|> env, |- PGM : env'
|> ----------------
|> env |- pgm(int I, PGM) : env' ;
|> 
|> Je desire mettre une annotation au noeud de l'arbre PGM.
|> A l'execution, on me dit que la var 'test' est inconnue. Si
|> je l'instancie a quelque chose, histoire de, j'ai une erreur.
|> 
|> Je me doute que la solution est simple, a base de  sendtree puis
|> annot/noannot pour les annotations mais je n'arrive pas a m'en sortir.
|> 
|> Quelle erreur ais-je pu faire ? Comment gerer ma variable lisp 'test'?

The question is: how handle annotation using Typol.

Ce probleme me semble different du precedent. En tout cas la solution existe
et est tres simple.

1) declare a decor in the environment for your language. The following
function declare an annotation of type tree, with name "name" for the formalism
"lang" if it does not already exist.

Declarer un decor (type d'annotation) dans l'environnement du langage.
La fonction suivante declare une annotation de type tree, de nom "name" pour
un formalisme "lang" si elle n'existe pas deja:

(defun new_decor (name lang)
    (lock
        (lambda (tag val)
            (cond
                ((eq tag 'not_found)
                    ({tree}:new_decor name 'tree ({name}:formalism lang)))
                (tag (evexit tag val))
                (t val)))
        ({name}:decor name 'tree ({name}:formalism lang))))

2) If necessary, modify some parameter for this decor (see the documentation)

Eventuellement modifier certains parametres de l'annotation (voir la doc).

(defun decor_control (name lang flag value)
    ({decor}:controle
        ({name}:decor name 'tree ({name}:formalism lang)) flag value))

3) In Typol use getannot, noannot, annot, and sendannot.

En Typol utiliser getannot, noannot, annot et sendannot:

import
   getannot(path, string, _), noannot(path, string), annot(path, string),
   sendannot(path, string, _) from prolog;

example:

env, T |- ... -> C
---------------
env |- f(A, B);
	provided getannot(subject, "type", T);
	do sendannot(s(subject, int 1), "code", C);

The data is already decorated with an annotation named "type".
We compute some code, using this annotation. This code is
attached to the first son of the current operator, A.

En supposant que la donnee est deja annotee par une annotation "type",
on calcule du code en utilisant cette annotation. Ce code  est ensuite
attache comme annotation au premier fils de f (pour les besoins de 
l'exmple).


-- 
Send contributions and compliments to centaur@sophia.inria.fr. Registration
and administrative matters should be sent to centaur-request@sophia.inria.fr.
+---------------------------------------------------------------------------+
|     Thierry Despeyroux      | email: Thierry.Despeyroux@sophia.inria.fr   |
| I.N.R.I.A. Sophia-Antipolis | phone: +33 93 65 77 07 fax: +33 93 65 77 66 |
+---------------------------------------------------------------------------+