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)

 

 

Grammar:

 

template <typename Iterator>

struct FortranLineGrammar : grammar<Iterator, space_type>

{

 

    FortranLineGrammar() :

        FortranLineGrammar::base_type(start)

    {

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

        BOOST_SPIRIT_DEBUG_NODE(lvalue);

 

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

        BOOST_SPIRIT_DEBUG_NODE(assignment);

 

                ...

    }

    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...

 

PRINT *, 'AHHHH! '

<start>

<lvalue>

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

    <dim>

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

      <fail/>

    </dim>

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

  <attributes>[[P]]</attributes>

</lvalue>

 

 

So what gives?