|
Boost : |
From: Eric Niebler (eric_at_[hidden])
Date: 2007-04-06 16:16:45
Larry Evans wrote:
> On 04/04/2007 02:18 AM, Eric Niebler wrote:
>> As discussed here recently, Boost.Proto is an expression template (ET)
>> framework for building domain-specific embedded languages (DSEL). The
>>
> [snip]
>> Feedback is most welcome.
>>
>
> proto/libs/xpressive/proto/doc/html/boost_proto/user_s_guide/calculator.html
>
> contains:
>
> The expr<> template makes up the nodes in expression trees. The
> first template parameter is the node type; in this case,
> proto::tag::terminal. That means that _1 is a leaf-node in the
> expression tree. The second template parameter is a list of children
> types. Terminals will always have only one type in the type
> list. The last parameter is the number of types in the list. It is
> deduced from the type list, so you won't need to worry about it.
>
> which suggests a leaf-node can have children. I thought leaf-nodes had
> no children. What am I missing? OOPS. Maybe a leaf-node, as you're
> defining it can have no other proto-expressions as children but it can
> have other types of children. Is that right?
That's right, expr<tag::terminal, ...> is special in that it is the only
node type that is allowed to have a non-expr<> as a child. Even though
leaf nodes in a tree are special, it simplifies much code to reuse the
expr<> type this way, rather than to define a separate terminal<> template.
-- Eric Niebler Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk