[DGD] Question about parse_string
Felix A. Croes
felix at dworkin.nl
Sun Apr 26 23:07:56 CEST 1998
Jason Cone <jcone at cs.tamu.edu> wrote:
> Is there a way to force the parse_string() function to fail from within a
> LPC function that's called from a production rule? It's my understanding
> that you can return a 0 and it'll just replace that segment of the parse
> tree with 0. As a general description of what I'm doing, I'm finally
> getting around to implementing a verb parser and need a mechanism to check
> for objects and replace the string reference (be it by name or filename)
> with an object reference. This works perfectly if the object exists. If it
> doesn't exist, however, I'd like to force the parse_string() to fail rather
> than continue parsing the input. Just seems like wasted computation to me.
> Suggestions or instruction (if any) on how to achieve this?
If you want to replace a sub-parse tree with 0, the LPC function should
return ({ 0 }), not 0. Returning 0 will cause parse_string() to fail
for the current alternative parse tree, so returning 0 will do what you
want to accomplish.
Regards,
Dworkin
More information about the DGD
mailing list