Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ RypScript Ideas:
- new public/static function functionName(argA,argB,etc);
- new public/static class className <extends [parent]>;
- set <local> type tag=value;
- end
- // Comment here
- def tableName;
- Operators:
- +,-,*,/,%,+=,-= - Arithmetic Operators
- $ - String Concatenation
- ++, -- - Increment, Decrement
- <<, >> - Shift Directions
- ==, !=, <, >, <=, >= - Comparison Operators
- ]]--
- syntax.constructors={'new','set','establish','est'}
- syntax={}
- env={}
- env.data={}
- env.data_stack={}
- env.apis={}
- env.version_int=0.1
- env.version_int="Version: 0.1"
- env.math={}
- env.math.pi=math.pi()
- env.math.inf=math.huge
- env.math.neginf=math.huge-math.huge-math.huge
- ryp={}
- ryp.lang{}
- ryp.math{}
- ryp.string{}
- ryp.util{}
- ryp.file{}
- ryp.net{}
- ryp.sys={}
- function translate(line) -- Tramslates the code.
- end
- function clear() -- Clears the screen.
- term.clear()
- term.setCursorPos(1,1)
- end
- function printLogo() -- Prints the logo.
- print([[
- _____ _____ _ _
- | __ \ / ____| (_) | |
- | |__) | _ _ __| (___ ___ _ __ _ _ __ | |_
- | _ / | | | '_ \\___ \ / __| '__| | '_ \| __|
- | | \ \ |_| | |_) |___) | (__| | | | |_) | |_
- |_| \_\__, | .__/_____/ \___|_| |_| .__/ \__|
- __/ | | | |
- |___/|_| |_|]])
- end
- function split(str, pat) -- Splits strings.
- local t = {} -- NOTE: use {n = 0} in Lua-5.0
- local fpat = "(.-)" .. pat
- local last_end = 1
- local s, e, cap = str:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(t,cap)
- end
- last_end = e+1
- s, e, cap = str:find(fpat, last_end)
- end
- if last_end <= #str then
- cap = str:sub(last_end)
- table.insert(t, cap)
- end
- return t
- end
- function class(base, init) -- Establishes classes.
- local c = {} -- a new class instance
- if not init and type(base) == 'function' then
- init = base
- base = nil
- elseif type(base) == 'table' then
- -- our new class is a shallow copy of the base class!
- for i,v in pairs(base) do
- c[i] = v
- end
- c._base = base
- end
- -- the class will be the metatable for all its objects,
- -- and they will look up their methods in it.
- c.__index = c
- -- expose a constructor which can be called by <classname>(<args>)
- local mt = {}
- mt.__call = function(class_tbl, ...)
- local obj = {}
- setmetatable(obj,c)
- if init then
- init(obj,...)
- else
- -- make sure that any stuff from the base class is initialized!
- if base and base.init then
- base.init(obj, ...)
- end
- end
- return obj
- end
- c.init = init
- c.is_a = function(self, klass)
- local m = getmetatable(self)
- while m do
- if m == klass then return true end
- m = m._base
- end
- return false
- end
- setmetatable(c, mt)
- return c
- end
- function readFile(inFile,outFile) -- Reads the file and calls translate() line by line.
- input=fs.open(inFile,"r")
- output=fs.open(outFile,"w")
- while true do -- The primary loop of which the prgoram is compiled in
- line = inFile.readLine() -- This reads the line
- translate(line)
- if (not line) then inFile.close() outFile.close() os.reboot() break end -- This checks and makes it stop when there is a blank line
- end
- end
- function intro() -- Introduction function.
- clear()
- printLogo()
- print("Welcome to the RypScript transalter.")
- print("Enter the path to the file to translate from:")
- inPath=read()
- print("Enter the path to the file to output too:")
- outPath=read()
- readFile(inPath,outPath)
- end
- intro()
Advertisement
Add Comment
Please, Sign In to add comment