Boost logo

Boost Users :

From: Neil Hunt (boost_at_[hidden])
Date: 2006-07-04 12:23:11


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.

By using:
ending = *blank_p >> eol_p ;

the parser runs to completion, but any given line must be terminated by
an end of line sequence.

Any suggestions on how to fix this problem?

Thanks for any help offered,
Neil Hunt


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