From: Francois Pottier <Francois.Pottier@inria.fr>
To: Joel Reymont <joelr1@gmail.com>
Cc: Caml List <caml-list@inria.fr>,
skaller <skaller@users.sourceforge.net>,
menhir-list@yquem.inria.fr
Subject: Re: [Menhir-list] There's an elephant in the room: Solution to sharing a symbol table
Date: Wed, 2 May 2007 07:44:11 +0200 [thread overview]
Message-ID: <20070502054411.GB726@yquem.inria.fr> (raw)
In-Reply-To: <1EE80473-541D-478D-97F8-06A1B5F65F79@gmail.com>
Hello,
On Tue, May 01, 2007 at 10:39:19PM +0100, Joel Reymont wrote:
>
> %type <Symtab.t -> Easy.program>
>
> program: statement EOF { fun t -> List.rev ($1 t) }
>
> Would this work with Menhir and would it be detrimental to performance?
Yes, it would work (with ocamlyacc or Menhir). It is in fact a classic idiom.
However, you must be aware that having your semantic actions build closures
means that all of the actual work (e.g., the invocation of List.rev above)
is delayed until *after* the entire parsing process is over. In other words,
performance-wise, your code is equivalent to building an abstract syntax
tree, without using your symbol table, and then transforming that tree.
> I think there's an elephant in the room. Functorization of a Menhir-
> generated parser doesn't solve this issue since the specialization
> happens at compile time whereas a new symbol table is a run-time value.
Functors can be applied at run-time (via "let module"), so a functor parameter
*can* provide a parser with runtime information. I would still recommend the
%parameter approach, since it is syntactically lighter and more efficient (the
semantic actions won't be delayed).
--
François Pottier
Francois.Pottier@inria.fr
http://cristal.inria.fr/~fpottier/
next prev parent reply other threads:[~2007-05-02 5:44 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 ` Francois Pottier [this message]
2007-05-02 5:58 ` [Menhir-list] " 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
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=20070502054411.GB726@yquem.inria.fr \
--to=francois.pottier@inria.fr \
--cc=caml-list@inria.fr \
--cc=joelr1@gmail.com \
--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