[DGD] Question about parse_string
Felix A. Croes
felix at dworkin.nl
Mon Jul 1 22:48:52 CEST 2002
Jay Shaffstall <jshaffst at netwalk.com> wrote:
>[...]
> >The thing to do is to add a "garbage" token rule to the grammar that
> >catches anything...
>
> Odd...that was one of the things I tried before mailing the list. Here's
> my test code with that bit added:
>
> if (parse_string ("whitespace = /[\b\n\r\t ]+/ garbage = /.+/
> command: 'touch' 'pole' command: 'touch' 'the' 'pole'", "touch pole"))
> this_user ()->message ("Parsed!\n");
> else
> this_user ()->message ("Did not parse.\n");
Oops, my mistake. The extra rule should be:
garbage = /./
Otherwise the longest match for " pole" will be the garbage token, rather
than whitespace followed by "pole".
Regards,
Dworkin
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list