English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Passing arguments to a parser generated by ocamlyacc
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-03-28 (10:53)
From: Jeremy Yallop <jeremy.yallop@e...>
Subject: Re: [Caml-list] Passing arguments to a parser generated by ocamlyacc
Joel Reymont wrote:
> I need to pass a symbol table to the parser generated by ocamlyacc. I 
> can do this fine with ocamllex and thought I could do the following for 
> ocamlyacc:
> %start program
> %type <Symtab.symtab -> Easy.program> program
> It doesn't work, unfortunately. Are there any workarounds?

One possible solution is to pass it as part of the value of each token 
returned by the lexer, e.g.

    %token <Symtab.symtab> TOKEN

      TOKEN ...    { let symtab = $1 in ... }