caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Joel Reymont <joelr1@gmail.com>
To: Caml List <caml-list@inria.fr>
Subject: Hacking Parsing to be re-entrant
Date: Fri, 30 Mar 2007 14:30:00 +0100	[thread overview]
Message-ID: <7F1226C5-BB02-443B-8854-785642ADDE3C@gmail.com> (raw)

Folks,

It seems that the global state in the Parsing module is confined to

let env =
   { s_stack = Array.create 100 0;
     v_stack = Array.create 100 (Obj.repr ());
     symb_start_stack = Array.create 100 dummy_pos;
     symb_end_stack = Array.create 100 dummy_pos;
     stacksize = 100;
     stackbase = 0;
     curr_char = 0;
     lval = Obj.repr ();
     symb_start = dummy_pos;
     symb_end = dummy_pos;
     asp = 0;
     rule_len = 0;
     rule_number = 0;
     sp = 0;
     state = 0;
     errflag = 0 }

To make a parser generated by ocamlyacc re-entrant one would need to  
pass env as argument to any function that uses it (a handful) as well  
as make ocamlyacc include it in the parser entry function together  
with yytables, etc.

let program (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) =
    (Parsing.yyparse yytables 1 lexfun lexbuf : Easy.program)

Am I missing something crucial here or is this an easy hack?

	Thanks, Joel

--
http://wagerlabs.com/




                 reply	other threads:[~2007-03-30 13:30 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=7F1226C5-BB02-443B-8854-785642ADDE3C@gmail.com \
    --to=joelr1@gmail.com \
    --cc=caml-list@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;
as well as URLs for NNTP newsgroup(s).