Boost logo

Boost Users :

Subject: [Boost-users] qi::locals
From: Xavier Pegenaute (xpegenaute_at_[hidden])
Date: 2010-05-27 10:51:45


Hi,

I would like to do some complex semantic operation, but I am not sure if
it is possible to do with Spirit. At the moment it does'nt compile :-)

I want a rule like this inside a template class with Iterator, and
ActionHandler as template names:

1: qi::rule<
2: Iterator,
3: qi::locals<
4: std::vector<typename ActionHandler::AClass *>,
5: typename ActionHandler::BClass> *
6: >,
7: skipper
8: > rule1;

later in the grammar I would like something like this:

9: rule1.name("rule1");
10: rule1 =
11: (
12: qi::lit("AClass") >
13: +(qi::int_ > qi::int_ > qi::char_)[
14: qi::_a.push_back(phoenix::construct<
15: typename ActionHandler::AClass>(qi::_1, qi::_2, qi::_3)
16: ] >
17: -(
18: qi::lit("BClass") >
19: +(qi::int_ > qi::char_)[qi::_b.addPair(qi::_1, qi::_2)]
20: )[phoenix::for_each(qi::_a.begin(), qi::_a.end(),
21: xxx::a_element.setBClass(qi::_b))]
22: )[phoenix::bind(&ActionHandler::addAClassVector,
23: phoenix::ref(handler), qi::_a)]
24: ;

I guess I have some problem with:
- The rule definition, here seems is expecting the rule's attribute type
- Line 14:
  - qi::_a is an actor, does'nt have push_back method
  - construct returns a AClass pointer?
- Line 19, same as befor, qi::_b is an actor without addPair method
- Line 20:
  - is it possible to use for_each?, I guess phoenix can.
  - begin/end qi::_a is an actors not a vector

Some idea to face it?, or may be is too complex and better do it in some
other easier way?

Thanks & Regards.
Xavi.


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