On 7/12/06, Eric Hill
I'm past the initial learning curve with Spirit, but would like to see how the pros handle this problem.
I have the following simple command structure:
show queues show users show processes start process foo queue user bar to process foo ...etc
I would like to parse these commands with Spirit. Easy enough. Since this is being entered from a keyboard, it would be nice to short-circuit the parser so you only have to enter enough of the command for the parser to reliably figure out what you want.
e.g. "sh qu" would parse as "show queues", and "st pr foo" would parse as "start process foo".
I can easily model the whole "show queues" command word with:
str_p("show") >> str_p("queues")
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!). Anyway, the strategy I followed was to initialise the functor parser with a set of tokens and it would generate the set of unambiguous prefixes. Then the functor parser would match tokens that matched the required words to sufficient length. Stuart Dootson Stuart Dootson