[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: adding match state to Lpeg
- From: mascarenhas@...
- Date: Thu, 24 Jan 2008 15:16:31 -0500
This is great, any thought on how this will look on the re syntax?
On 1/24/08, Roberto Ierusalimschy <email@example.com> wrote:
> > I also have a suggestion for Lpeg, an optional parameter to match, a Lua
> > object that gets passed as the first argument in any function captures, if
> > present:
> > lpeg.match(expression, subject, idx, state)
> > If state is nil the function captures receive only the captures, as usual.
> > This lets you write Lpeg parsers that have match-local state, instead of
> > having to fake this with closures. It is specially useful with re-based
> > parsers.
> The next version of Lpeg has a somewhat similar mechanism: the so-called
> argument capture. lpeg.Carg(i) captures the value of the i-th extra
> argument passed to lpeg.match. This captured value can be used like any
> other captured value (in particular, as an argument to an enclosing
> function capture).
> -- Roberto