lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

2008/12/1 Roberto Ierusalimschy <>:
> This particular form of non-pure construct is quite generic. I would
> say that it is the "most generic", as by calling a function the function
> can do whatever it wants. So it is more useful in the sense that all
> others (or most others, probably) can be written on top of it.

That makes sense. We have Cmt, a runtime equivalent of patt / func,
but no runtime equivalent of the various other captures, because they
can all be replaced by patt / func for an appropriate func (although,
of course, you need some basic captures to start the process!

> It is a compromisse, but not of the sort that happened with regular
> expressions. Match-time captures is fairly generic, but it does
> not change the basic interface between patterns (ordered choice +
> restricted backtracking). For other patterns around it, it behaves
> like any other pattern.

Hmm, I think I see. I'll have to think more about that.

>> Can anyone help me with a really strong motivating example of why Cmt
>> is important enough to have earned its place as the one exceptional
>> case in lpeg?
> The motivation for match-time captures is "the extension to avoid
> all other extensions". (For instance, it emcompasses back-references,
> a common feature in pattern-matching tools.)

:-) I'd still be interested in more practical uses where Cmt is
needed, though. It's surprisingly hard to find any around (assuming
that "lpeg Cmt" makes a good Google search, which I'd think it would
:-)) My feeling is that it's very rarely needed (although it may
simplify some cases where it's not technically necessary).

>> (On a related note, are there any papers available on the theory of
>> captures in PEGs? I found Roberto's papers on the implementation of
>> lpeg fascinating to read, but they omit any serious discussion of
>> captures. I'd love to have a similar reference which addressed the
>> area of captures, from both a theoretical and an implementation point
>> of view).
> Not yet. I plan to write something...

I await the result with anticipation!

Thanks for the explanation,