Can Boost's Spirit Lex have multiple semantic actions for a token definition?
Consider this Lexer construction:
namespace bp = boost::phoenix;
this->self = lex::token_def<>("[ \v\f\t\r]+")
| lex::token_def<>("\n")[++bp::ref(line_no)]
| lex::token_def<>("\\/\\/")[set_lexer_state("single_line_comment")]
| lex::token_def<>(".")
;
this->self("single_line_comment")
= lex::token_def<>("\n")
[++bp::ref(line_no), set_lexer_state("INITIAL")]
| lex::token_def<>(".")
;
However only the state switch goes through, but the line ending in state single_line_comment does not get counted.
If I switch the order, e.g.:
[set_lexer_state("INITIAL"), ++bp::ref(line_no)]
The line ending gets counted and the state switch doesn't go through. Is it possible to have multiple semantic actions there separated by commas or do I have to write a single functor to do state switching and any other action I want?