khepri-compile
Advanced tools
Comparing version 0.2.4 to 0.3.0
@@ -27,3 +27,3 @@ /* | ||
}); | ||
})(ecma_peep.optimize, transform.transform), khepri_peep.optimize), lexical.check), normalize.normalize); | ||
})(ecma_peep, transform), khepri_peep), lexical), normalize); | ||
(compile = (function(f, g) { | ||
@@ -30,0 +30,0 @@ return (function() { |
/* | ||
* THIS FILE IS AUTO GENERATED FROM 'lib/control/zipper.kep' | ||
* THIS FILE IS AUTO GENERATED from 'lib/control/zipper.kep' | ||
* DO NOT EDIT | ||
*/ | ||
"use strict"; | ||
var StateT = require("akh")["trans"]["state"], | ||
State = require("akh")["state"], | ||
IdentityT = require("akh")["trans"]["identity"], | ||
zipper = require("neith")["zipper"], | ||
tree = require("neith")["tree"], | ||
*/"use strict"; | ||
var Identity = require("akh")["identity"], | ||
ZipperT = require("./zippert"), | ||
Zipper; | ||
(Zipper = IdentityT(State)); | ||
(Zipper = ZipperT(Identity)); | ||
(Zipper.run = (function(m, ctx) { | ||
return State.evalState(IdentityT.runIdentityT(m), ctx); | ||
return Identity.runIdentity(ZipperT.run(m, ctx)); | ||
})); | ||
var lift = Zipper.lift; | ||
(Zipper.get = lift(State.get)); | ||
(Zipper.put = (function(f, g) { | ||
return (function(x) { | ||
return f(g(x)); | ||
}); | ||
})(lift, State.put)); | ||
(Zipper.extract = Zipper.get.chain(zipper.extract)); | ||
(Zipper.inspect = Zipper.get.map.bind(Zipper.get)); | ||
(Zipper.inspectWith = Zipper.extract.chain.bind(Zipper.extract)); | ||
(Zipper.move = (function(f, g) { | ||
return (function(x) { | ||
return f(g(x)); | ||
}); | ||
})(lift, State.modify)); | ||
(Zipper.up = Zipper.move(zipper.up)); | ||
(Zipper.down = Zipper.move(zipper.down)); | ||
(Zipper.left = Zipper.move(zipper.left)); | ||
(Zipper.right = Zipper.move(zipper.right)); | ||
(Zipper.node = Zipper.inspect(tree.node)); | ||
(Zipper.modifyNode = (function(f) { | ||
return Zipper.move(tree.modifyNode.bind(null, f)); | ||
})); | ||
(Zipper.setNode = (function(x) { | ||
return Zipper.move(tree.setNode.bind(null, x)); | ||
})); | ||
(Zipper.child = (function(edge) { | ||
return Zipper.move(tree.child.bind(null, edge)); | ||
})); | ||
(module.exports = Zipper); |
/* | ||
* THIS FILE IS AUTO GENERATED FROM 'lib/khepri_peep.kep' | ||
* THIS FILE IS AUTO GENERATED from 'lib/khepri_peep.kep' | ||
* DO NOT EDIT | ||
*/ | ||
"use strict"; | ||
*/"use strict"; | ||
var zipper = require("neith")["zipper"], | ||
@@ -18,31 +17,22 @@ __o = require("khepri-ast-zipper"), | ||
ast_value = require("khepri-ast")["value"], | ||
__o1 = require("akh")["base"], | ||
next = __o1["next"], | ||
seq = __o1["sequence"], | ||
seqa = __o1["sequencea"], | ||
fun = require("./fun"), | ||
__o1 = require("./control/base"), | ||
next = __o1["next"], | ||
binary = __o1["binary"], | ||
seq = __o1["seq"], | ||
seqa = __o1["seqa"], | ||
Zipper = require("./control/zipper"), | ||
UniqueT = require("./control/uniquet"), | ||
optimize, M = UniqueT(Zipper), | ||
ZipperT = require("./control/zippert"), | ||
Unique = require("./control/unique"), | ||
optimize, M = ZipperT(Unique), | ||
run = (function(c, ctx, seed) { | ||
return Zipper.run(UniqueT.runUniqueT(c, seed), ctx); | ||
return Unique.runUnique(ZipperT.run(c, ctx), seed); | ||
}), | ||
pass = M.of(null), | ||
extract = M.lift(Zipper.get), | ||
node = M.lift(Zipper.node), | ||
move = (function(f, g) { | ||
return (function(x) { | ||
return f(g(x)); | ||
}); | ||
})(M.lift, Zipper.move), | ||
up = M.lift(Zipper.up), | ||
right = M.lift(Zipper.right), | ||
down = M.lift(Zipper.down), | ||
modify = (function(f, g) { | ||
return (function(x) { | ||
return f(g(x)); | ||
}); | ||
})(M.lift, Zipper.modifyNode), | ||
unique = M.unique, | ||
extract = M.get, | ||
node = M.node, | ||
move = M.move, | ||
up = M.up, | ||
right = M.right, | ||
down = M.down, | ||
modify = M.modifyNode, | ||
unique = M.lift(Unique.unique), | ||
peepholes = ({}), | ||
@@ -105,14 +95,24 @@ addPeephole = (function(types, up, condition, f) { | ||
return true; | ||
}), binary(unique, unique, (function(xUid, yUid) { | ||
return modify((function(node) { | ||
var xArg = setData(ast_value.Identifier.create(null, "x"), "uid", xUid), | ||
yArg = setData(ast_value.Identifier.create(null, "y"), "uid", yUid), | ||
kind = (((node.op === "||") || (node.op === "&&")) ? ast_expression.LogicalExpression.create : | ||
((node.op === ".") ? (function(loc, _, x, y) { | ||
return ast_expression.MemberExpression.create(loc, x, y, true); | ||
}) : ast_expression.BinaryExpression.create)); | ||
return ast_expression.FunctionExpression.create(null, null, ast_pattern.ArgumentsPattern.create( | ||
null, null, [ast_pattern.IdentifierPattern.create(null, xArg), ast_pattern.IdentifierPattern | ||
.create(null, yArg) | ||
]), kind(null, node.op, xArg, yArg)); | ||
}), unique.chain((function(xUid) { | ||
return unique.chain((function(yUid) { | ||
return modify((function(node) { | ||
var xArg = setData(ast_value.Identifier.create(null, "x"), "uid", xUid), | ||
yArg = setData(ast_value.Identifier.create(null, "y"), "uid", yUid), | ||
kind = (((node.op === "||") || (node.op === "&&")) ? ast_expression.LogicalExpression | ||
.create : ((node.op === ".") ? (function(loc, _, x, y) { | ||
return ast_expression.MemberExpression.create(loc, x, y, | ||
true); | ||
}) : ((node.op === "@") ? (function(loc, _, x, y) { | ||
return ast_expression.CurryExpression.create(loc, x, y); | ||
}) : ((node.op === "new") ? (function(loc, _, x, y) { | ||
return ast_expression.NewExpression.create(loc, x, [ | ||
y | ||
]); | ||
}) : ast_expression.BinaryExpression.create)))); | ||
return ast_expression.FunctionExpression.create(null, null, ast_pattern.ArgumentsPattern | ||
.create(null, null, [ast_pattern.IdentifierPattern.create(null, xArg), | ||
ast_pattern.IdentifierPattern.create(null, yArg) | ||
]), (node.flipped ? kind(null, node.op, yArg, xArg) : kind(null, node.op, | ||
xArg, yArg))); | ||
})); | ||
})); | ||
@@ -119,0 +119,0 @@ }))); |
@@ -15,14 +15,13 @@ /* | ||
record = require("bes")["record"], | ||
__o0 = require("akh")["base"], | ||
next = __o0["next"], | ||
seq = __o0["sequence"], | ||
seqa = __o0["sequencea"], | ||
StateT = require("akh")["trans"]["state"], | ||
Identity = require("akh")["identity"], | ||
ErrorT = require("akh")["trans"]["error"], | ||
scope = require("./scope"), | ||
Scope = scope["Scope"], | ||
fun = require("./fun"), | ||
__o0 = require("./control/base"), | ||
next = __o0["next"], | ||
seq = __o0["seq"], | ||
seqa = __o0["seqa"], | ||
binary = __o0["binary"], | ||
Zipper = require("./control/zipper"), | ||
StateT = require("akh")["trans"]["state"], | ||
Identity = require("akh")["identity"], | ||
ErrorT = require("akh")["trans"]["error"], | ||
check, _check, State = record.declare(null, ["scope", "unique"]), | ||
@@ -29,0 +28,0 @@ StateM = StateT(Zipper), |
@@ -16,2 +16,2 @@ /* | ||
})); | ||
(exports["optimize"] = optimize); | ||
(module.exports = optimize); |
@@ -15,2 +15,2 @@ /* | ||
})); | ||
(exports["optimize"] = optimize); | ||
(module.exports = optimize); |
@@ -25,2 +25,2 @@ /* | ||
})); | ||
(exports["check"] = check); | ||
(module.exports = check); |
@@ -16,2 +16,2 @@ /* | ||
})); | ||
(exports["normalize"] = normalize); | ||
(module.exports = normalize); |
@@ -16,2 +16,2 @@ /* | ||
})); | ||
(exports["transform"] = transform); | ||
(module.exports = transform); |
@@ -7,3 +7,2 @@ /* | ||
var record = require("bes")["record"], | ||
array = require("bes")["array"], | ||
ecma_clause = require("ecma-ast")["clause"], | ||
@@ -29,41 +28,19 @@ ecma_declaration = require("ecma-ast")["declaration"], | ||
zipper = require("neith")["zipper"], | ||
StateM = require("akh")["state"], | ||
__o0 = require("akh")["base"], | ||
next = __o0["next"], | ||
seq = __o0["sequence"], | ||
seqa = __o0["sequencea"], | ||
scope = require("./scope"), | ||
__o0 = require("./tail"), | ||
Tail = __o0["Tail"], | ||
trampoline = __o0["trampoline"], | ||
fun = require("./fun"), | ||
flip = fun["flip"], | ||
transform, objectElementUnpack, _transform = (function() { | ||
var args = arguments; | ||
return _transform.apply(null, args); | ||
}), | ||
State = record.declare(null, ["ctx", "scope", "packageManager", "bindings", "unique"]); | ||
transform, objectElementUnpack, State = record.declare(null, ["ctx", "scope", "packageManager", "bindings", | ||
"unique" | ||
]); | ||
(State.empty = State.create(null, scope.Scope.empty, null, [ | ||
[], null | ||
], 0)); | ||
var ok = (function(x) { | ||
return (function(s, ok) { | ||
return ok(x, s); | ||
}); | ||
}), | ||
bind = (function(p, f) { | ||
return (function(s, ok) { | ||
return new(Tail)(p, s, (function(x, s) { | ||
return f(x)(s, ok); | ||
})); | ||
}); | ||
}), | ||
var ok = StateM.of, | ||
bind = StateM.chain, | ||
pass = ok(), | ||
next = (function(p, n) { | ||
return bind(p, (function(_) { | ||
return n; | ||
})); | ||
}), | ||
seqa = (function(arr) { | ||
return fun.reduce(arr, next); | ||
}), | ||
seq = (function() { | ||
var args = arguments; | ||
return seqa(args); | ||
}), | ||
binds = (function(p, f) { | ||
@@ -75,4 +52,4 @@ return bind(p, (function(x) { | ||
cons = (function(a, b) { | ||
return bind(a, (function(x) { | ||
return bind(b, (function(y) { | ||
return a.chain((function(x) { | ||
return b.chain((function(y) { | ||
return ok([x].concat(y)); | ||
@@ -83,20 +60,6 @@ })); | ||
enumeration = fun.foldr.bind(null, flip(cons), ok([])), | ||
extract = (function(s, ok) { | ||
return ok(s, s); | ||
}), | ||
setState = (function(s) { | ||
return (function(_, ok) { | ||
return ok(s, s); | ||
}); | ||
}), | ||
modifyState = (function(f) { | ||
return bind(extract, (function(s) { | ||
return setState(f(s)); | ||
})); | ||
}), | ||
examineState = (function(f) { | ||
return bind(extract, (function(s) { | ||
return f(s); | ||
})); | ||
}), | ||
extract = StateM.get, | ||
setState = StateM.put, | ||
modifyState = StateM.modify, | ||
examineState = StateM.chain.bind(null, StateM.get), | ||
examineScope = (function(f) { | ||
@@ -107,7 +70,2 @@ return bind(extract, (function(s) { | ||
}), | ||
examineRealScope = (function(f) { | ||
return bind(extract, (function(s) { | ||
return f(s.realScope); | ||
})); | ||
}), | ||
packageManager = examineState((function(s) { | ||
@@ -117,7 +75,5 @@ return ok(s.packageManager); | ||
modifyScope = (function(f) { | ||
return (function(s, ok, err) { | ||
var scope = f(s.scope), | ||
newState = State.setScope(s, scope); | ||
return ok(scope, newState); | ||
}); | ||
return modifyState((function(s) { | ||
return s.setScope(f(s.scope)); | ||
})); | ||
}), | ||
@@ -197,2 +153,5 @@ setScope = (function(s) { | ||
}), | ||
_trans, _transform = bind(node, (function(x) { | ||
return _trans(x); | ||
})), | ||
identifier = (function(loc, name) { | ||
@@ -533,3 +492,3 @@ return ecma_value.Identifier.create(loc, name); | ||
}))); | ||
var _trans = (function(node) { | ||
(_trans = (function(node) { | ||
if ((node && (node instanceof khepri_node.Node))) { | ||
@@ -540,12 +499,11 @@ var t = transformers[node.type]; | ||
return pass; | ||
})); | ||
var _transp = (function(node) { | ||
if ((node && (node instanceof khepri_node.Node))) { | ||
var t = transformers[node.type]; | ||
if ((t && t[0].post)) return t[0].post; | ||
} | ||
return pass; | ||
}), | ||
_transp = (function(node) { | ||
if ((node && (node instanceof khepri_node.Node))) { | ||
var t = transformers[node.type]; | ||
if ((t && t[0].post)) return t[0].post; | ||
} | ||
return pass; | ||
}); | ||
(_transform = bind(node, _trans)); | ||
var _transformPost = bind(node, _transp), | ||
_transformPost = bind(node, _transp), | ||
walk = (function(pre, post) { | ||
@@ -576,6 +534,4 @@ return next(pre, bind(ctx, (function(t) { | ||
.setUnique(data.unique); | ||
return trampoline(next(walk(_transform, _transformPost), node)(s, (function(x) { | ||
return x; | ||
}))); | ||
return StateM.evalState(next(walk(_transform, _transformPost), node), s); | ||
})); | ||
(exports["transform"] = transform); |
{ | ||
"name": "khepri-compile", | ||
"version": "0.2.4", | ||
"version": "0.3.0", | ||
"description": "Compiler for the Khepri programming language", | ||
@@ -41,3 +41,3 @@ "author": "Matt Bierner", | ||
"khepri-ast": "3.6.x", | ||
"khepri-ast": "3.7.x", | ||
"khepri-ast-zipper": "1.1.x", | ||
@@ -54,3 +54,3 @@ | ||
"khepri-parse": "0.8.x", | ||
"khepri-parse": "0.9.x", | ||
"ecma-unparse": "3.2.x" | ||
@@ -57,0 +57,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
56
169212
2409
13
+ Addedkhepri-ast@3.7.0(transitive)
- Removedkhepri-ast@3.6.2(transitive)
Updatedkhepri-ast@3.7.x