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

Re: (No Subject)



About keeping lines in the abstract syntax...

I also use a language in which I want to keep some line information
in the abstract syntax.

The problem is that Metal wants each token to come with a value.
The solution is in the metal file.
In my case the token is called LINE ( return(LINE) in the .tokens file).
I use two Metal rules:
      <declaration> ::= <line> ;
         line ()
      <line> ::= %LINE ;
         id-atom(%LINE)
The second one constructs an atomic node, with the value returned by lex.
The first one throws it away and constructs what I really want.

---
Voila ce que je fais pour un langage dans lequel je veux aussi conserver
des informations de ligne.

Le probleme est que Metal reclame que chaque token ait une valeur.
La solution est donc dans le fichier Metal.
Dans mon cas le token est appelle LINE ( return(LINE) dans le fichier .tokens).
J'utilise 2 regles Metal:
      <declaration> ::= <line> ;
         line ()
      <line> ::= %LINE ;
         id-atom(%LINE)
La seconde costruit un noeud bidon, avec comme valeur ce qui est retourne
par lex. La premiere balance ce noeud illico et construit ce dont j'ai
reellement besoin.

Thierry
-- 
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 |
+---------------------------------------------------------------------------+