mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
refactor types out of compile
This commit is contained in:
parent
445ef4314a
commit
64fd33c089
@ -1,11 +1,19 @@
|
||||
module("moonscript.compile", package.seeall)
|
||||
local util = require("moonscript.util")
|
||||
local data = require("moonscript.data")
|
||||
local dump = require("moonscript.dump")
|
||||
require("moonscript.compile.format")
|
||||
require("moonscript.compile.line")
|
||||
require("moonscript.compile.value")
|
||||
local ntype, Set = data.ntype, data.Set
|
||||
local Set
|
||||
do
|
||||
local _table_0 = require("moonscript.data")
|
||||
Set = _table_0.Set
|
||||
end
|
||||
local ntype
|
||||
do
|
||||
local _table_0 = require("moonscript.types")
|
||||
ntype = _table_0.ntype
|
||||
end
|
||||
local concat, insert = table.concat, table.insert
|
||||
local pos_to_line, get_closest_line, trim = util.pos_to_line, util.get_closest_line, util.trim
|
||||
local bubble_names = {
|
||||
|
@ -1,14 +1,15 @@
|
||||
module "moonscript.compile", package.seeall
|
||||
|
||||
util = require "moonscript.util"
|
||||
data = require "moonscript.data"
|
||||
dump = require "moonscript.dump"
|
||||
|
||||
require "moonscript.compile.format"
|
||||
require "moonscript.compile.line"
|
||||
require "moonscript.compile.value"
|
||||
|
||||
import ntype, Set from data
|
||||
import Set from require "moonscript.data"
|
||||
import ntype from require "moonscript.types"
|
||||
|
||||
import concat, insert from table
|
||||
import pos_to_line, get_closest_line, trim from util
|
||||
|
||||
|
@ -1,7 +1,16 @@
|
||||
module("moonscript.compile", package.seeall)
|
||||
local util = require("moonscript.util")
|
||||
local data = require("moonscript.data")
|
||||
local Set, ntype = data.Set, data.ntype
|
||||
local Set
|
||||
do
|
||||
local _table_0 = require("moonscript.data")
|
||||
Set = _table_0.Set
|
||||
end
|
||||
local ntype
|
||||
do
|
||||
local _table_0 = require("moonscript.types")
|
||||
ntype = _table_0.ntype
|
||||
end
|
||||
local concat, insert = table.concat, table.insert
|
||||
indent_char = " "
|
||||
user_error = function(...)
|
||||
|
@ -3,7 +3,8 @@ module "moonscript.compile", package.seeall
|
||||
util = require "moonscript.util"
|
||||
data = require "moonscript.data"
|
||||
|
||||
import Set, ntype from data
|
||||
import Set from require "moonscript.data"
|
||||
import ntype from require "moonscript.types"
|
||||
import concat, insert from table
|
||||
|
||||
export indent_char, default_return, moonlib, cascading, non_atomic, has_value, is_non_atomic
|
||||
|
@ -1,10 +1,13 @@
|
||||
module("moonscript.compile", package.seeall)
|
||||
local util = require("moonscript.util")
|
||||
local data = require("moonscript.data")
|
||||
require("moonscript.compile.format")
|
||||
require("moonscript.compile.types")
|
||||
local reversed = util.reversed
|
||||
local ntype = data.ntype
|
||||
local ntype, smart_node
|
||||
do
|
||||
local _table_0 = require("moonscript.types")
|
||||
ntype = _table_0.ntype
|
||||
smart_node = _table_0.smart_node
|
||||
end
|
||||
local concat, insert = table.concat, table.insert
|
||||
local constructor_name = "new"
|
||||
line_compile = {
|
||||
|
@ -1,13 +1,11 @@
|
||||
module "moonscript.compile", package.seeall
|
||||
|
||||
util = require "moonscript.util"
|
||||
data = require "moonscript.data"
|
||||
|
||||
require "moonscript.compile.format"
|
||||
require "moonscript.compile.types"
|
||||
|
||||
import reversed from util
|
||||
import ntype from data
|
||||
import ntype, smart_node from require "moonscript.types"
|
||||
import concat, insert from table
|
||||
|
||||
export line_compile
|
||||
|
@ -2,7 +2,11 @@ module("moonscript.compile", package.seeall)
|
||||
local util = require("moonscript.util")
|
||||
local data = require("moonscript.data")
|
||||
require("moonscript.compile.format")
|
||||
local ntype = data.ntype
|
||||
local ntype
|
||||
do
|
||||
local _table_0 = require("moonscript.types")
|
||||
ntype = _table_0.ntype
|
||||
end
|
||||
local concat, insert = table.concat, table.insert
|
||||
local table_append
|
||||
table_append = function(name, len, value)
|
||||
|
@ -6,7 +6,7 @@ data = require "moonscript.data"
|
||||
|
||||
require "moonscript.compile.format"
|
||||
|
||||
import ntype from data
|
||||
import ntype from require "moonscript.types"
|
||||
import concat, insert from table
|
||||
|
||||
export value_compile
|
||||
|
@ -1,12 +1,5 @@
|
||||
module("moonscript.data", package.seeall)
|
||||
local concat = table.concat
|
||||
ntype = function(node)
|
||||
if type(node) ~= "table" then
|
||||
return "value"
|
||||
else
|
||||
return node[1]
|
||||
end
|
||||
end
|
||||
Set = function(items)
|
||||
local self = { }
|
||||
do
|
||||
|
@ -1,19 +1,11 @@
|
||||
-- data structure utils
|
||||
|
||||
-- data structures & static data
|
||||
module "moonscript.data", package.seeall
|
||||
|
||||
export Set, Stack
|
||||
export ntype, lua_keywords
|
||||
export lua_keywords
|
||||
|
||||
import concat from table
|
||||
|
||||
-- type of node as string
|
||||
ntype = (node) ->
|
||||
if type(node) != "table"
|
||||
"value"
|
||||
else
|
||||
node[1]
|
||||
|
||||
Set = (items) ->
|
||||
self = {}
|
||||
self[key] = true for key in *items
|
||||
|
@ -1,6 +1,6 @@
|
||||
module("moonscript", package.seeall)
|
||||
require("moonscript.parse")
|
||||
require("moonscript.compile")
|
||||
require("moonscript.parse")
|
||||
require("moonscript.util")
|
||||
local concat, insert = table.concat, table.insert
|
||||
local split, dump = util.split, util.dump
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
module "moonscript", package.seeall
|
||||
|
||||
require "moonscript.parse"
|
||||
require "moonscript.compile"
|
||||
require "moonscript.parse"
|
||||
require "moonscript.util"
|
||||
|
||||
import concat, insert from table
|
||||
|
@ -4,10 +4,12 @@ local util = require"moonscript.util"
|
||||
|
||||
require"lpeg"
|
||||
|
||||
local dump = require"moonscript.dump"
|
||||
local data = require"moonscript.data"
|
||||
local types = require"moonscript.types"
|
||||
|
||||
local ntype = data.ntype
|
||||
local ntype = types.ntype
|
||||
|
||||
local dump = util.dump
|
||||
local trim = util.trim
|
||||
|
||||
local Stack = data.Stack
|
||||
|
@ -1,7 +1,13 @@
|
||||
module("moonscript.compile", package.seeall)
|
||||
module("moonscript.types", package.seeall)
|
||||
local util = require("moonscript.util")
|
||||
local data = require("moonscript.data")
|
||||
local ntype = data.ntype
|
||||
ntype = function(node)
|
||||
if type(node) ~= "table" then
|
||||
return "value"
|
||||
else
|
||||
return node[1]
|
||||
end
|
||||
end
|
||||
local t = { }
|
||||
local node_types = {
|
||||
fndef = {
|
@ -1,13 +1,15 @@
|
||||
module "moonscript.compile", package.seeall
|
||||
|
||||
module "moonscript.types", package.seeall
|
||||
util = require "moonscript.util"
|
||||
data = require "moonscript.data"
|
||||
|
||||
import ntype from data
|
||||
export smart_node, build
|
||||
export ntype, smart_node, build
|
||||
|
||||
-- todo: this should be merged into data
|
||||
-- lets us index a node by item name based on it's type
|
||||
-- type of node as string
|
||||
ntype = (node) ->
|
||||
if type(node) != "table"
|
||||
"value"
|
||||
else
|
||||
node[1]
|
||||
|
||||
t = {}
|
||||
|
||||
@ -51,6 +53,7 @@ build = setmetatable {}, {
|
||||
rawget self, name
|
||||
}
|
||||
|
||||
-- makes it so node properties can be accessed by name instead of index
|
||||
smart_node = (node) ->
|
||||
index = key_table[ntype node]
|
||||
if not index then return node
|
Loading…
Reference in New Issue
Block a user