Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify compiler.l #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions bin/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var special63 = function (k) {
return is63(getenv(k, "special"));
};
var special_form63 = function (form) {
return ! atom63(form) && special63(hd(form));
return hd63(form, special63);
};
var statement63 = function (k) {
return special63(k) && getenv(k, "stmt");
Expand Down Expand Up @@ -197,7 +197,7 @@ var can_unquote63 = function (depth) {
return quoting63(depth) && depth === 1;
};
var quasisplice63 = function (x, depth) {
return can_unquote63(depth) && ! atom63(x) && hd(x) === "unquote-splicing";
return can_unquote63(depth) && hd63(x, "unquote-splicing");
};
var expand_local = function (__x38) {
var ____id1 = __x38;
Expand Down Expand Up @@ -576,7 +576,7 @@ var infix63 = function (x) {
return is63(getop(x));
};
infix_operator63 = function (x) {
return obj63(x) && infix63(hd(x));
return hd63(x, infix63);
};
var compile_args = function (args) {
var __s1 = "(";
Expand Down Expand Up @@ -683,7 +683,7 @@ var compile_special = function (form, stmt63) {
return apply(__special, __args2) + __tr;
};
var parenthesize_call63 = function (x) {
return ! atom63(x) && hd(x) === "%function" || precedence(x) > 0;
return hd63(x, "%function") || precedence(x) > 0;
};
var compile_call = function (form) {
var __f = hd(form);
Expand Down Expand Up @@ -811,7 +811,7 @@ compile = function (form) {
__e45 = compile_atom(__form);
} else {
var __e46 = undefined;
if (infix63(hd(__form))) {
if (infix_operator63(__form)) {
__e46 = compile_infix(__form);
} else {
__e46 = compile_call(__form);
Expand Down Expand Up @@ -853,7 +853,7 @@ var literal63 = function (form) {
return atom63(form) || hd(form) === "%array" || hd(form) === "%object";
};
var standalone63 = function (form) {
return ! atom63(form) && ! infix63(hd(form)) && ! literal63(form) && !( "get" === hd(form)) || id_literal63(form);
return ! atom63(form) && ! infix_operator63(form) && ! literal63(form) && ! hd63(form, "get") || id_literal63(form);
};
var lower_do = function (args, hoist, stmt63, tail63) {
var ____x95 = almost(args);
Expand Down Expand Up @@ -992,7 +992,7 @@ var lower_pairwise = function (form) {
}
};
var lower_infix63 = function (form) {
return infix63(hd(form)) && _35(form) > 3;
return infix_operator63(form) && _35(form) > 3;
};
var lower_infix = function (form, hoist) {
var __form3 = lower_pairwise(form);
Expand Down Expand Up @@ -1090,7 +1090,9 @@ _eval = function (form) {
return _37result;
};
immediate_call63 = function (x) {
return obj63(x) && obj63(hd(x)) && hd(hd(x)) === "%function";
return hd63(x, function (x) {
return hd63(x, "%function");
});
};
setenv("do", {_stash: true, special: function () {
var __forms1 = unstash(Array.prototype.slice.call(arguments, 0));
Expand All @@ -1103,10 +1105,8 @@ setenv("do", {_stash: true, special: function () {
__s3 = clip(__s3, 0, edge(__s3)) + ";\n";
}
__s3 = __s3 + compile(__x137, {_stash: true, stmt: true});
if (! atom63(__x137)) {
if (hd(__x137) === "return" || hd(__x137) === "break") {
break;
}
if (hd63(__x137, "return") || hd63(__x137, "break")) {
break;
}
____i19 = ____i19 + 1;
}
Expand Down
24 changes: 12 additions & 12 deletions bin/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ local function special63(k)
return is63(getenv(k, "special"))
end
local function special_form63(form)
return not atom63(form) and special63(hd(form))
return hd63(form, special63)
end
local function statement63(k)
return special63(k) and getenv(k, "stmt")
Expand Down Expand Up @@ -176,7 +176,7 @@ local function can_unquote63(depth)
return quoting63(depth) and depth == 1
end
local function quasisplice63(x, depth)
return can_unquote63(depth) and not atom63(x) and hd(x) == "unquote-splicing"
return can_unquote63(depth) and hd63(x, "unquote-splicing")
end
local function expand_local(__x38)
local ____id1 = __x38
Expand Down Expand Up @@ -522,7 +522,7 @@ local function infix63(x)
return is63(getop(x))
end
function infix_operator63(x)
return obj63(x) and infix63(hd(x))
return hd63(x, infix63)
end
local function compile_args(args)
local __s1 = "("
Expand Down Expand Up @@ -629,7 +629,7 @@ local function compile_special(form, stmt63)
return apply(__special, __args2) .. __tr
end
local function parenthesize_call63(x)
return not atom63(x) and hd(x) == "%function" or precedence(x) > 0
return hd63(x, "%function") or precedence(x) > 0
end
local function compile_call(form)
local __f = hd(form)
Expand Down Expand Up @@ -757,7 +757,7 @@ function compile(form, ...)
__e37 = compile_atom(__form)
else
local __e38 = nil
if infix63(hd(__form)) then
if infix_operator63(__form) then
__e38 = compile_infix(__form)
else
__e38 = compile_call(__form)
Expand Down Expand Up @@ -799,7 +799,7 @@ local function literal63(form)
return atom63(form) or hd(form) == "%array" or hd(form) == "%object"
end
local function standalone63(form)
return not atom63(form) and not infix63(hd(form)) and not literal63(form) and not( "get" == hd(form)) or id_literal63(form)
return not atom63(form) and not infix_operator63(form) and not literal63(form) and not hd63(form, "get") or id_literal63(form)
end
local function lower_do(args, hoist, stmt63, tail63)
local ____x98 = almost(args)
Expand Down Expand Up @@ -938,7 +938,7 @@ local function lower_pairwise(form)
end
end
local function lower_infix63(form)
return infix63(hd(form)) and _35(form) > 3
return infix_operator63(form) and _35(form) > 3
end
local function lower_infix(form, hoist)
local __form3 = lower_pairwise(form)
Expand Down Expand Up @@ -1043,7 +1043,9 @@ function _eval(form)
return _37result
end
function immediate_call63(x)
return obj63(x) and obj63(hd(x)) and hd(hd(x)) == "%function"
return hd63(x, function (x)
return hd63(x, "%function")
end)
end
setenv("do", {_stash = true, special = function (...)
local __forms1 = unstash({...})
Expand All @@ -1056,10 +1058,8 @@ setenv("do", {_stash = true, special = function (...)
__s3 = clip(__s3, 0, edge(__s3)) .. ";\n"
end
__s3 = __s3 .. compile(__x141, {_stash = true, stmt = true})
if not atom63(__x141) then
if hd(__x141) == "return" or hd(__x141) == "break" then
break
end
if hd63(__x141, "return") or hd63(__x141, "break") then
break
end
____i19 = ____i19 + 1
end
Expand Down
Loading