caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Passing arguments to a parser generated by ocamlyacc
@ 2007-03-28 10:25 Joel Reymont
  2007-03-28 10:42 ` [Caml-list] " Jeremy Yallop
  0 siblings, 1 reply; 2+ messages in thread
From: Joel Reymont @ 2007-03-28 10:25 UTC (permalink / raw)
  To: Caml List

Folks,

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?

My parser is supposed to be used as a C library. I have a hunch that  
when there are several calls to the parser the single mutable symbol  
table I'm using now will be overwritten, thus the need to pass one in.

	Thanks, Joel

--
http://wagerlabs.com/




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Passing arguments to a parser generated by ocamlyacc
  2007-03-28 10:25 Passing arguments to a parser generated by ocamlyacc Joel Reymont
@ 2007-03-28 10:42 ` Jeremy Yallop
  0 siblings, 0 replies; 2+ messages in thread
From: Jeremy Yallop @ 2007-03-28 10:42 UTC (permalink / raw)
  To: Caml List

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-28 10:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-28 10:25 Passing arguments to a parser generated by ocamlyacc Joel Reymont
2007-03-28 10:42 ` [Caml-list] " Jeremy Yallop

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).