Version française
Home     About     Download     Resources     Contact us    
Browse thread
There's an elephant in the room: Solution to sharing a symbol table
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Francois Pottier <Francois.Pottier@i...>
Subject: Re: [Caml-list] Re: [Menhir-list] There's an elephant in the room: Solution to sharing a symbol table

Hi,

On Thu, May 03, 2007 at 02:07:26AM +1000, skaller wrote:
> State must be maintained in function arguments.

This is a trivial example, but:

  let x = ref 0
  let f () : bool = incr x; x / 2 = 0

Here, f exploits an internal state, even though it is not explicitly
parameterized over a piece of state. Similarly, a parser can have internal
state, even if the parsing functions are not explicitly parameterized over a
piece of state. It is sufficient for the entire parser either to refer to a
global variable or to abstracted over a piece of state (which functors allow).

> When the parser sees the include statement it parses the
> file 'filename'. The parse of the included file, in Felix,
> is independent of the surrounding code. The parser is
> called recursively and the resulting AST is returned
> from the user action.
> 
> There is no way to do this without passing a state variable
> on the stack.

I don't see why this is so. In fact, nothing in your example seems to require
any kind of state -- you only need the parser to be able to recursively invoke
itself. Or am I missing something?

-- 
François Pottier
Francois.Pottier@inria.fr
http://cristal.inria.fr/~fpottier/