Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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

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

Jeremy.