Jump to content

[TEST] Simple Lua Pre-processor (implementation)


rain_gloom

Recommended Posts

I made an implementation of this pre-processor. Currently it just returns the processed file as a string.

Example file:

  
#debug=true 
function power (x,n) 
    #if debug then 
    print(x,n) 
    #end 
    if n==0 return 1 else 
    return x*power(x,n-1) 
end 
powersOfTwo={ 
#for i=0,10 do 
    $(2^i), 
#end 
} 

Becomes:

  
function power(x,n) 
    print(x,n) 
    return x*power(x,n-1) 
end 
powersOfTwo={ 
    1, 
    2, 
    4, 
    8, 
    16, 
    32, 
    64, 
    128, 
    256, 
    1024, 
} 
  

Useful if you want to build more optimized scripts, pre-initialize constants, make debug builds, make debug code easily removable.

If there is demand for it, I'll try to implement the more sophisticated version

I'm planning to use it for a server-side "build" system. It would pre-process the files, then send them to the compiler, save the compiled version as a luac file, then edit the meta.xml accordingly.

Which files are pre-processed and which to compile should be controllable either in the Meta or a separate config file per-resource.

If you have any suggestions, I'd be happy to hear them.

ps.: don't ask for a GNU Make-style thingy, I have something that remotely resembles a life

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...