[DGD] Working with parse_string()

bart at wotf.org bart at wotf.org
Tue Jul 21 17:27:57 CEST 2009


On Tue, 21 Jul 2009 14:09:27 +0200, Felix A. Croes wrote

> 
> The problem of parsing a string longer than whatever you've set your
> maximum string length to is very similar to parsing a string of
> unknown length; for example, a string received piece by piece on
> an internet connection.  What you do is parse as much of it as
> you can, and leave the remainder to be re-parsed in a followup call.
> 
> Rather than:
> 
>     word = /[a-zA-Z]+/
>     Array: '{' OptionalWords '}'
>     OptionalWords:
>     OptionalWords: Words
>     Words: Words ',' word
>     Words: word
> 
> you use:
> 
>     word: /[a-zA-Z]+/
>     PartialArray: '{' OptionalWords '}'
>     PartialArray: '{' OptionalWords ReparseThis
>     PartialArray: OptionalWords ReparseThis
>     PartialArray: OptionalWords '}'
>     OptionalWords:
>     OptionalWords: word ',' OptionalWords
>     ReparseThis:
>     ReparseThis: word
>     ReparseThis: word '}'
> 
> and the tokens collected by ReparseThis are concatenated and added
> as a prefix to the next chunk to parse.

That seems a useful approach, I'll go experiment with that, thanks.

Bart.
--
Created with Open WebMail at http://www.bartsplace.net/
Read my weblog at http://soapbox.bartsplace.net/




More information about the DGD mailing list