Boost logo

Boost Users :

From: james.jones_at_[hidden]
Date: 2006-07-07 08:59:53


From: Neil Hunt <boost_at_[hidden]>
> Hello all,
>
> Given a simple spirit grammar (simplified from my real grammer and
> untested) such as:
>
> file = *line;
> line = sensible_line >> ending >> *comment;
> sensible_line = confix_p( '\"', *c_escape_ch_p, '\"' );
> comment = !( ch_p(';') >> ( anychar_p - eol_p ) ) >> ending;
> ending = *blank_p >> ( eol_p | end_p );
>
>
> Note: any given line can be legitimately terminated by the end of the
> file or end of line
>
> And there can be arbitrary numbers of comment lines between sensible lines.
>
> However since 'comment' is terminated with 'ending', the parser ends up
> in an infinite loop matching the kleene star on end_p because it returns
> zero length (doesn't advance the scanner). At least I think this is the
> problem.

Indeed. You can fix it by adjusting your grammar thus:

line = sensible_line >> (ending >> comment)* >> ending;
sensible_line ... as before
comment = !( ch_p(';') >> ( anychar_p - eol_p ) );
ending ... as before

-
James Jones Administrative Data Mgmt.
Webmaster 375 Raritan Center Pkwy, Suite A
Data Architect Edison, NJ 08837


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net