caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Hacking Parsing to be re-entrant
@ 2007-03-30 13:30 Joel Reymont
  0 siblings, 0 replies; only message in thread
From: Joel Reymont @ 2007-03-30 13:30 UTC (permalink / raw)
  To: Caml List

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/




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

only message in thread, other threads:[~2007-03-30 13:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-30 13:30 Hacking Parsing to be re-entrant 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).