Re: Parsing a set number of repetitions

Sebastian Gsänger <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
Hi,

seems i misunderstood the lazyness in phoenix :)
boost::phoenix::stl::size seems to expect real containers that are 
evaluated lazyly,
while my aim was to evaluate lazy containers in an unlazy-fashion (e.g. 
via phx::bind).
Or something like that...
Should anyone be interested in my solution (focus on the atoms rule):

template<typename Iterator>
struct xyz_parse_grammar: qi::grammar<Iterator, Vipster::Molecule(), 
qi::blank_type>
{
     xyz_parse_grammar(): xyz_parse_grammar::base_type(mol, "XYZ")
     {
         name = +qi::alnum;
         atom = name
                   >> qi::double_
                   >> qi::double_
                   >> qi::double_;
         atoms = (atom % qi::eol)
                     > qi::eps(qi::_r1 == 
phx::bind(&std::vector<Vipster::Atom>::size, qi::_val));
         comment = *(qi::char_ - qi::eol) > qi::eol;
         step %= qi::omit[qi::int_[qi::_a = qi::_1] > qi::eol]
                     > comment
                     > atoms(qi::_a);
         steps = step% +qi::eol;
         mol = steps;
     }
     qi::rule<Iterator, Vipster::Molecule(), qi::blank_type> mol;
     qi::rule<Iterator, std::vector<Vipster::Step>(), qi::blank_type> steps;
     qi::rule<Iterator, Vipster::Step(), qi::locals<int>, 
qi::blank_type> step;
     qi::rule<Iterator, std::string(), qi::blank_type> comment;
     qi::rule<Iterator, std::vector<Vipster::Atom>(int), qi::blank_type> 
atoms;
     qi::rule<Iterator, Vipster::Atom(), qi::blank_type> atom;
     qi::rule<Iterator, std::string(), qi::blank_type> name;
}

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.