I need to parse an expression and I'm using boost :: spirit, the expression must have the form (@anything but @ followed of the string .PV@), and I am using the following grammar
P = S >> "." >> V;
S = ch_p('@') >> +~ch_p('@');
V = str_p(".PV@");
but does not work me, could you tell me where is the error. I need do it with a grammar and I am using namespace boost::spirit
Update For completeness adding the regex approach (see at the bottom)
In spirit V2 I'd suggest the simpler
Assuming that you didn't mean a double
.
to be required. See a test program Live On Coliru.Also, note the
confix
parser in the spirit repository, which could do this slightly more succinctly:See that Live On Coliru as well.
Output:
Regex Approach
Depending on your use case, you could use a regular expression as has been pointed out in comments. See a simple demo Live On Coliru
Bear in mind,
std::regex
is not ready on any compiler/platform I know of