Opened 13 years ago

Closed 13 years ago

#3275 closed Bugs (invalid)

Spirit does not skip whitespace between str_p and ch_p

Reported by: misterkraus@… Owned by: Joel de Guzman
Milestone: Boost 1.40.0 Component: spirit
Version: Boost 1.38.0 Severity: Problem
Keywords: spirit whitespace skip Cc:

Description

After matching a str_p or ch_p trailing whitespace till the next token is not skipped. Tested under VC2008 and macosx gcc 4.0. Either this is a major bug or i am missing something fundamental. Example:

#include <boost/spirit/include/classic_core.hpp>
#include <boost/spirit/include/classic_push_back_actor.hpp>
#include <boost/spirit/include/classic_exceptions.hpp>
#include <boost/spirit/include/classic_confix.hpp>
#include <iostream>

using namespace BOOST_SPIRIT_CLASSIC_NS;

int main(int argc, char* argv[])
{
	rule<> fileRule =  ch_p('{') >> real_p;

	parse_info<> info= parse("    {  3.0",
		fileRule,space_p);

	if (!info.hit)
	{
		std::cout<<"ERROR:"<<info.stop<<std::endl;
	}
	return 0;
}


Change History (3)

comment:2 by anonymous, 13 years ago

Severity: ShowstopperProblem

Thanks for the tip. If i pass the rule as a temporary argument to the parse function the example works. Please note though that the FAQ mentiones a compile problem, but while the mentioned code compiles without warning it does not work. Therefore a clarification of the FAQ section might be in order.

comment:3 by anonymous, 13 years ago

Resolution: invalid
Status: newclosed

The problem is a scanner mismatch indeed. But in this case you're using a rule without any skipper while parsing with one. This rule acts as an implicit lexeme[] (see the docs for more information). So this is desired bahavior.

Regards Hartmut

Note: See TracTickets for help on using tickets.