Boost logo

Proto :

Subject: Re: [proto] So I heard proto make AST ...
From: Eric Niebler (eric_at_[hidden])
Date: 2010-08-11 12:51:41


On 8/11/2010 12:00 PM, joel falcou wrote:
> On 11/08/10 17:52, Eric Niebler wrote:
>> I don't exactly recall the details of Joel's technique. My experiments
>> to separate transforms from grammars were largely unsuccessful because
>> control flow often need pattern matching. I'd like to see alternate
>> designs.
>
> Mine was just a post-order traversal by a visitor that could be
> specialized on node's tag

This is kind of like Proto's evaluation contexts, IIUC. I'm not wild for
them because often just the tag isn't enough information to find the
right handler. But maybe it covers enough use cases and can be made
easier to use. Right now, proto has an "eval" function that takes an
expression and an evaluation context, but the user is responsible for
the flow control. Maybe there should be a pre_order_eval and
post_order_eval that takes on the control flow responsibilities.

>> Ah, but the control flow of this transform depends on pattern matching
>> (i.e., the grammar) to dispatch to the correct handler. I'm interested
>> to see what this arity calculation would look like with a tree traversal.
>
> Last time I tried, i ended up needing a meta-function that gave you the
> arity of any tag.

Tags don't have arities. E.g. nothing prevents someone from creating an
expression with tag::plus and 5 children.

> Then you did a fold of max over the tree traversal.

I don't understand that.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

Proto list run by eric at boostpro.com