imba
Version:
1,552 lines • 1.21 MB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
aliases: () => aliases,
compile: () => export_compile,
deserialize: () => export_deserialize,
fonts: () => fonts,
helpers: () => export_helpers,
modifiers: () => modifiers,
parse: () => export_parse,
parseAsset: () => parseAsset,
parser: () => export_parser,
program: () => program,
resolve: () => export_resolve,
resolveConfig: () => export_resolveConfig,
rewrite: () => export_rewrite,
selparser: () => selparser,
tokenize: () => export_tokenize,
variants: () => variants
});
module.exports = __toCommonJS(stdin_exports);
var __create = Object.create;
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined")
return require.apply(this, arguments);
throw new Error('Dynamic require of "' + x + '" is not supported');
});
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require2() {
return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
var __copyProps2 = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps2(
isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var require_token = __commonJS({
"src/compiler/token.imba1"(exports) {
var self = {};
var TOK = exports.TOK = {};
var TTERMINATOR = TOK.TERMINATOR = 1;
var TIDENTIFIER = TOK.IDENTIFIER = TOK.IVAR = 2;
var CONST = TOK.CONST = 3;
var VAR = TOK.VAR = 4;
var IF = TOK.IF = 5;
var ELSE = TOK.ELSE = 6;
var DEF = TOK.DEF = 7;
function Token2(type, value, loc, len) {
this._type = type;
this._value = value;
this._loc = loc != null ? loc : -1;
this._len = len != null ? len : this._value.length;
this._meta = null;
this.generated = false;
this.newLine = false;
this.spaced = false;
this.call = false;
return this;
}
exports.Token = Token2;
Token2.prototype.type = function() {
return this._type;
};
Token2.prototype.value = function() {
return this._value;
};
Token2.prototype.traverse = function() {
return;
};
Token2.prototype.c = function() {
return "" + this._value;
};
Token2.prototype.prepend = function(str) {
this._value = str + this._value;
return this;
};
Token2.prototype.toString = function() {
return this._value;
};
Token2.prototype.charAt = function(i) {
return this._value.charAt(i);
};
Token2.prototype.slice = function(i) {
return this._value.slice(i);
};
Token2.prototype.cloneSlice = function(i, type) {
return new Token2(type || this._type, this.slice(i), this._loc + i, this._len - i);
};
Token2.prototype.region = function() {
return [this._loc, this._loc + this._len];
};
Token2.prototype.startLoc = function() {
return this._loc;
};
Token2.prototype.endLoc = function() {
return this._loc + this._len;
};
Token2.prototype.loc = function() {
return [this._loc, this.endLoc()];
};
exports.lex = self.lex = function() {
var token = this.tokens[this.pos++];
var ttag;
if (token) {
ttag = token._type;
this.yytext = token;
} else {
ttag = "";
}
;
return ttag;
};
exports.token = self.token = function(typ, val) {
return new Token2(typ, val, -1, 0);
};
exports.typ = self.typ = function(tok) {
return tok._type;
};
exports.val = self.val = function(tok) {
return tok._value;
};
exports.line = self.line = function(tok) {
return tok._line;
};
exports.loc = self.loc = function(tok) {
return tok._loc;
};
exports.setTyp = self.setTyp = function(tok, v) {
return tok._type = v;
};
exports.setVal = self.setVal = function(tok, v) {
return tok._value = v;
};
exports.setLine = self.setLine = function(tok, v) {
return tok._line = v;
};
exports.setLoc = self.setLoc = function(tok, v) {
return tok._loc = v;
};
var LBRACKET = exports.LBRACKET = new Token2("{", "{", 0, 0, 0);
var RBRACKET = exports.RBRACKET = new Token2("}", "}", 0, 0, 0);
var LPAREN = exports.LPAREN = new Token2("(", "(", 0, 0, 0);
var RPAREN = exports.RPAREN = new Token2(")", ")", 0, 0, 0);
LBRACKET.generated = true;
RBRACKET.generated = true;
LPAREN.generated = true;
RPAREN.generated = true;
var INDENT = exports.INDENT = new Token2("INDENT", "2", 0, 0, 0);
var OUTDENT = exports.OUTDENT = new Token2("OUTDENT", "2", 0, 0, 0);
}
});
var fnv1a_exports = {};
__export2(fnv1a_exports, {
fnv1a: () => fnv1a
});
function fnv1a(string2, { size = 32 } = {}) {
if (!FNV_PRIMES[size]) {
throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");
}
let hash = FNV_OFFSETS[size];
const fnvPrime = FNV_PRIMES[size];
let isUnicoded = false;
for (let index = 0; index < string2.length; index++) {
let characterCode = string2.charCodeAt(index);
if (characterCode > 127 && !isUnicoded) {
string2 = unescape(encodeURIComponent(string2));
characterCode = string2.charCodeAt(index);
isUnicoded = true;
}
hash ^= BigInt(characterCode);
hash = BigInt.asUintN(size, hash * fnvPrime);
}
return hash;
}
var FNV_PRIMES, FNV_OFFSETS;
var init_fnv1a = __esm({
"vendor/fnv1a.js"() {
FNV_PRIMES = {
32: 16777619n,
64: 1099511628211n,
128: 309485009821345068724781371n,
256: 374144419156711147060143317175368453031918731002211n,
512: 35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,
1024: 5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n
};
FNV_OFFSETS = {
32: 2166136261n,
64: 14695981039346656037n,
128: 144066263297769815596495629667062367629n,
256: 100029257958052580907070968620625704837092796014241193945225284501741471925557n,
512: 9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,
1024: 14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n
};
}
});
var identifiers_exports = {};
__export2(identifiers_exports, {
InternalPrefixes: () => InternalPrefixes,
ReservedIdentifierRegex: () => ReservedIdentifierRegex,
ReservedPrefixes: () => ReservedPrefixes,
ToImbaMap: () => ToImbaMap,
ToJSMap: () => ToJSMap,
toCustomTagIdentifier: () => toCustomTagIdentifier,
toImbaIdentifier: () => toImbaIdentifier,
toJSIdentifier: () => toJSIdentifier
});
function toJSIdentifier(raw) {
return raw.replace(toJSregex, toJSreplacer);
}
function toImbaIdentifier(raw) {
return raw.replace(toImbaRegex, toImbaReplacer);
}
function toCustomTagIdentifier(str) {
return "\u0393" + toJSIdentifier(str);
}
var InternalPrefixes, ReservedPrefixes, ReservedIdentifierRegex, ToJSMap, toJSregex, toJSreplacer, ToImbaMap, toImbaRegex, toImbaReplacer;
var init_identifiers = __esm({
"src/utils/identifiers.imba"() {
InternalPrefixes = {
TAG: "\u03C4",
FLIP: "\u03C9",
VALUE: "\u03C5",
CACHE: "\u03F2",
KEY: "\u03BA",
ANY: "\u03C6",
SYM: "\u03B5",
SEP: "\u03B9",
PRIVATE: "\u03A8",
B: "\u03B9",
T: "\u03C4",
C: "\u03C1",
V: "\u03C5",
K: "\u03BA",
D: "\u0394",
H: "\u03B8",
EXTEND: "\u03A9"
};
ReservedPrefixes = new Set(Object.values(InternalPrefixes));
ReservedIdentifierRegex = new RegExp("^[" + Array.from(ReservedPrefixes).join("") + "]", "u");
ToJSMap = {
"-": "\u039E",
"?": "\u03A6",
"#": "\u03A8",
"@": "\u03B1"
};
toJSregex = new RegExp("[-?#@]", "gu");
toJSreplacer = function(m) {
return ToJSMap[m];
};
ToImbaMap = {
"\u039E": "-",
"\u03A6": "?",
"\u03A8": "#",
"\u03B1": "@"
};
toImbaRegex = new RegExp("[\u039E\u03A6\u03A8\u03B1]", "gu");
toImbaReplacer = function(m) {
return ToImbaMap[m];
};
}
});
var require_helpers = __commonJS({
"src/compiler/helpers.imba1"(exports) {
function iter$(a) {
return a ? a.toArray ? a.toArray() : a : [];
}
var self = {};
var fnv1a2 = (init_fnv1a(), __toCommonJS2(fnv1a_exports)).fnv1a;
var ansiMap = {
reset: [0, 0],
bold: [1, 22],
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29],
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
gray: [90, 39],
redBright: [91, 39],
greenBright: [92, 39],
yellowBright: [93, 39],
blueBright: [94, 39],
magentaBright: [95, 39],
cyanBright: [96, 39],
whiteBright: [97, 39]
};
var ansi = exports.ansi = {
bold: function(text) {
return "\x1B[1m" + text + "\x1B[22m";
},
red: function(text) {
return "\x1B[31m" + text + "\x1B[39m";
},
green: function(text) {
return "\x1B[32m" + text + "\x1B[39m";
},
yellow: function(text) {
return "\x1B[33m" + text + "\x1B[39m";
},
blue: function(text) {
return "\x1B[94m" + text + "\x1B[39m";
},
gray: function(text) {
return "\x1B[90m" + text + "\x1B[39m";
},
white: function(text) {
return "\x1B[37m" + text + "\x1B[39m";
},
f: function(name, text) {
let pair = ansiMap[name];
return "\x1B[" + pair[0] + "m" + text + "\x1B[" + pair[1] + "m";
}
};
ansi.warn = ansi.yellow;
ansi.error = ansi.red;
var imba$ = (init_identifiers(), __toCommonJS2(identifiers_exports));
var toImbaIdentifier2 = imba$.toImbaIdentifier;
var toJSIdentifier2 = imba$.toJSIdentifier;
var GreekLetters = "\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C3\u03C4\u03C5\u03C6\u03C7\u03C8\u03C9";
exports.brace = self.brace = function(str) {
var lines = str.match(/\n/);
if (lines) {
return "{" + str + "\n}";
} else {
return "{\n" + str + "\n}";
}
;
};
exports.normalizeIndentation = self.normalizeIndentation = function(str) {
var m;
var reg = /\n+([^\n\S]*)/g;
var ind = null;
var length_;
while (m = reg.exec(str)) {
var attempt = m[1];
if (ind === null || 0 < (length_ = attempt.length) && length_ < ind.length) {
ind = attempt;
}
;
}
;
if (ind) {
str = str.replace(RegExp("\\n" + ind, "g"), "\n");
}
;
return str;
};
exports.flatten = self.flatten = function(arr) {
var out = [];
arr.forEach(function(v) {
return v instanceof Array ? out.push.apply(out, self.flatten(v)) : out.push(v);
});
return out;
};
exports.clearLocationMarkers = self.clearLocationMarkers = function(str) {
return str.replace(/\/\*\%([\w\|]*)\$\*\//g, "");
};
exports.pascalCase = self.pascalCase = function(str) {
return str.replace(/(^|[\-\_\s])(\w)/g, function(m, v, l) {
return l.toUpperCase();
});
};
exports.camelCase = self.camelCase = function(str) {
str = String(str);
return str.replace(/([\-\_\s])(\w)/g, function(m, v, l) {
return l.toUpperCase();
});
};
exports.dashToCamelCase = self.dashToCamelCase = function(str) {
str = String(str);
if (str.indexOf("-") >= 0) {
str = str.replace(/([\-\s])(\w)/g, function(m, v, l) {
return l.toUpperCase();
});
}
;
return str;
};
exports.snakeCase = self.snakeCase = function(str) {
var str = str.replace(/([\-\s])(\w)/g, "_");
return str.replace(/()([A-Z])/g, "_$1", function(m, v, l) {
return l.toUpperCase();
});
};
exports.dasherize = self.dasherize = function(str) {
return str.replace(/([a-z\d])([A-Z])/g, "$1-$2").toLowerCase();
};
exports.setterSym = self.setterSym = function(sym) {
return self.dashToCamelCase("set-" + sym);
};
exports.quote = self.quote = function(str) {
return '"' + str + '"';
};
exports.singlequote = self.singlequote = function(str) {
return "'" + str + "'";
};
exports.isValidIdentifier = self.isValidIdentifier = function(str) {
return !/[?-\s]/.test(str) && str[0] != "#";
};
exports.toValidIdentifier = self.toValidIdentifier = function(str) {
return toJSIdentifier2(str);
return str.replace(/[-\?]/g, "$");
};
exports.fromValidIdentifier = self.fromValidIdentifier = function(str) {
return toImbaIdentifier2(str);
return str[0] + str.slice(1).replace(/\$$/, "?").replace(/\$/g, "-");
};
exports.isSystemIdentifier = self.isSystemIdentifier = function(str) {
return GreekLetters.indexOf(str[0]) >= 0;
};
exports.symbolize = self.symbolize = function(str, stack) {
str = String(str);
return self.toValidIdentifier(str);
if (stack && stack.tsc() || true) {
return str;
}
;
var end = str.charAt(str.length - 1);
if (end == "?") {
str = "is" + str[0].toUpperCase() + str.slice(1, -1);
}
;
if (str.indexOf("-") >= 0) {
str = str.replace(/([\-\s])(\w)/g, function(m, v, l) {
return l.toUpperCase();
});
}
;
return str;
};
exports.indent = self.indent = function(str) {
return String(str).replace(/^/g, " ").replace(/\n/g, "\n ").replace(/\n\t$/g, "\n");
};
exports.bracketize = self.bracketize = function(str, ind) {
if (ind === void 0)
ind = true;
if (ind) {
str = "\n" + self.indent(str) + "\n";
}
;
return "{" + str + "}";
};
exports.parenthesize = self.parenthesize = function(str) {
return "(" + String(str) + ")";
};
exports.unionOfLocations = self.unionOfLocations = function() {
var $0 = arguments, i = $0.length;
var locs = new Array(i > 0 ? i : 0);
while (i > 0)
locs[i - 1] = $0[--i];
var a = Infinity;
var b = -Infinity;
for (let i2 = 0, items = iter$(locs), len = items.length, loc; i2 < len; i2++) {
loc = items[i2];
if (loc && loc._loc != void 0) {
loc = loc._loc;
}
;
if (loc && loc.loc instanceof Function) {
loc = loc.loc();
}
;
if (loc instanceof Array) {
if (a > loc[0]) {
a = loc[0];
}
;
if (b < loc[0]) {
b = loc[1];
}
;
} else if (typeof loc == "number" || loc instanceof Number) {
if (a > loc) {
a = loc;
}
;
if (b < loc) {
b = loc;
}
;
}
;
}
;
return [a, b];
};
exports.locationToLineColMap = self.locationToLineColMap = function(code) {
var lines = code.split(/\n/g);
var map = [];
var chr;
var loc = 0;
var col = 0;
var line = 0;
while (chr = code[loc]) {
map[loc] = [line, col];
if (chr == "\n") {
line++;
col = 0;
} else {
col++;
}
;
loc++;
}
;
map[loc] = [line, col];
map[loc + 1] = [line, col];
return map;
};
exports.markLineColForTokens = self.markLineColForTokens = function(tokens, code) {
return self;
};
exports.parseArgs = self.parseArgs = function(argv, o) {
var env_;
if (o === void 0)
o = {};
var aliases2 = o.alias || (o.alias = {});
var groups = o.group || (o.group = []);
var schema = o.schema || {};
schema.main = {};
var options = {};
var explicit = {};
argv = argv || process.argv.slice(2);
var curr = null;
var i = 0;
var m;
while (i < argv.length) {
var arg = argv[i];
i++;
if (m = arg.match(/^\-([a-zA-Z]+)(\=\S+)?$/)) {
curr = null;
let chars = m[1].split("");
for (let i2 = 0, items = iter$(chars), len = items.length, item; i2 < len; i2++) {
item = items[i2];
var key = aliases2[item] || item;
chars[i2] = key;
options[key] = true;
}
;
if (chars.length == 1) {
curr = chars;
}
;
continue;
} else if (m = arg.match(/^\-\-([a-z0-9\-\_A-Z]+)(\=\S+)?$/)) {
var val = true;
key = m[1];
if (key.indexOf("no-") == 0) {
key = key.substr(3);
val = false;
}
;
key = self.dashToCamelCase(key);
if (m[2]) {
val = m[2].slice(1);
}
;
options[key] = val;
curr = key;
continue;
} else {
var desc = schema[curr];
if (!(curr && schema[curr])) {
curr = "main";
}
;
if (arg.match(/^\d+$/)) {
arg = parseInt(arg);
}
;
val = options[curr];
if (val == true || val == false) {
options[curr] = arg;
} else if (typeof val == "string" || val instanceof String || (typeof val == "number" || val instanceof Number)) {
options[curr] = [val].concat(arg);
} else if (val instanceof Array) {
val.push(arg);
} else {
options[curr] = arg;
}
;
if (!(desc && desc.multi)) {
curr = "main";
}
;
}
;
}
;
for (let j = 0, items = iter$(groups), len = items.length; j < len; j++) {
let name = self.dashToCamelCase(items[j]);
for (let v, i_ = 0, keys = Object.keys(options), l = keys.length, k; i_ < l; i_++) {
k = keys[i_];
v = options[k];
if (k.indexOf(name) == 0) {
let key2 = k.substr(name.length).replace(/^\w/, function(m2) {
return m2.toLowerCase();
});
if (key2) {
options[name] || (options[name] = {});
options[name][key2] = v;
} else {
options[name] || (options[name] = {});
}
;
}
;
}
;
}
;
if (typeof (env_ = options.env) == "string" || env_ instanceof String) {
options["ENV_" + options.env] = true;
}
;
return options;
};
exports.printExcerpt = self.printExcerpt = function(code, loc, pars) {
if (!pars || pars.constructor !== Object)
pars = {};
var hl = pars.hl !== void 0 ? pars.hl : false;
var gutter = pars.gutter !== void 0 ? pars.gutter : true;
var type = pars.type !== void 0 ? pars.type : "warn";
var pad = pars.pad !== void 0 ? pars.pad : 2;
var lines = code.split(/\n/g);
var locmap = self.locationToLineColMap(code);
var lc = locmap[loc[0]] || [0, 0];
var ln = lc[0];
var col = lc[1];
var line = lines[ln];
var ln0 = Math.max(0, ln - pad);
var ln1 = Math.min(ln0 + pad + 1 + pad, lines.length);
let lni = ln - ln0;
var l = ln0;
var res1 = [];
while (l < ln1) {
res1.push(lines[l++]);
}
;
var out = res1;
if (gutter) {
out = out.map(function(line2, i) {
let prefix = "" + (ln0 + i + 1);
let str;
while (prefix.length < String(ln1).length) {
prefix = " " + prefix;
}
;
if (i == lni) {
str = " -> " + prefix + " | " + line2;
if (hl) {
str = ansi.f(hl, str);
}
;
} else {
str = " " + prefix + " | " + line2;
if (hl) {
str = ansi.f("gray", str);
}
;
}
;
return str;
});
}
;
let res = out.join("\n");
return res;
};
exports.printWarning = self.printWarning = function(code, warn) {
let msg = warn.message;
let excerpt = self.printExcerpt(code, warn.loc, { hl: "whiteBright", type: "warn", pad: 1 });
return msg + "\n" + excerpt;
};
exports.identifierForPath = self.identifierForPath = function(str) {
let hash = fnv1a2(str).toString(36);
if (hash[0].match(/\d/)) {
hash = "z" + hash;
}
;
return hash;
};
exports.isPlainObject = self.isPlainObject = function(val) {
return typeof val == "object" && Object.getPrototypeOf(val) == Object.prototype;
};
exports.deepAssign = self.deepAssign = function(base, assignment) {
for (let v, i = 0, keys = Object.keys(assignment), l = keys.length, k; i < l; i++) {
k = keys[i];
v = assignment[k];
let orig = base[k];
if (self.isPlainObject(orig) && self.isPlainObject(v)) {
self.deepAssign(orig, v);
} else {
base[k] = v;
}
;
}
;
return base;
};
}
});
var require_constants = __commonJS({
"src/compiler/constants.imba1"(exports) {
function iter$(a) {
return a ? a.toArray ? a.toArray() : a : [];
}
var BALANCED_PAIRS = exports.BALANCED_PAIRS = [
["(", ")"],
["[", "]"],
["{", "}"],
["{{", "}}"],
["INDENT", "OUTDENT"],
["CALL_START", "CALL_END"],
["PARAM_START", "PARAM_END"],
["INDEX_START", "INDEX_END"],
["TAG_START", "TAG_END"],
["STYLE_START", "STYLE_END"],
["BLOCK_PARAM_START", "BLOCK_PARAM_END"]
];
var BITWISE_OPERATORS = exports.BITWISE_OPERATORS = {
"|": true,
"&": true,
"!&": true,
"~": true,
"|=": true,
"&=": true,
"~=": true,
"^=": true,
"^": true,
"<<": true,
"<<=": true,
">>": true,
">>=": true
};
var ASSIGNMENT_OPERATORS = exports.ASSIGNMENT_OPERATORS = {
"=": true,
"=?": true,
"??=": true,
"||=": true,
"&&=": true,
"|=": true,
"|=?": true,
"&=": true,
"&=?": true,
"^=": true,
"^=?": true,
"~=": true,
"~=?": true
};
var INVERSES = exports.INVERSES = {};
for (let i = 0, len = BALANCED_PAIRS.length, pair; i < len; i++) {
pair = BALANCED_PAIRS[i];
left = pair[0];
rite = pair[1];
INVERSES[rite] = left;
INVERSES[left] = rite;
BALANCED_PAIRS[left] = rite;
}
var left;
var rite;
var ALL_KEYWORDS = exports.ALL_KEYWORDS = [
"true",
"false",
"null",
"this",
"delete",
"typeof",
"in",
"instanceof",
"throw",
"break",
"continue",
"debugger",
"if",
"else",
"switch",
"for",
"while",
"do",
"try",
"catch",
"finally",
"class",
"extends",
"super",
"return",
"undefined",
"then",
"unless",
"until",
"loop",
"of",
"by",
"when",
"def",
"tag",
"do",
"elif",
"begin",
"var",
"let",
"self",
"await",
"import",
"and",
"or",
"is",
"isnt",
"not",
"yes",
"no",
"isa",
"case",
"nil",
"require"
];
var TOK = exports.TOK = {
TERMINATOR: "TERMINATOR",
INDENT: "INDENT",
OUTDENT: "OUTDENT",
DEF_BODY: "DEF_BODY",
THEN: "THEN",
CATCH: "CATCH"
};
var OPERATOR_ALIASES = exports.OPERATOR_ALIASES = {
and: "&&",
or: "||",
is: "==",
isnt: "!=",
isa: "instanceof"
};
var HEREGEX_OMIT = exports.HEREGEX_OMIT = /\s+(?:#.*)?/g;
var HEREGEX = exports.HEREGEX = /^\/{3}([\s\S]+?)\/{3}([a-z]{0,8})(?!\w)/;
var TAG_GLOBAL_ATTRIBUTES = exports.TAG_GLOBAL_ATTRIBUTES = {
itemid: 1,
itemprop: 1,
itemref: 1,
itemscope: 1,
itemtype: 1,
enterkeyhint: 1,
autofocus: 1,
autocapitalize: 1,
autocomplete: 1,
accesskey: 1,
inputmode: 1,
spellcheck: 1,
translate: 1,
is: 1
};
var SYSVAR_PREFIX = exports.SYSVAR_PREFIX = {
TAG: "\u03C4",
FLIP: "\u03C9",
VALUE: "\u03C5",
CACHE: "\u03C1",
KEY: "\u03BA",
ANY: "\u03C6",
B: "\u0398",
T: "\u03C4",
C: "\u03C1",
V: "\u03C5",
K: "\u03BA",
D: "\u0394"
};
var TAG_TYPES = exports.TAG_TYPES = {
"": [-1, { id: 1, className: "class", slot: 1, part: 1, elementTiming: "elementtiming" }],
HTML: [-1, { title: 1, lang: 1, translate: 1, dir: 1, accessKey: "accesskey", draggable: 1, spellcheck: 1, autocapitalize: 1, inputMode: "inputmode", style: 1, tabIndex: "tabindex", enterKeyHint: "enterkeyhint" }],
HTMLAnchor: [1, { target: 1, download: 1, ping: 1, rel: 1, relList: "rel", hreflang: 1, type: 1, referrerPolicy: "referrerpolicy", coords: 1, charset: 1, name: 1, rev: 1, shape: 1, href: 1 }],
HTMLArea: [1, { alt: 1, coords: 1, download: 1, shape: 1, target: 1, ping: 1, rel: 1, relList: "rel", referrerPolicy: "referrerpolicy", href: 1 }],
HTMLMedia: [1, { src: 1, crossOrigin: "crossorigin", preload: 1, controlsList: "controlslist" }],
HTMLAudio: [4, {}],
HTMLBase: [1, { href: 1, target: 1 }],
HTMLQuote: [1, { cite: 1 }],
HTMLBody: [1, { text: 1, link: 1, vLink: "vlink", aLink: "alink", bgColor: "bgcolor", background: 1 }],
HTMLBR: [1, { clear: 1 }],
HTMLButton: [1, { formAction: "formaction", formEnctype: "formenctype", formMethod: "formmethod", formTarget: "formtarget", name: 1, type: 1, value: 1 }],
HTMLCanvas: [1, { width: 1, height: 1 }],
HTMLTableCaption: [1, { align: 1 }],
HTMLTableCol: [1, { span: 1, align: 1, ch: "char", chOff: "charoff", vAlign: "valign", width: 1 }],
HTMLData: [1, { value: 1 }],
HTMLDataList: [1, {}],
HTMLMod: [1, { cite: 1, dateTime: "datetime" }],
HTMLDetails: [1, {}],
HTMLDialog: [1, {}],
HTMLDiv: [1, { align: 1 }],
HTMLDList: [1, {}],
HTMLEmbed: [1, { src: 1, type: 1, width: 1, height: 1, align: 1, name: 1 }],
HTMLFieldSet: [1, { name: 1 }],
HTMLForm: [1, { acceptCharset: "accept-charset", action: 1, autocomplete: 1, enctype: 1, encoding: "enctype", method: 1, name: 1, target: 1 }],
HTMLHeading: [1, { align: 1 }],
HTMLHead: [1, {}],
HTMLHR: [1, { align: 1, color: 1, size: 1, width: 1 }],
HTMLHtml: [1, { version: 1 }],
HTMLIFrame: [1, { src: 1, srcdoc: 1, name: 1, sandbox: 1, width: 1, height: 1, referrerPolicy: "referrerpolicy", csp: 1, allow: 1, align: 1, scrolling: 1, frameBorder: "frameborder", longDesc: "longdesc", marginHeight: "marginheight", marginWidth: "marginwidth", loading: 1 }],
HTMLImage: [1, { alt: 1, src: 1, srcset: 1, sizes: 1, crossOrigin: "crossorigin", useMap: "usemap", width: 1, height: 1, referrerPolicy: "referrerpolicy", decoding: 1, name: 1, lowsrc: 1, align: 1, hspace: 1, vspace: 1, longDesc: "longdesc", border: 1, loading: 1 }],
HTMLInput: [1, { accept: 1, alt: 1, autocomplete: 1, dirName: "dirname", formAction: "formaction", formEnctype: "formenctype", formMethod: "formmethod", formTarget: "formtarget", height: 1, max: 1, maxLength: "maxlength", min: 1, minLength: "minlength", name: 1, pattern: 1, placeholder: 1, src: 1, step: 1, type: 1, defaultValue: "value", width: 1, align: 1, useMap: "usemap" }],
HTMLLabel: [1, { htmlFor: "for" }],
HTMLLegend: [1, { align: 1 }],
HTMLLI: [1, { value: 1, type: 1 }],
HTMLLink: [1, { href: 1, crossOrigin: "crossorigin", rel: 1, relList: "rel", media: 1, hreflang: 1, type: 1, as: 1, referrerPolicy: "referrerpolicy", sizes: 1, imageSrcset: "imagesrcset", imageSizes: "imagesizes", charset: 1, rev: 1, target: 1, integrity: 1 }],
HTMLMap: [1, { name: 1 }],
HTMLMenu: [1, {}],
HTMLMeta: [1, { name: 1, httpEquiv: "http-equiv", content: 1, scheme: 1 }],
HTMLMeter: [1, { value: 1, min: 1, max: 1, low: 1, high: 1, optimum: 1 }],
HTMLObject: [1, { data: 1, type: 1, name: 1, useMap: "usemap", width: 1, height: 1, align: 1, archive: 1, code: 1, hspace: 1, standby: 1, vspace: 1, codeBase: "codebase", codeType: "codetype", border: 1 }],
HTMLOList: [1, { start: 1, type: 1 }],
HTMLOptGroup: [1, { label: 1 }],
HTMLOption: [1, { label: 1, value: 1 }],
HTMLOutput: [1, { htmlFor: "for", name: 1 }],
HTMLParagraph: [1, { align: 1 }],
HTMLParam: [1, { name: 1, value: 1, type: 1, valueType: "valuetype" }],
HTMLPicture: [1, {}],
HTMLPre: [1, { width: 1 }],
HTMLProgress: [1, { value: 1, max: 1 }],
HTMLScript: [1, { src: 1, type: 1, charset: 1, crossOrigin: "crossorigin", referrerPolicy: "referrerpolicy", event: 1, htmlFor: "for", integrity: 1 }],
HTMLSelect: [1, { autocomplete: 1, name: 1, size: 1 }],
HTMLSlot: [1, { name: 1 }],
HTMLSource: [1, { src: 1, type: 1, srcset: 1, sizes: 1, media: 1 }],
HTMLSpan: [1, {}],
HTMLStyle: [1, { media: 1, type: 1 }],
HTMLTable: [1, { align: 1, border: 1, frame: 1, rules: 1, summary: 1, width: 1, bgColor: "bgcolor", cellPadding: "cellpadding", cellSpacing: "cellspacing" }],
HTMLTableSection: [1, { align: 1, ch: "char", chOff: "charoff", vAlign: "valign" }],
HTMLTableCell: [1, { colSpan: "colspan", rowSpan: "rowspan", headers: 1, align: 1, axis: 1, height: 1, width: 1, ch: "char", chOff: "charoff", vAlign: "valign", bgColor: "bgcolor", abbr: 1, scope: 1 }],
HTMLTemplate: [1, {}],
HTMLTextArea: [1, { autocomplete: 1, cols: 1, dirName: "dirname", maxLength: "maxlength", minLength: "minlength", name: 1, placeholder: 1, rows: 1, wrap: 1 }],
HTMLTime: [1, { dateTime: "datetime" }],
HTMLTitle: [1, {}],
HTMLTableRow: [1, { align: 1, ch: "char", chOff: "charoff", vAlign: "valign", bgColor: "bgcolor" }],
HTMLTrack: [1, { kind: 1, src: 1, srclang: 1, label: 1 }],
HTMLUList: [1, { type: 1 }],
HTMLVideo: [4, { width: 1, height: 1, poster: 1 }],
SVG: [-1, {}],
SVGGraphics: [66, { transform: 1 }],
SVGA: [67, {}],
SVGAnimation: [66, {}],
SVGAnimate: [69, {}],
SVGAnimateMotion: [69, {}],
SVGAnimateTransform: [69, {}],
SVGGeometry: [67, {}],
SVGCircle: [73, { cx: 1, cy: 1, r: 1 }],
SVGClipPath: [67, { clipPathUnits: 1 }],
SVGDefs: [67, {}],
SVGDesc: [66, {}],
SVGDiscard: [66, {}],
SVGEllipse: [73, { cx: 1, cy: 1, rx: 1, ry: 1 }],
SVGFEBlend: [66, { mode: 1, x: 1, y: 1, width: 1, height: 1 }],
SVGFEColorMatrix: [66, { type: 1, values: 1, x: 1, y: 1, width: 1, height: 1 }],
SVGFEComponentTransfer: [66, { x: 1, y: 1, width: 1, height: 1 }],
SVGFEComposite: [66, { operator: 1, x: 1, y: 1, width: 1, height: 1 }],
SVGFEConvolveMatrix: [66, { orderX: 1, orderY: 1, kernelMatrix: 1, divisor: 1, edgeMode: 1, x: 1, y: 1, width: 1, height: 1 }],
SVGFEDiffuseLighting: [66, { surfaceScale: 1, diffuseConstant: 1, x: 1, y: 1, width: 1, height: 1 }],
SVGFEDisplacementMap: [66, { xChannelSelector: 1, yChannelSelector: 1, x: 1, y: 1, width: 1, height: 1 }],
SVGFEDistantLight: [66, {}],
SVGFEDropShadow: [66, { dx: 1, dy: 1, stdDeviationX: 1, stdDeviationY: 1, x: 1, y: 1, width: 1, height: 1 }],
SVGFEFlood: [66, { x: 1, y: 1, width: 1, height: 1 }],
SVGComponentTransferFunction: [66, { type: 1, tableValues: 1, slope: 1, amplitude: 1, exponent: 1 }],
SVGFEFuncA: [90, {}],
SVGFEFuncB: [90, {}],
SVGFEFuncG: [90, {}],
SVGFEFuncR: [90, {}],
SVGFEGaussianBlur: [66, { x: 1, y: 1, width: 1, height: 1 }],
SVGFEImage: [66, { preserveAspectRatio: 1, x: 1, y: 1, width: 1, height: 1 }],
SVGFEMerge: [66, { x: 1, y: 1, width: 1, height: 1 }],
SVGFEMergeNode: [66, {}],
SVGFEMorphology: [66, { operator: 1, x: 1, y: 1, width: 1, height: 1 }],
SVGFEOffset: [66, { x: 1, y: 1, width: 1, height: 1 }],
SVGFEPointLight: [66, {}],
SVGFESpecularLighting: [66, { surfaceScale: 1, specularConstant: 1, specularExponent: 1, x: 1, y: 1, width: 1, height: 1 }],
SVGFESpotLight: [66, { specularExponent: 1 }],
SVGFETile: [66, { x: 1, y: 1, width: 1, height: 1 }],
SVGFETurbulence: [66, { numOctaves: 1, stitchTiles: 1, type: 1, x: 1, y: 1, width: 1, height: 1 }],
SVGFilter: [66, { filterUnits: 1, primitiveUnits: 1, x: 1, y: 1, width: 1, height: 1 }],
SVGForeignObject: [67, { x: 1, y: 1, width: 1, height: 1 }],
SVGG: [67, {}],
SVGImage: [67, { x: 1, y: 1, width: 1, height: 1, preserveAspectRatio: 1 }],
SVGLine: [73, { x1: 1, y1: 1, x2: 1, y2: 1 }],
SVGGradient: [66, { gradientUnits: 1, gradientTransform: 1, spreadMethod: 1 }],
SVGLinearGradient: [111, { x1: 1, y1: 1, x2: 1, y2: 1 }],
SVGMarker: [66, { refX: 1, refY: 1, markerUnits: 1, markerWidth: 1, markerHeight: 1, orientType: 1, orientAngle: 1, viewBox: 1, preserveAspectRatio: 1 }],
SVGMask: [66, { maskUnits: 1, maskContentUnits: 1, x: 1, y: 1, width: 1, height: 1 }],
SVGMetadata: [66, {}],
SVGMPath: [66, {}],
SVGPath: [73, {}],
SVGPattern: [66, { patternUnits: 1, patternContentUnits: 1, patternTransform: 1, x: 1, y: 1, width: 1, height: 1, viewBox: 1, preserveAspectRatio: 1 }],
SVGPolygon: [73, {}],
SVGPolyline: [73, {}],
SVGRadialGradient: [111, { cx: 1, cy: 1, r: 1, fx: 1, fy: 1, fr: 1 }],
SVGRect: [73, { x: 1, y: 1, width: 1, height: 1, rx: 1, ry: 1 }],
SVGScript: [66, {}],
SVGSet: [69, {}],
SVGStop: [66, {}],
SVGStyle: [66, {}],
SVGSVG: [67, { x: 1, y: 1, width: 1, height: 1, viewBox: 1, preserveAspectRatio: 1 }],
SVGSwitch: [67, {}],
SVGSymbol: [66, { viewBox: 1, preserveAspectRatio: 1 }],
SVGTextContent: [67, { textLength: 1, lengthAdjust: 1 }],
SVGTextPositioning: [130, { x: 1, y: 1, dx: 1, dy: 1, rotate: 1 }],
SVGText: [131, {}],
SVGTextPath: [130, { startOffset: 1, method: 1, spacing: 1 }],
SVGTitle: [66, {}],
SVGTSpan: [131, {}],
SVGUse: [67, { x: 1, y: 1, width: 1, height: 1 }],
SVGView: [66, { viewBox: 1, preserveAspectRatio: 1 }]
};
var TAG_NAMES2 = exports.TAG_NAMES = {
a: 2,
abbr: 1,
address: 1,
area: 3,
article: 1,
aside: 1,
audio: 5,
b: 1,
base: 6,
bdi: 1,
bdo: 1,
blockquote: 7,
body: 8,
br: 9,
button: 10,
canvas: 11,
caption: 12,
cite: 1,
code: 1,
col: 13,
colgroup: 13,
data: 14,
datalist: 15,
dd: 1,
del: 16,
details: 17,
dfn: 1,
dialog: 18,
div: 19,
dl: 20,
dt: 1,
em: 1,
embed: 21,
fieldset: 22,
figcaption: 1,
figure: 1,
footer: 1,
form: 23,
h1: 24,
h2: 24,
h3: 24,
h4: 24,
h5: 24,
h6: 24,
head: 25,
header: 1,
hgroup: 1,
hr: 26,
html: 27,
i: 1,
iframe: 28,
img: 29,
input: 30,
ins: 16,
kbd: 1,
label: 31,
legend: 32,
li: 33,
link: 34,
main: 1,
map: 35,
mark: 1,
menu: 36,
meta: 37,
meter: 38,
nav: 1,
noscript: 1,
object: 39,
ol: 40,
optgroup: 41,
option: 42,
output: 43,
p: 44,
param: 45,
picture: 46,
pre: 47,
progress: 48,
q: 7,
rp: 1,
rt: 1,
ruby: 1,
s: 1,
samp: 1,
script: 49,
section: 1,
select: 50,
slot: 51,
small: 1,
source: 52,
span: 53,
strike: 1,
strong: 1,
style: 54,
sub: 1,
summary: 1,
sup: 1,
table: 55,
tbody: 56,
td: 57,
template: 58,
textarea: 59,
tfoot: 56,
th: 57,
thead: 56,
time: 60,
title: 61,
tr: 62,
track: 63,
u: 1,
ul: 64,
"var": 1,
video: 65,
wbr: 1,
svg_a: 68,
svg_animate: 70,
svg_animateMotion: 71,
svg_animateTransform: 72,
svg_audio: 66,
svg_canvas: 66,
svg_circle: 74,
svg_clipPath: 75,
svg_defs: 76,
svg_desc: 77,
svg_discard: 78,
svg_ellipse: 79,
svg_feBlend: 80,
svg_feColorMatrix: 81,
svg_feComponentTransfer: 82,
svg_feComposite: 83,
svg_feConvolveMatrix: 84,
svg_feDiffuseLighting: 85,
svg_feDisplacementMap: 86,
svg_feDistantLight: 87,
svg_feDropShadow: 88,
svg_feFlood: 89,
svg_feFuncA: 91,
svg_feFuncB: 92,
svg_feFuncG: 93,
svg_feFuncR: 94,
svg_feGaussianBlur: 95,
svg_feImage: 96,
svg_feMerge: 97,
svg_feMergeNode: 98,
svg_feMorphology: 99,
svg_feOffset: 100,
svg_fePointLight: 101,
svg_feSpecularLighting: 102,
svg_feSpotLight: 103,
svg_feTile: 104,
svg_feTurbulence: 105,
svg_filter: 106,
svg_foreignObject: 107,
svg_g: 108,
svg_iframe: 66,
svg_image: 109,
svg_line: 110,
svg_linearGradient: 112,
svg_marker: 113,
svg_mask: 114,
svg_metadata: 115,
svg_mpath: 116,
svg_path: 117,
svg_pattern: 118,
svg_polygon: 119,
svg_polyline: 120,
svg_radialGradient: 121,
svg_rect: 122,
svg_script: 123,
svg_set: 124,
svg_stop: 125,
svg_style: 126,
svg_svg: 127,
svg_switch: 128,
svg_symbol: 129,
svg_text: 132,
svg_textPath: 133,
svg_title: 134,
svg_tspan: 135,
svg_unknown: 66,
svg_use: 136,
svg_video: 66,
svg_view: 137
};
var keys = Object.keys(TAG_TYPES);
for (let i = 0, items = iter$(keys), len = items.length, typ; i < len; i++) {
typ = items[i];
let item = TAG_TYPES[typ];
item.up = TAG_TYPES[keys[item[0]]];
item.name = typ + "Element";
}
for (let ref, i = 0, keys1 = Object.keys(TAG_NAMES2), l = keys1.length, name; i < l; i++) {
name = keys1[i];
ref = TAG_NAMES2[name];
TAG_NAMES2[name] = TAG_TYPES[keys[ref]];
}
}
});
var \u03A8__init__, \u03A8source, \u03A8lineText, \u03A8version, DOCMAP, Position, Range, DiagnosticSeverity, Diagnostic;
var init_structures = __esm({
"src/program/structures.imba"() {
\u03A8__init__ = /* @__PURE__ */ Symbol.for("#__init__");
\u03A8source = /* @__PURE__ */ Symbol.for("#source");
\u03A8lineText = /* @__PURE__ */ Symbol.for("#lineText");
\u03A8version = /* @__PURE__ */ Symbol.for("#version");
DOCMAP = /* @__PURE__ */ new WeakMap();
Position = class {
[\u03A8__init__]($$ = null) {
this.line = $$ ? $$.line : void 0;
this.character = $$ ? $$.character : void 0;
this.offset = $$ ? $$.offset : void 0;
}
constructor(l, c, o, v = null) {
this[\u03A8__init__]();
this.line = l;
this.character = c;
this.offset = o;
this[\u03A8version] = v;
}
toString() {
return "" + this.line + ":" + this.character;
}
valueOf() {
return this.offset;
}
};
Range = class {
[\u03A8__init__]($$ = null) {
this.start = $$ ? $$.start : void 0;
this.end = $$ ? $$.end : void 0;
}
constructor(start, end) {
this[\u03A8__init__]();
this.start = start;
this.end = end;
}
get offset() {
return this.start.offset;
}
get length() {
return this.end.offset - this.start.offset;
}
get ["0"]() {
return this.start.offset;
}
get ["1"]() {
return this.end.offset;
}
getText(str) {
return str.slice(this.start, this.end);
}
equals(other) {
return other.offset == this.offset && other.length == this.length;
}
};
DiagnosticSeverity = {
Error: 1,
Warning: 2,
Information: 3,
Hint: 4,
error: 1,
warning: 2,
warn: 2,
info: 3,
hint: 4
};
Diagnostic = class {
constructor(data, doc = null) {
this.range = data.range;
this.severity = DiagnosticSeverity[data.severity] || data.severity;
this.code = data.code;
this.source = data.source;
this.message = data.message;
DOCMAP.set(this, doc);
}
get [\u03A8source]() {
return DOCMAP.get(this);
}
get [\u03A8lineText]() {
return this[\u03A8source].doc.getLineText(this.range.start.line);
}
toSnippet() {
let start = this.range.start;
let end = this.range.end;
let msg = "" + this[\u03A8source].sourcePath + ":" + (start.line + 1) + ":" + (start.character + 1) + ": " + this.message;
let line = this[\u03A8source].doc.getLineText(start.line);
let stack = [msg, line];
stack.push(line.replace(/[^\t]/g, " ").slice(0, start.character) + "^".repeat(end.character - start.character));
return stack.join("\n").replace(/\t/g, " ") + "\n";
}
toError() {
let start = this.range.start;
let end = this.range.end;
let msg = "" + this[\u03A8source].sourcePath + ":" + (start.line + 1) + ":" + (start.character + 1) + ": " + this.message;
let err = new SyntaxError(msg);
let line = this[\u03A8source].doc.getLineText(start.line);
let stack = [msg, line];
stack.push(line.replace(/[^\t]/g, " ").slice(0, start.character) + "^".repeat(end.character - start.character));
err.stack = "\n" + stack.join("\n").replace(/\t/g, " ") + "\n";
return err;
}
raise() {
throw this.toError();
}
};
}
});
function iter$__(a) {
let v;
return a ? (v = a.toIterable) ? v.call(a) : a : [];
}
function prevToken(start, pattern, max = 1e5) {
let tok = start;
while (tok && max > 0) {
if (tok.match(pattern)) {
return tok;
}
;
max--;
tok = tok.prev;
}
;
return null;
}
function computeLineOffsets(text, isAtLineStart, textOffset) {
if (textOffset === void 0) {
textOffset = 0;
}
;
var result = isAtLineStart ? [textOffset] : [];
var i = 0;
while (i < text.length) {
var ch = text.charCodeAt(i);
if (ch === 13 || ch === 10) {
if (ch === 13 && i + 1 < text.length && text.charCodeAt(i + 1) === 10) {
i++;
}
;
result.push(textOffset + i + 1);
}
;
i++;
}
;
return result;
}
function getWellformedRange(range) {
var start = range.start;
var end = range.end;
if (start.line > end.line || start.line === end.line && start.character > end.character) {
return new Range(end, start);
}
;
return range instanceof Range ? range : new Range(start, end);
}
function editIsFull(e) {
return e !== void 0 && e !== null && typeof e.text === "string" && e.range === void 0;
}
function fastExtractSymbols(text) {
let lines = text.split(/\n/);
let symbols = [];
let scope = { indent: -1, children: [] };
let root = scope;
let m;
let t0 = Date.now();
for (let i = 0, items\u03C62 = iter$__(lines), len\u03C62 = items\u03C62.length; i < len\u03C62; i++) {
let line = items\u03C62[i];
if (line.match(/^\s*$/)) {
continue;
}
;
let indent = line.match(/^\t*/)[0].length;
while (scope.indent >= indent) {
scope = scope.parent || root;
}
;
m = line.match(/^(\t*((?:export )?(?:static )?(?:extend )?)(class|tag|def|get|set|prop|attr) )(\@?[\w\-\$\:]+(?:\.[\w\-\$]+)?)/);
if (m) {
let kind = m[3];
let name = m[4];
let ns = scope.name ? scope.name + "." : "";
let mods = m[2].trim().split(/\s+/);
let md = "";
let span = {
start: { line: i, character: m[1].length },
end: { line: i, character: m[0].length }
};
let symbol = {
kind,
ownName: name,
name: ns + name,
span,
indent,
modifiers: mods,
children: [],
parent: scope == root ? null : scope,
type: kind,
data: {},
static: mods.indexOf("static") >= 0,
extends: mods.indexOf("extend") >= 0
};
if (symbol.static) {
symbol.containerName = "static";
}
;
symbol.containerName = m[2] + m[3];
if (kind == "tag" && (m = line.match(/\<\s+([\w\-\$\:]+(?:\.[\w\-\$]+)?)/))) {
symbol.superclass = m[1];
}
;
if (scope.type == "tag") {
md = "```html\n<" + scope.name + " " + name + ">\n```\n";
symbol.description = { kind: "markdown", value: md };
}
;
scope.children.push(symbol);
scope = symbol;
symbols.push(symbol);
}
;
}
;
root.all = symbols;
console.log("fast outline", text.length, Date.now() - t0);
return root;
}
var init_utils = __esm({
"src/program/utils.imba"() {
init_structures();
}
});
function iter$__2(a) {
let v;
return a ? (v = a.toIterable) ? v.call(a) : a : [];
}
function regexify(array, pattern = "#") {
if (typeof array == "string") {
array = array.split(" ");
}
;
let items = array.slice().sort(function(_0, _1) {
return _1.length - _0.length;
});
items = items.map(function(item) {
let escaped = item.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
return pattern.replace("#", escaped);
});
return new RegExp("(?:" + items.join("|") + ")");
}
function denter(indent, outdent, stay, o = {}) {
var v$\u03C6;
if (indent == null) {
indent = toodeep;
} else if (indent == 1) {
indent = { next: "@>" };
} else if (indent == 2) {
indent = { next: "@>_indent&-_indent" };
} else if (typeof indent == "string") {
indent = { next: indent };
}
;
if (outdent == -1) {
outdent = repop;
}
;
if (stay == -1) {
stay = repop;
} else if (stay == 0) {
o.comment == null ? o.comment = true : o.comment;
stay = {};
}
;
indent = Object.assign({ token: "white.tabs" }, indent || {});
stay = Object.assign({ token: "white.tabs" }, stay || {});
outdent = Object.assign({ token: "@rematch", next: "@pop" }, outdent || {});
let cases = {
"$1==$S2 ": indent,
"$1==$S2": {
cases: { "$1==$S6": stay, "@default": { token: "@rematch", switchTo: "@*$1" } }
},
"@default": outdent
};
v$\u03C6 = 0;
for (let k of ["next", "switchTo"]) {
let v = v$\u03C6++;
if (indent[k] && indent[k].indexOf("*") == -1) {
indent[k] += "*$1";
}
;
}
;
let rule = [/^(\t*)(?=[^ \t\n])/, { cases }];
if (o.comment) {
let clones = {};
for (let i\u03C6 = 0, keys\u03C6 = Object.keys(cases), l\u03C6 = keys\u03C6.length, k, v; i\u03C6 < l\u03C6; i\u03C6++) {
k = keys\u03C6[i\u03C6];
v = cases[k];
let clone = Object.assign({}, v);
if (!clone.next && !clone.switchTo) {
clone.next = "@>_comment";
}
;
clones[k] = clone;