I'm trying to write a parser using boost::spirit
that will match an alphanumeric sequence that may also contain the _ character, but will exclude the literals 'in' and 'out' (rule0
).
For example, it should match "abc3x3_" , "_hello", "in_12", "out_in" etc. But should not match "in" or "out".
rule1
below is intended to achieve this.
typedef boost::spirit::qi::rule <const char*, string(), ascii::space_type> myRule;
myRule rule0 = qi::lit("in") | "out";
myRule rule1 = ((qi::alpha | '_') >> *(qi::alnum | '_')) - rule0;
The problem is that it doesn't match strings that contain the literals from rule0
as substrings:
For example, it doesn't match "_in", "in_12", "out1" etc.
Where am I wrong?