lua-users home
lua-l archive

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


On Thu, Jun 17, 2010 at 2:08 PM, Wesley Smith <wesley.hoke@gmail.com> wrote:
> I'm trying to figure out why a listlpeg pattern I've written is
> generating so many captures.  Below is a vastly simplified script that
> generates a stack of 15 captures when only 1 is returned by the
> pattern.  When the subject of the match is larger, I easily get in
> excess of 9000 captures.  It seems that the pattern is capturing every
> singly sub-table and I have absolutely no idea why.  Is there
> something about recursive grammar rules that implicitly generates
> captures?  Is it possibly a bug where the stack isn't being properly
> cleared after going down a level in the tree of tables?
>
> There's no way to see what's going on from within Lua itself unless
> you hit the stack overflow limit, so to test, put a printf in the
> pushcapture function and watch.
>
>
> static int pushcapture (CapState *cs) {
>        printf("push_capture top %d\n", lua_gettop(cs->L));


Are you talking about the Lua stack or the capture stack? When I run
your script pushcapture is called only once, and prints "15", but this
15 is how many values are in the Lua stack, not the capture stack. Is
this value >9000 in your other test?

--
Fabio Mascarenhas