lua-users home
lua-l archive

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


Hi guys,

Given:
--one.lua
print 'one'

--two.lua
print 'two'

The debug filter example works as expected:
>lua -lfdebug one.lua
FILTER  @one.lua
FILTER  1       <name>  print
FILTER  1       <string>        one
FILTER  2       <eof>   nil
one

But we're not loading two.lua properly in this case!
>lua -lfdebug -lone two.lua
FILTER  @.\one.lua
FILTER  1       <name>  print
FILTER  1       <string>        one
FILTER  2       <eof>   nil
one
FILTER  0       <eof>   nil
FILTER  0       <eof>   nil

Loading several libraries like this is essential for something like a
macro library, which I'm currently working on. Any macro definitions
must be executed _before_ the code is compiled.
>lua -lmacro -lmacro-defs test.lua

There is a slightly ugly workaround - put a "require(MDEFS)" in macro.lua and:
>lua -e"MDEFS='macro-defs'" -lmacro test.lua

Of course, then macro-defs.lua cannot itself be preprocessed. I wanted
to filter the macro definitions because then I can use _token
literals_ (e.g. macro('def',@local function@)) which evaluate as a
list of tokens ready to be substituted. Otherwise one would have to
tokenize the string with Lua code, which would be tedious.

steve d.