|
Boost Users : |
Subject: Re: [Boost-users] [proto] Comma Strangeness
From: Manjunath Kudlur (keveman_at_[hidden])
Date: 2010-03-26 21:37:19
> display_expr dumps out an expression without any comma operators.
> It just shows a subscript off "list" with one "index," obj["name3"].attr["b"].
>
> It's the behavior I would expect if the operands of the commas were not
> protoized expressions, but they _should_ be protoized.
>
> The funny thing is, if I write a small testcase just isolating the terminals,
> members, etc. needed to construct the expression, it works as expected.
> But in the context of the (much) larger language, it fails. However, the
> grammar specification shouldn't have any bearing on what display_expr
> dumps out.
>
I have the following toy program :
#include <iostream>
#include <boost/proto/proto.hpp>
using namespace std;
namespace proto=boost::proto;
struct list_ {};
struct attr_ {};
struct obj_ {};
template<class E> struct obj_expr;
struct obj_domain
: proto::domain<proto::pod_generator<obj_expr> >
{};
template <class E>
struct obj_expr {
BOOST_PROTO_BASIC_EXTENDS(E, obj_expr<E>, obj_domain);
BOOST_PROTO_EXTENDS_SUBSCRIPT();
BOOST_PROTO_EXTENDS_MEMBERS(
((attr_, attr))
)
};
proto::terminal<list_>::type list;
obj_expr<proto::terminal<obj_>::type> obj;
int main()
{
proto::display_expr(
list[obj["name1"].attr["a"],
obj["name2"].attr["a"],
obj["name3"].attr["b"]]
);
return 0;
}
and I do see the expression getting printed out correctly as follows.
Do you see something different?
subscript(
terminal(5list_)
, comma(
comma(
subscript(
member(
subscript(
terminal(4obj_)
, terminal(name1)
)
, terminal(5attr_)
)
, terminal(a)
)
, subscript(
member(
subscript(
terminal(4obj_)
, terminal(name2)
)
, terminal(5attr_)
)
, terminal(a)
)
)
, subscript(
member(
subscript(
terminal(4obj_)
, terminal(name3)
)
, terminal(5attr_)
)
, terminal(b)
)
)
)
Manjunath
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net