mirror of
https://github.com/Adorable-Catgirl/LuaComp.git
synced 2024-12-23 08:48:05 +11:00
Now only includes argparse if you compile src/staticinit.lua
This commit is contained in:
parent
cb396d6d3f
commit
0272d053f0
2
examples/bad_include.lua
Normal file
2
examples/bad_include.lua
Normal file
@ -0,0 +1,2 @@
|
||||
--#include "world.lua
|
||||
print("hello"..get_world())
|
8
examples/macro2.lua
Normal file
8
examples/macro2.lua
Normal file
@ -0,0 +1,8 @@
|
||||
@[[function my_macro(a, b)]]
|
||||
print("Hello, @[{a}]. Your lucky number is @[{b}].")
|
||||
@[[end]]
|
||||
|
||||
@[[my_macro("world", 7)]]
|
||||
@[[my_macro("user", 42)]]
|
||||
@[[my_macro("Earth", 0)]]
|
||||
@[[my_macro("Satna", 666)]]
|
15
examples/test.c
Normal file
15
examples/test.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
/* I really don't know why you'd do this. */
|
||||
|
||||
@[[function my_macro(a, b)]]
|
||||
printf("Good morning, @[{a}]. Your lucky number is @[{b}].");
|
||||
@[[end]]
|
||||
|
||||
int main() {
|
||||
@[[my_macro("user", 7)]]
|
||||
@[[my_macro("Steve", 24)]]
|
||||
@[[my_macro("Mr. Bones", 666)]]
|
||||
@[[my_macro("mother", -1)]]
|
||||
@[[my_macro(os.getenv("USER"), os.getenv("UID"))]]
|
||||
return 0;
|
||||
}
|
@ -53,7 +53,7 @@ local function generate(ast)
|
||||
end
|
||||
local env = {code = ""}
|
||||
local function run_away_screaming(fpos, err)
|
||||
io.stdout:write("ERROR: "..fps..": "..err.."\n")
|
||||
io.stdout:write("ERROR: "..fpos..": "..err.."\n")
|
||||
os.exit(1)
|
||||
end
|
||||
local function call_directive(fpos, dname, ...)
|
||||
@ -68,7 +68,7 @@ local function generate(ast)
|
||||
local function put_env(fpos, evar)
|
||||
local e = os.getenv(evar)
|
||||
if not e then
|
||||
run_away_screaming(fpos, "Enviroment variable `"..env.."' does not exist!")
|
||||
run_away_screaming(fpos, "Enviroment variable `"..evar.."' does not exist!")
|
||||
end
|
||||
env.code = env.code .. "\""..lua_escape(e).."\""
|
||||
end
|
||||
|
@ -22,9 +22,7 @@
|
||||
--#include "directive_provider.lua"
|
||||
--#include "cfg/minifier_providers.lua"
|
||||
|
||||
local argparse = (function()
|
||||
--#include "argparse.lua"
|
||||
end)()
|
||||
local argparse = require("argparse")
|
||||
|
||||
local parser = argparse(arg[0], "LuaComp v"..LUACOMP_VERSION.."\nA Lua preprocessor+postprocessor.")
|
||||
parser:argument("input", "Input file (- for STDIN)")
|
||||
|
0
src/staticinit.lua
Normal file
0
src/staticinit.lua
Normal file
Loading…
Reference in New Issue
Block a user