Boost logo

Boost Users :

Subject: [Boost-users] Quick (hopefully simple) Spirit::Qi question
From: david.weber_at_[hidden]
Date: 2012-02-20 19:37:12

I have a grammar that fully works. I'm in the process of now adding
semantic actions to actually *do* something, and I'm hitting a snag.
(BTW, I've used Boost::Spirit::Classic, but this is my first time w/ Qi)





template <typename Iterator>

struct FortranLineGrammar : grammar<Iterator, space_type>



    FortranLineGrammar() :



        lvalue %= !hex_int >> lexeme[alpha >> *(alnum | '_')] >> *dim;



        assignment = lvalue[ppp_print] >> "=" >> command;





    typedef rule<Iterator, std::string(), space_type> string_rule_t;

    string_rule_t lvalue;






Semantic action:



extern void ppp_print(std::string& b);


and later


void ppp_print(std::string& b)


    std::cout << b << std::endl;




So, what I'm going for, is when an lvalue is encountered, to call
ppp_print with whatever matched that value.


Unfortunately, I'm only getting the first character?!?


Here is the debug output, not the right match, but I'm still tweaking
the grammar. Looking at the actions only...





  <try>PRINT *, 'AHHHH! '</try>


      <try> *, 'AHHHH! '</try>



  <success> *, 'AHHHH! '</success>





So what gives?


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at