[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LPegK, Yieldable LPeg
- From: William Ahern <william@...>
- Date: Thu, 2 Feb 2012 21:27:13 -0800
On Fri, Feb 03, 2012 at 02:02:44PM +0900, Miles Bader wrote:
> William Ahern <william@25thandClement.com> writes:
> > http://25thandClement.com/~william/projects/lpegk.git
> >
> > Stuff like discarding subject prefixes and progressive capture
> > internalization will just have to wait. I'd rather use it for my immediate
> > intentions--online sockets parsing--so I can get a feel for real-world
> > needs.
>
> Hmm, are you _eventually_ going to have to start discarding something if
> you're parsing a continual stream...? :]
Just loop over lpeg.match and use lpeg.Cp at the end of the pattern to
capture the stream position. Continous protocol streams will have boundaries
somewhere. It's not ideal for parsing a finite (but unknown length) object,
like a full XML document. But it wouldn't be any worse than the existing
capability of LPeg; perhaps easier, since you don't have to build a gigantic
string.