Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
'use strict';
var AST = require("./aST.bs.js");
var List = require("bs-platform/lib/js/list.js");
var $$Array = require("bs-platform/lib/js/array.js");
var Curry = require("bs-platform/lib/js/curry.js");
var Pervasives = require("bs-platform/lib/js/pervasives.js");
function hydrate(st) {
return st;
}
function dehydrate(st) {
return st;
}
function from_script(scpt) {
return scpt[/* statements */0];
}
var pp = AST.pp_statement;
function count(st) {
return st[/* count */0];
}
function command(st) {
return st[/* cmd */1];
}
function payload_to_opt(param) {
if (param) {
return param[0];
}
}
function mem(key, st) {
var is_matching_key = function (param) {
if (param.tag) {
return param[0][/* name */0] === key;
} else {
return false;
}
};
return List.exists(is_matching_key, $$Array.to_list(st[/* args */2]));
}
function is_resolved(key, st) {
var is_matching_resolved_key = function (param) {
if (param.tag) {
var f = param[0];
if (f[/* name */0] !== key) {
return false;
} else {
var match = f[/* payload */1];
if (typeof match === "number") {
return match !== 0;
} else {
return true;
}
}
} else {
return false;
}
};
return List.exists(is_matching_resolved_key, $$Array.to_list(st[/* args */2]));
}
function has_payload(key, st) {
var is_matching_resolved_key_with_payload = function (param) {
if (param.tag) {
var f = param[0];
if (f[/* name */0] !== key) {
return false;
} else {
var match = f[/* payload */1];
if (typeof match === "number") {
return false;
} else {
return true;
}
}
} else {
return false;
}
};
return List.exists(is_matching_resolved_key_with_payload, $$Array.to_list(st[/* args */2]));
}
function flag(key, st) {
var consuming_flag = /* record */[/* contents */undefined];
var result = /* record */[/* contents */undefined];
var iterator = function (arg) {
var match = result[0];
if (match !== undefined) {
return true;
} else if (arg.tag) {
var flag = arg[0];
console.log(flag[/* name */0]);
if (flag[/* name */0] !== key) {
return true;
} else {
var match$1 = flag[/* payload */1];
if (typeof match$1 === "number" && match$1 === 0) {
consuming_flag[0] = flag;
return true;
} else {
result[0] = flag;
return true;
}
}
} else {
var match$2 = consuming_flag[0];
if (match$2 !== undefined) {
var fl = match$2;
fl[/* payload */1] = /* Resolved */[arg[0]];
result[0] = fl;
consuming_flag[0] = undefined;
return false;
} else {
return true;
}
}
};
st[/* args */2] = $$Array.of_list(List.filter(iterator)($$Array.to_list(st[/* args */2])));
var match = result[0];
if (match !== undefined) {
var match$1 = match[/* payload */1];
if (typeof match$1 === "number") {
if (match$1 !== 0) {
return /* Empty */0;
} else {
return Pervasives.failwith("Unreachable");
}
} else {
return /* Payload */[match$1[0]];
}
}
}
function resolve_all_flags(st) {
var consuming_flag = /* record */[/* contents */undefined];
var iterator = function (arg) {
if (arg.tag) {
var flag = arg[0];
var match = flag[/* payload */1];
if (typeof match === "number" && match === 0) {
consuming_flag[0] = flag;
return true;
} else {
return true;
}
} else {
var match$1 = consuming_flag[0];
if (match$1 !== undefined) {
match$1[/* payload */1] = /* Resolved */[arg[0]];
consuming_flag[0] = undefined;
return false;
} else {
return true;
}
}
};
st[/* args */2] = $$Array.of_list(List.filter(iterator)($$Array.to_list(st[/* args */2])));
return /* () */0;
}
function iter(f, st) {
resolve_all_flags(st);
var iterator = function (param) {
if (param.tag) {
var flag = param[0];
var match = flag[/* payload */1];
if (typeof match === "number") {
if (match !== 0) {
return Curry._2(f, flag[/* name */0], /* Empty */0);
} else {
return Pervasives.failwith("Unreachable");
}
} else {
return Curry._2(f, flag[/* name */0], /* Payload */[match[0]]);
}
} else {
return /* () */0;
}
};
return $$Array.iter(iterator, st[/* args */2]);
}
function positionals(st) {
var filter = function (param) {
if (param.tag) {
var flag = param[0];
var match = flag[/* payload */1];
if (typeof match === "number" && match === 0) {
flag[/* payload */1] = /* Absent */1;
return false;
} else {
return false;
}
} else {
return true;
}
};
var map = function (param) {
if (param.tag) {
return Pervasives.failwith("Unreachable");
} else {
return param[0];
}
};
return $$Array.of_list(List.map(map, List.filter(filter)($$Array.to_list(st[/* args */2]))));
}
exports.count = count;
exports.command = command;
exports.mem = mem;
exports.is_resolved = is_resolved;
exports.has_payload = has_payload;
exports.positionals = positionals;
exports.iter = iter;
exports.flag = flag;
exports.pp = pp;
exports.hydrate = hydrate;
exports.from_script = from_script;
exports.payload_to_opt = payload_to_opt;
exports.dehydrate = dehydrate;
/* AST Not a pure module */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.