Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Francois Pottier <Francois.Pottier@inria.fr>
To: skaller <skaller@users.sourceforge.net>
Cc: Caml List <caml-list@inria.fr>, menhir-list@yquem.inria.fr
Subject: Re: [Caml-list] Re: [Menhir-list] There's an elephant in the room: Solution to sharing a symbol table
Date: Wed, 2 May 2007 20:30:20 +0200	[thread overview]
Message-ID: <20070502183020.GA17473@yquem.inria.fr> (raw)
In-Reply-To: <1178122046.6486.31.camel@rosella.wigram>


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/


  reply	other threads:[~2007-05-02 18:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-01 21:39 Joel Reymont
2007-05-02  5:44 ` [Menhir-list] " Francois Pottier
2007-05-02  5:58   ` Joel Reymont
     [not found]     ` <20070502070345.GA5242@yquem.inria.fr>
2007-05-02  7:35       ` Joel Reymont
2007-05-02  9:04     ` [Caml-list] " skaller
2007-05-02 11:56       ` Francois Pottier
2007-05-02 16:07         ` skaller
2007-05-02 18:30           ` Francois Pottier [this message]
2007-05-03  1:17             ` skaller
2007-05-03  8:48               ` Joel Reymont

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=20070502183020.GA17473@yquem.inria.fr \
    --to=francois.pottier@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=menhir-list@yquem.inria.fr \
    --cc=skaller@users.sourceforge.net \
    /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