Page namespace (page_namespace) | 0 |
Page title (without namespace) (page_title) | 'Ero' |
Full page title (page_prefixedtitle) | 'Ero' |
Old content model (old_content_model) | 'wikitext' |
New content model (new_content_model) | 'wikitext' |
Old page wikitext, before the edit (old_wikitext) | '{{stub}}
{{WIP}}
is a esolang written in [http://lua.org Lua].
== Syntax: ==
:|: statement terminator
<hr>
:.(opcode) makes a statement
<hr>
|:: signals that arguments are after this
<hr>
>> is argument seperator.
== Example(s): ==
:.1|::1>>"Hello,world!":|:
:.8|::1>>1:|:
:.1|::1>>1:|::.1|::2>>1:|::.2|::1>>2>>3:|::.8|::1>>3:|:
== Current intrepeter ==
--|:: intrepeter
local reg={}
local pc = 1
local functions = {[1]=print,[2]=error}
local opc = {
[1]=function(a,b)-- :.1|::1>>"Hello,world!":|:
reg[a]=b
end;
[2]=function(a,b,c)--add
reg[c]=(reg[a]+reg[b])
end;
[3]=function(a,b,c)--sub
reg[c]=(reg[a]-reg[b])
end;
[4]=function(a,b,c)--mul
reg[c]=(reg[a]*reg[b])
end;
[5]=function(a,b,c)--div
reg[c]=(reg[a]/reg[b])
end;
[6]=function(a,b,c)--pow
reg[c]=(reg[a]^reg[b])
end;
[7]=function(a,b,c)--mod
reg[c]=(reg[a]%reg[b])
end;
[8]=function(a,...)--call
local args = {}
for i,v in ipairs({...}) do
args[i]=reg[v]
end
functions[a](table.unpack(args))
end;
[9]=function(n)--jump
pc=pc-n
end;
[10]=function(r,n)--jump if true
if reg[r] == true then
pc=pc-n
end
end
}
function compile(source)
local inst = {}
for stmt in source:gmatch("(.-):|:") do
local opco = stmt:match("^%.:([0-9]+)|::")
if opco then
opco = tonumber(opco)
-- print(opco)
local argst = stmt:match("|::(.*)")
local args = {}
-- print(argst)
if argst then
local argcount = 0
for argf in argst:gmatch("([^>>]+)") do
-- print(argf)
argcount=argcount+1
local fl = argf:sub(1,1)..argf:sub(-1)
local num = tonumber(argf)
if num then
args[#args+1] = num
elseif fl=="''" or fl=='""' then
args[#args+1] = argf:sub(2,-2)
elseif argf=="true" then args[#args+1] = true elseif argf=="false" then args[#args+1] = false
else error("invalid argument #"..argcount) end
end
end
inst[#inst+1]={opcode=opco, args=args}
end
end
return inst
end
function intrepet(p)
pc = 1
while p[pc] ~= nil do
while pc <= #p do
local instr = p[pc]
local op = opc[instr.opcode]
if op then
op(table.unpack(instr.args))
end
pc = pc + 1
end
end
end
if arg[1] == nil then
print("|:: (Ero), the esoteric language")
while true do
io.write(">")
local inp=io.read()
local ok,res =pcall(compile,inp)
--print(ok,table.concat(res," "))
if not ok then io.stderr:write(res) else intrepet(res) end
end
end' |
New page wikitext, after the edit (new_wikitext) | '{{stub}}
{{WIP}}
{{infobox proglang
|name=<nowiki>|::</nowiki>
|author=[[User:InLuaIKnow|InLuaIKnow]]
|year=2026
|majorimpl=[http://lua.org Lua]
}}
is a esolang written in [http://lua.org Lua].
== Syntax: ==
:|: statement terminator
<hr>
:.(opcode) makes a statement
<hr>
|:: signals that arguments are after this
<hr>
>> is argument seperator.
== Example(s): ==
:.1|::1>>"Hello,world!":|:
:.8|::1>>1:|:
:.1|::1>>1:|::.1|::2>>1:|::.2|::1>>2>>3:|::.8|::1>>3:|:
== Current intrepeter ==
--|:: intrepeter
local reg={}
local pc = 1
local functions = {[1]=print,[2]=error}
local opc = {
[1]=function(a,b)-- :.1|::1>>"Hello,world!":|:
reg[a]=b
end;
[2]=function(a,b,c)--add
reg[c]=(reg[a]+reg[b])
end;
[3]=function(a,b,c)--sub
reg[c]=(reg[a]-reg[b])
end;
[4]=function(a,b,c)--mul
reg[c]=(reg[a]*reg[b])
end;
[5]=function(a,b,c)--div
reg[c]=(reg[a]/reg[b])
end;
[6]=function(a,b,c)--pow
reg[c]=(reg[a]^reg[b])
end;
[7]=function(a,b,c)--mod
reg[c]=(reg[a]%reg[b])
end;
[8]=function(a,...)--call
local args = {}
for i,v in ipairs({...}) do
args[i]=reg[v]
end
functions[a](table.unpack(args))
end;
[9]=function(n)--jump
pc=pc-n
end;
[10]=function(r,n)--jump if true
if reg[r] == true then
pc=pc-n
end
end
}
function compile(source)
local inst = {}
for stmt in source:gmatch("(.-):|:") do
local opco = stmt:match("^%.:([0-9]+)|::")
if opco then
opco = tonumber(opco)
-- print(opco)
local argst = stmt:match("|::(.*)")
local args = {}
-- print(argst)
if argst then
local argcount = 0
for argf in argst:gmatch("([^>>]+)") do
-- print(argf)
argcount=argcount+1
local fl = argf:sub(1,1)..argf:sub(-1)
local num = tonumber(argf)
if num then
args[#args+1] = num
elseif fl=="''" or fl=='""' then
args[#args+1] = argf:sub(2,-2)
elseif argf=="true" then args[#args+1] = true elseif argf=="false" then args[#args+1] = false
else error("invalid argument #"..argcount) end
end
end
inst[#inst+1]={opcode=opco, args=args}
end
end
return inst
end
function intrepet(p)
pc = 1
while p[pc] ~= nil do
while pc <= #p do
local instr = p[pc]
local op = opc[instr.opcode]
if op then
op(table.unpack(instr.args))
end
pc = pc + 1
end
end
end
if arg[1] == nil then
print("|:: (Ero), the esoteric language")
while true do
io.write(">")
local inp=io.read()
local ok,res =pcall(compile,inp)
--print(ok,table.concat(res," "))
if not ok then io.stderr:write(res) else intrepet(res) end
end
end' |
Lines added in edit (added_lines) | [
0 => '{{infobox proglang',
1 => '|name=<nowiki>|::</nowiki>',
2 => '|author=[[User:InLuaIKnow|InLuaIKnow]]',
3 => '|year=2026',
4 => '|majorimpl=[http://lua.org Lua]',
5 => '}}'
] |