Re: [SimpleParse] Graceful failure ?
Brought to you by:
mcfletch
|
From: H. T. H. <hi...@co...> - 2004-03-26 07:16:36
|
On Sun, Mar 21, 2004 at 03:58:16PM -0500, Mike C. Fletcher wrote:
> H. T. Hind wrote:
> ...
>
> >>>>column_specs := '<s>',ws,('<c>'?,ws)+,'\n'
> >>>>
> ...
>
> >The data had '<S>' , i.e a capital S instead of a lower case s
> >and that resulted in the app going into a loop.
> >
> >
> But not from the section described if spelled like this:
>
> column_specs := '<s>',ws,('<c>',ws)*,'\n'
>
> that is, you can't get a loop *from this part of the grammar* because
> there's no null-matching construct. When writing a grammar, you write
> the grammar to include everything which is valid and reject that which
> is not valid. An '<S>' presented anywhere to the above production will
> simply cause a fail, not a loop.
Thank you for the pointer. I looked at the grammar and indeed
there was a null-matching construct.
> >My issue is , that it may not be possible to define all the valid
> >input that we'll get. In the case where the input is invalid, I'd
> >want the application to fail instead of going into an infinite
> >loop.
> >
> >
> Understood, what I'm saying is, you don't need to define all possible
> inputs, you just need to avoid defining constructs that can successfully
> match a NULL string. You might also want to look at the "cut" or
> "errorOnFail" directive, which can raise SyntaxErrors if part of a
> construct fails (doesn't help with null-matching constructs, however).
Avoiding the NULL string was it. Now it correctly fails .
Thanks,
HTH
|