caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Functors and sharing a symbol table between a Menhir parser and ocamllex lexer
@ 2007-05-01 10:34 Joel Reymont
  0 siblings, 0 replies; only message in thread
From: Joel Reymont @ 2007-05-01 10:34 UTC (permalink / raw)
  To: Francois.Pottier

I want to pass a symbol table to my Menhir parser since I want to run  
several parsers in parallel and don't want any shared state.

I have this in the header of my ocamllex lexer:

   module P = EasyParser.Make
     (
       struct
         type t = EasySymtab.symtab_t
         let putsym = EasySymtab.putsym
         let infer_type = EasyCheck.infer_type
         let symtype = EasyCheck.symtype
       end
     )

rule token tab = parse
...

Above are functions that take a symbol table as their first argument  
and the lexer (token) takes the symbol table as well.

In my parser test harness I have:

let parse str =
   let lexbuf = Lexing.from_string str in
   let ast = EasyLexer.P.program (EasyLexer.token (symtab ())) lexbuf in
   List.map EasyLocStrip.strip_stmt ast

How do I ensure that the lexer and the parser use the same symbol table?

I thought I could parameterize the parser on curried functions like  
"putsym tab" but then how do I make sure that all functions in Make  
above take the same tab?

If that works than I need to ensure that EasyLexer.token in my parse  
function takes the same tab that  was used by EasyParser.Make.

Any suggestions?

	Thanks, Joel

--
http://wagerlabs.com/


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-05-01 12:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-01 10:34 Functors and sharing a symbol table between a Menhir parser and ocamllex lexer Joel Reymont

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).