Re: [SimpleParse] Graceful failure ?
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ro...> - 2004-03-20 11:01:58
|
H. T. Hind wrote: ... >>column_specs := '<s>',ws,('<c>'?,ws)+,'\n' >> >> ... >Is there another way to define the above that avoids the loop ? >We might not be able to anticipate all the data that we might >encounter, hence it is essential to have the ability to fail with >an error such that a human can intervene and fix the data. > > This doesn't have anything to do with the data, the grammar itself is saying "if you match nothing here, go ahead and try to match it again". That is; to say the *exact* same thing with an engine such as mxTextTools, you can't spell it without defining a recursion, however, you probably don't want to anyway: column_specs := '<s>',ws,('<c>',ws)*,'\n' is probably what you are looking for. That is, to match the group within the brackets, you *must* find at least one '<c>', and optionally some whitespace, but if you don't find that, ignore the whole group, while allowing for repetition of the group. >>It's possible to catch it, yes, but it would require some considerable >>work to modify the engine to be able to support the feature. >> >> >> > >Would you recommend then something like PLY ? > > If you feel like it would meet your needs. You haven't yet outlined what you're actually trying to parse that would be a problem for SimpleParse (given a proper grammar). Other parser-generators may use Earley or similar parsing mechanisms, which are more general than SimpleParse, but your parsing task here doesn't seem particularly to require such generality. Anyway, good luck, Mike _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ |