Permalink
Browse files

convert more modules

  • Loading branch information...
1 parent 38463a0 commit 915fc36b2ec81e04613be012125fc20e700e4c60 @leafo committed Nov 29, 2012
Showing with 25 additions and 22 deletions.
  1. +1 −1 bin/moonc
  2. +1 −1 moonscript/init.lua
  3. +1 −1 moonscript/init.moon
  4. +11 −9 moonscript/parse.lua
  5. +8 −3 moonscript/transform.lua
  6. +1 −4 moonscript/transform.moon
  7. +2 −3 test.lua
View
@@ -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
@@ -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
@@ -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
@@ -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)
--- parse a string
--- returns tree, or nil and error message
-function string(str)
- local g = build_grammar()
- return g:match(str)
-end
+return {
+ extract_line = extract_line,
+
+ -- parse a string
+ -- returns tree, or nil and error message
+ string = function (str)
+ local g = build_grammar()
+ return g:match(str)
+ end
+}
View
@@ -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
+}
@@ -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
@@ -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:", { })

0 comments on commit 915fc36

Please sign in to comment.