On 7/12/06, Stuart Dootson
On 7/12/06, Eric Hill
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