bkc
Version:
:dog: If there are no dogs in Heaven, then when I die I want to go where they went.
28 lines (27 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const ast_1 = require("./ast/ast");
const error_1 = require("./execute/error");
const execute_1 = require("./execute/execute");
const check_1 = require("./util/check");
const determine_1 = require("./util/determine");
exports.bkc = (code, optionsE) => {
const options = check_1.fixOption(optionsE);
if (check_1.checkOptionNameSpace(options).length !== 0) {
throw error_1.error(error_1.ERROR_CODE.NAMESPACE_OCCUPIED_INITIAL);
}
const ast = ast_1.default(code, options);
const executed = execute_1.default(ast, options);
for (let i of executed) {
if (determine_1.determineReturn(i.value)) {
return i.arg;
}
const func = determine_1.determine(i.value, options.externals);
if (!func) {
throw error_1.error(error_1.ERROR_CODE.COMMAND_IS_UNDEFINED);
}
func(i.arg);
}
return void 0;
};
exports.default = exports.bkc;