Fri, 15 Oct 2010 15:17:17 +0100
Initial commit
#!/usr/bin/env lua local jslex = require "lib.jslex" local js2lua = require "lib.js2lua" local stream = jslex.new_stream(io.open(arg[1])); local list = {}; local i, token_type, token_value = 0, stream.get_token(); while token_type do i = i + 1; list[i] = { type = token_type, value = token_value }; -- print("Line "..(stream.line or 1)..":", token_type, token_value); token_type, token_value = stream.get_token(); end io.stderr:write("js2lua: Translating...\n"); local d = {}; local function w(t) table.insert(d, t); end js2lua(list, w); io.stderr:write("===== Result ======\n", table.concat(d), "\n===== ====== =====\n"); io.stderr:write("js2lua: Running...\n"); assert(loadstring(table.concat(d)))();