Module:Sandbox/AnataBakka

local p = {} local lib      = require('Module:Feature')

function p.get(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end allvals="" val=string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(args[1]," ",""),"%/"," / "),"%*"," * "),"%+"," + "),"%-"," - ") val=expr(val) if allvals~="" then allvals=allvals.." / "..val else allvals=val end return allvals end function expr(val) local i=1 local j=1 local a,b local switcher while i>0 do       while j>0 do            temp=val if string.find(val,"%)")~=nil then               switchertemp=mw.text.split( val, "%)") temp=last(switchertemp[1],"%(")               end            if string.find(temp,"%/")~=nil then                a=mw.text.split(temp,"%/")                b=mw.text.split(a[2]," ")                switcher=last( a[1]," ")                switcher2=b[2]                switcher3=switcher/switcher2                val=string.gsub(val,switcher.." %/ "..switcher2,switcher3)                break            end            if string.find(temp,"%*")~=nil then                a=mw.text.split( temp,"%*")                b=mw.text.split(a[2]," ")                switcher=last( a[1]," ")                switcher2=b[2]                switcher3=switcher*switcher2                val=string.gsub(val,switcher.." %* "..switcher2,switcher3)                break            end            if string.find(temp,"%-")~=nil then                a=mw.text.split( temp,"%-")                b=mw.text.split(a[2]," ") switcher=last( a[1]," ") switcher2=b[2] switcher3=switcher-switcher2 val=string.gsub(val,switcher.." %- "..switcher2,switcher3) break end if string.find(temp,"%+")~=nil then a=mw.text.split( temp,"%+") b=mw.text.split(a[2]," ") switcher=last( a[1]," ") switcher2=b[2] switcher3=switcher+switcher2 val=string.gsub(val,switcher.." %+ "..switcher2,switcher3) break end if string.find(val,"%)")~=nil then               val=string.gsub(val,"%("..temp.."%)",temp)                break            else                i=0            end            break        end    end return temp end function last(val,sign)    local a=mw.text.split(val,sign)    local j=1    while j>0 do                if (a[j] ~=nil) and (a[j] ~="") then                    j=j+1                else                    break                end    end    return a[j-1] end return p