So I've begun playing with the Boost Spirit library and its absolutely amazing! But along the way i have ran into many errors - many on my behalf for not fully reading the documentation.. But after going through as much as I could find, i am stumped on attributes - strings in regards to skipping.
At the moment I'd like to detect an ASM alike label and print it in a console like so:
Identifier = qi::lexeme[qi::alpha >> (*qi::alnum | qi::lit("_"))]
Label = Identifier >> ":"
Syntax = Label[phx::bind(&Grammar::print, this, qi::_1)];
where phx::bind calls a simple print string function to cout. The rules are defined like so:
qi::rule<Iterator, std::string(), ascii::space_type> Identifier;
qi::rule<Iterator, std::string(), ascii::space_type> Label;
qi::rule<Iterator, ascii::space_type> Syntax;
Which works BUT the problem is, I don't want the skipper to skip between the Identifier and the ":" literal.
I have tried:
Label = qi::lexeme [Identifier >> ":"]
Label = qi::no_skip[.................]
etc
But i receive error messages such as converting to parameter 4 - cannot convert unused_skipper<..> to char_class<..> which makes some sense. I also tried removing the skipper type on the rule definition which didn't work. I then tried mixing it up and making some rules attributes strings whilst others not, - and converting them to strings using as_string - worked, but output was empty. So here I am. stumped.
Is there something I'm not understanding about attribute propagation? Or perhaps something about attributes in general. Maybe even a method to return a string from a non-skipped sequence?
Would someone please be able to enlighten me on my errors? & Any future tips on attributes?
Many Thanks, Adam.