Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Joel Reymont <joelr1@gmail.com>
To: Francois.Pottier@inria.fr
Subject: Functors and sharing a symbol table between a Menhir parser and ocamllex lexer
Date: Tue, 1 May 2007 11:34:48 +0100	[thread overview]
Message-ID: <6E3B0D38-E618-49F6-A69A-28524EA6C495@gmail.com> (raw)

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/


                 reply	other threads:[~2007-05-01 12:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6E3B0D38-E618-49F6-A69A-28524EA6C495@gmail.com \
    --to=joelr1@gmail.com \
    --cc=Francois.Pottier@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox