[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Yieldable LPEG Parser
- From: Miles Bader <miles@...>
- Date: Thu, 02 Feb 2012 10:50:54 +0900
William Ahern <william@25thandClement.com> writes:
> I've considered the ability to discard early, but that was when I wanted to
> write a PEG engine from scratch. I wrote the above patch yesterday
> afternoon, and I haven't investigated how easy it would be to do something
> like that. The most obvious problem is captures. The capture code would need
> to be substantially refactored, because currently it requires the origin
> address. The patch basically converts all the (const char *) members to a
> size_t offset; but the offset is still relative to the origin. getsidx() and
> getsptr() both take the current origin address to derive an index and an
> address, respectively.
Hmm, maybe captures could instead point into a vector of "capture text"
objects, sorted by position in the text, which would start out as a
pointer/length into global source text, but as the beginning of global
source text gets discarded, any captures that would be affected would be
replaced by an equivalent Lua string.... That way maybe you wouldn't
pay too much price for captures that weren't used in the end.
-miles
--
"Nah, there's no bigger atheist than me. Well, I take that back.
I'm a cancer screening away from going agnostic and a biopsy away
from full-fledged Christian." [Adam Carolla]