Basic Rust to Lua converter.
Works for simple scripts and programs, go check it out it would mean a lot
To see output press F9 and chose server instead of client.
Works for simple scripts and programs, go check it out it would mean a lot
This is very intriguing, how’d you end up writing the transpiler part of it? You also can’t see the output unless you’re a developer just so you know.
I created a crude calc struct with an impl block and it seems to translate well.
Input:
// Rust input
struct Calc {
first: i32,
second: i32,
}
impl Calc {
fn new(f: i32, s: i32) -> Self {
Self {
first: f,
second: s
}
}
fn add(self) -> i32 {
self.first + self.second
}
}
fn main() -> () {
let e = Calc::new(6, 7);
let res = e.add();
println!("{}", res);
}
Output:
-- Compiled Rust to Luau (public ver1.0)
-- creds. regex lexer and ast parser written by physics1514_, transpiler by enzo421 & physics1514_
local String = { from = function(s) return s end }
local Ordering = { Less = "Less", Equal = "Equal", Greater = "Greater" }
local function __cmp(a, b) if a < b then return Ordering.Less elseif a > b then return Ordering.Greater else return Ordering.Equal end end
local Vec = {}; Vec.__index = Vec
function Vec.new() return setmetatable({}, Vec) end
function Vec:push(v) table.insert(self, v) end
function Vec:pop() return table.remove(self) end
function Vec:len() return #self end
function Vec:sort() table.sort(self) end
function Vec:insert(i, v) table.insert(self, i, v) end
function Vec:remove(i) return table.remove(self, i) end
local Calc = {}; Calc.__index = Calc
function Calc.new(f, s)
return setmetatable({first = f, second = s}, Calc)
end
function Calc:add()
return self.first + self.second
end
function main()
local e = Calc.new(6, 7)
local res = e:add()
print(string.format("%s", res))
end
main()