Boost logo

Boost Users :

From: Stuart Dootson (stuart.dootson_at_[hidden])
Date: 2006-07-13 11:26:21


On 7/12/06, Stuart Dootson <stuart.dootson_at_[hidden]> wrote:
> On 7/12/06, Eric Hill <eric_at_[hidden]> wrote:

<snip>

> > But how do I match "just enough" instead of "whole word" without doing it
> > manually?
> >
> > TIA,
> > Eric
> >
>
> There's nothing built in to do that (AFAIK). However, it is relatively
> trivial to implement using a functor parser. I've done it myself -
> however, the code's at work, and I'm not :-) I'll post some code
> tomorrow after work (haven't got access to this e-mail account
> there!).
>
> Stuart Dootson

As promised...

disambiguate.h is the parser implementation, dis.cpp is a sample
parser using it.

There are two main sections in disambiguate.h. The first contains the
implementation of the Disambiguator class. This determines the minimum
unambiguous prefix for each token you add to it.

The second section contains the min_unambiguous_parser_f class, which
is the parser. This uses an associated Disambiguator together with the
user supplied complete keyword to match any unambiguous prefix of the
keyword. There are several min_unambig_p overloads that you use in a
parser to create a min_unambiguous_parser_f. The one thing I'm not
sure about is the ~epsilon_p I've got that ensures that the character
following the keyword isn't in [a-zA-Z0-9_] - it should probably be
something else? But I'm not sure what.

Anyway - hope that's of use/interest...

Stuart Dootson





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