convert more modules

This commit is contained in:
leaf corcoran 2012-11-28 20:53:47 -08:00
parent 38463a078d
commit 915fc36b2e
7 changed files with 25 additions and 22 deletions

View File

@ -2,7 +2,7 @@
module("moonscript", package.seeall)
require "moonscript.parse"
local parse = require "moonscript.parse"
local compile = require "moonscript.compile"
local util = require "moonscript.util"

View File

@ -1,6 +1,6 @@
module("moonscript", package.seeall)
local compile = require("moonscript.compile")
require("moonscript.parse")
local parse = require("moonscript.parse")
local concat, insert = table.concat, table.insert
local split, dump
do

View File

@ -2,7 +2,7 @@
module "moonscript", package.seeall
compile = require "moonscript.compile"
require "moonscript.parse"
parse = require "moonscript.parse"
import concat, insert from table
import split, dump from require "moonscript.util"

View File

@ -1,4 +1,3 @@
module("moonscript.parse", package.seeall)
local util = require"moonscript.util"
@ -117,7 +116,7 @@ local function wrap_env(fn)
}))
end
function extract_line(str, start_pos)
local function extract_line(str, start_pos)
str = str:sub(start_pos)
m = str:match"^(.-)\n"
if m then return m end
@ -633,13 +632,16 @@ local build_grammar = wrap_env(function()
return tree
end
}
end)
return {
extract_line = extract_line,
-- parse a string
-- returns tree, or nil and error message
function string(str)
string = function (str)
local g = build_grammar()
return g:match(str)
end
}

View File

@ -1,4 +1,3 @@
module("moonscript.transform", package.seeall)
local types = require("moonscript.types")
local util = require("moonscript.util")
local data = require("moonscript.data")
@ -24,6 +23,7 @@ do
end
end
local implicitly_return
local Run
do
local _parent_0 = nil
local _base_0 = {
@ -335,7 +335,7 @@ construct_comprehension = function(inner, clauses)
end
return current_stms[1]
end
Statement = Transformer({
local Statement = Transformer({
root_stms = function(self, body)
return apply_to_last(body, implicitly_return(self))
end,
@ -1309,7 +1309,7 @@ implicitly_return = function(scope)
end
return fn
end
Value = Transformer({
local Value = Transformer({
["for"] = default_accumulator,
["while"] = default_accumulator,
foreach = default_accumulator,
@ -1549,3 +1549,8 @@ Value = Transformer({
})
end
})
return {
Statement = Statement,
Value = Value,
Run = Run
}

View File

@ -1,6 +1,4 @@
module "moonscript.transform", package.seeall
types = require "moonscript.types"
util = require "moonscript.util"
data = require "moonscript.data"
@ -22,8 +20,6 @@ mtype = do
else
t
export Statement, Value, Run
local implicitly_return
class Run
@ -879,3 +875,4 @@ Value = Transformer {
build.chain { base: {"parens", fn}, {"call", arg_list} }
}
{ :Statement, :Value, :Run }

View File

@ -10,9 +10,8 @@ pcall(function()
gettime = socket.gettime
end)
require "moonscript.parse"
require "moonscript.compile"
local parse, compile = moonscript.parse, moonscript.compile
parse = require "moonscript.parse"
compile = require "moonscript.compile"
local opts, ind = alt_getopt.get_opts(arg, "qd:", { })