[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Token filter
- From: Thomas Lauer <thomas.lauer@...>
- Date: Thu, 31 May 2007 20:15:39 +0100
I have further investigated this and found out the following. The
original token filter file looks like that:
My problem comes from the fact that the filter function replaces itself.
Or, in other words, that one function does two things.
Whenever a new file is loaded, luaX_setinput() (the proxy.c version)
installs a filter like that:
void luaX_setinput(lua_State *L, LexState *ls, ZIO *z, TString *source)
if (lua_isnil(L,-1)) lua_pop(L,1);
printf(">> %s %i\n",getstr(source),source->tsv.len);
However, this means that once a filter function is installed, it expects
to be called only as a filter and *not* to set a filter for another
The following version of the token filter file is completely off the top
of my head (and it's getting late anyway...), so it will certainly need
much more polishing. But it seems to work and it shows the basic idea:
if get==nil then -- we are being called as a filter
_get=get -- we are being called to set a new filter function
As I am relatively new to this token filter business, others (especially
lhf, I would think) will certainly find a much more elegant solution.
web : http://thomaslauer.com/start