▓▓▓ ▒▒▒ ▒▒▒ ▓▓▓ ███
███ ▓▓▓ ▒▒▒ ▓▓▓ ███
▓▓▓ ███ ▓▓▓ ▒▒▒ ▓▓▓
▒▒▒ ▓▓▓ ███ ▓▓▓ ▒▒▒ awk metaprogrammer Tiny scripts, huge potential. #preprocessor #awk #lua #permacomputing #lite
NOTE:
meta.awkandmeta.luaare interchangable. For exotic operating systems without lua/awk: check here
$ ./meta.awk input.html > output.html
$ ./meta.lua input.html > output.html<ul>
# for( i = 0; i < 2; i++ ){
<li>
# print(" "i)
</li>
# }
</ul>output.html:
<ul>
<li>
0
</li>
<li>
1
</li>
</ul>You can change the prefix (#) to fit other languages better.
Here's a 3-in-1 demo which generates nelua/redbean-specific code from lua-code:
$ target=redbean meta.lua input.lua '--|' > out.redbean.lua
$ target=nelua meta.lua input.lua '--|' > out.nelua
$ target=lua meta.lua input.lua '--|' > out.lua input.lua:
--| target = os.getenv("target")
--| if target == "nelua" then
local a: Person =
--| else
local a =
--| end
{name = "Mark", age = 20}
--| if target ~= "redbean" then
function LaunchBrowser() return false; end -- dummy function
--| end
print(a.name, a.age)
print("hello world from $(target)")out.nelua:
local a: Person =
{name = "Mark", age = 20}
function LaunchBrowser() return false; end -- dummy function
print(a.name, a.age)
print("hello world from nelua")
out.redbean.lua:
local a =
{name = "Mark", age = 20}
print(a.name, a.age)
print("hello world from redbean")
out.lua:
local a =
{name = "Mark", age = 20}
function LaunchBrowser() return false; end -- dummy function
print(a.name, a.age)
print("hello world from lua")
Chances are your OS already has lua/awk installed. However:
TIP: see portable crossplatform awk/lua binaries thanks to cosmopolitan libc♥) (don't forget to run
chmod +x awk lua)
AWK is awesome, its tiny and usually preinstalled on many Os'ses..linux distros..busybox..etc Lua is awesome, and tiny and has various cool dialects (teal / nelua) allow targeting web/games/esp32 from the same lua-code.