Re: [SimpleParse] Graceful failure ?
Brought to you by:
mcfletch
|
From: Mike C. F. <mcf...@ro...> - 2004-03-21 20:58:28
|
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.
>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).
HTH,
Mike
_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/
|