In spirit X3 I can build a parser like this:
const auto p = ("Number:" >> x3::_int)
| ("String:" >> +x3::alpha);
If I know after the string Number
comes a int and after String
a string all the time I can use the >
to say after Number
only comes a number and so on.
const auto p = ("Number:" > x3::_int)
| ("String:" > +x3::alpha);
For me the difference is if the parser fails to parse the input an exception is throw.
Now my question is, should I use the >
operater over the >>
operater whenever possible? Is the parser which will be generated using >
faster then the one only using the >>
operator?
You should always just profile things.
Regardless:
Will I get a faster parser using spirit X3 when I use the expect operator
Only to the extent that it prevents backtracking alternatives, but if you needed that it's not doing the same anyways.