diff --git a/make_stage1.sh b/make_stage1.sh deleted file mode 100755 index f7d8dbc..0000000 --- a/make_stage1.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -xe - -node phi.js compile.phi compile.phi stage1.js diff --git a/make_stage2.sh b/make_stage2.sh deleted file mode 100755 index b57959c..0000000 --- a/make_stage2.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -xe - -node stage1.js compile.phi stage2.js diff --git a/phi.js b/phi.js deleted file mode 100644 index 1635f17..0000000 --- a/phi.js +++ /dev/null @@ -1,639 +0,0 @@ -"use strict"; - -import fs from "node:fs"; -import process from "node:process"; -import { Runtime } from "./runtime.js"; - -function main() { - const filename = process.argv[2]; - const text = fs.readFileSync(filename).toString(); - - const ast = new Parser(text).parse(); - - let lastValue = null; - - const evaluator = new Evaluator(filename); - for (const expr of ast) { - const result = evaluator.eval(expr); - if (result.type !== "value") { - break; - } - lastValue = result.value; - } - if (lastValue !== null) { - // console.log(Runtime.valueToJs(lastValue)); - } -} - -class Evaluator { - constructor(filename) { - this.syms = { parent: undefined, map: new Map(this.builtins) }; - this.currentLine = 0; - this.filename = filename; - this.runtime = new Runtime({ filename, args: process.argv.slice(3) }); - } - - /** - * @param {Expr} expr - */ - eval(expr) { - if (!expr) { - this.runtime.printPanic( - "expression could not be evaluated", - this.currentLine, - ); - throw new Error("expression could not be evaluated"); - } - - this.currentLine = expr.line; - this.runtime.setLine(expr.line); - if (expr.type === "list") { - return this.evalList(expr, expr.line); - } else if (expr.type === "int") { - return { type: "value", value: { type: "int", value: expr.value } }; - } else if (expr.type === "string") { - return { - type: "value", - value: { type: "string", value: expr.value }, - }; - } else if (expr.type === "ident") { - const sym = this.findSym(expr.value); - if (!sym) { - this.panic( - `undefined symbol '${expr.value}'`, - ); - } - if (sym.type === "local") { - return { type: "value", value: { ...sym.value } }; - } else { - return { type: "value", value: { ...sym } }; - } - } else { - throw new Error( - `unknown expr type '${expr.type}' on line ${expr.line}`, - ); - } - } - - evalToValue(expr) { - const result = this.eval(expr); - if (result.type !== "value") { - throw new Error(`expected value on line ${expr.line}`); - } - return result.value; - } - - evalList(expr) { - const s = expr.values; - const id = s[0]?.type === "ident" ? s[0].value : undefined; - if (id === "fn") { - return this.evalFn(expr); - } else if (id === "return") { - return { - type: "return", - value: s[1] ? this.evalToValue(s[1]) : { type: "null" }, - }; - } else if (id === "let") { - return this.evalLet(expr); - } else if (id === "if") { - return this.evalIf(expr); - } else if (id === "loop") { - return this.evalLoop(expr); - } else if (id === "for") { - return this.evalFor(expr); - } else if (id === "break") { - return { - type: "break", - value: s[1] ? this.evalToValue(s[1]) : { type: "null" }, - }; - } else if (id === "do") { - return this.evalDo(expr); - } else if (id === "call") { - return this.evalCall(expr); - } else if (id === "not") { - const value = this.evalToValue(s[1]); - return { - type: "value", - value: { type: "bool", value: !value.value }, - }; - } else if (id === "or") { - const left = this.evalToValue(s[1]); - if (this.runtime.truthy(left)) { - return { type: "value", value: { type: "bool", value: true } }; - } else { - const right = this.evalToValue(s[2]); - return { - type: "value", - value: { type: "bool", value: this.runtime.truthy(right) }, - }; - } - } else if (id === "and") { - const left = this.evalToValue(s[1]); - if (this.runtime.truthy(left)) { - const right = this.evalToValue(s[2]); - return { - type: "value", - value: { type: "bool", value: this.runtime.truthy(right) }, - }; - } else { - return { type: "value", value: { type: "bool", value: false } }; - } - } else if (id in this.artithmeticOps) { - const left = this.evalToValue(s[1]); - const right = this.evalToValue(s[2]); - return { - type: "value", - value: this.artithmeticOps[id](left, right), - }; - } else if (id === "==") { - const left = this.evalToValue(s[1]); - const right = this.evalToValue(s[2]); - return { - type: "value", - value: this.runtime.opEq(left, right), - }; - } else if (id === "!=") { - const left = this.evalToValue(s[1]); - const right = this.evalToValue(s[2]); - return { - type: "value", - value: this.runtime.opNe(left, right), - }; - } else if (id in this.comparisonOps) { - const left = this.evalToValue(s[1]); - const right = this.evalToValue(s[2]); - return { - type: "value", - value: this.runtime.comparisonOperation( - left, - right, - this.comparisonOps[id], - ), - }; - } else if (id in this.assignOps) { - return this.evalAssign(expr); - } else { - return { - type: "value", - value: { - type: "list", - values: s.map((expr) => this.evalToValue(expr)), - }, - }; - } - } - - evalFn(expr) { - const s = expr.values; - const name = s[1].value; - this.syms.map.set(name, { - type: "fn", - line: expr.line, - name, - params: s[2].values.map((ident) => ident.value), - body: s[3], - syms: this.syms, - }); - return { type: "value", value: { type: "null" } }; - } - - evalLet(expr) { - const s = expr.values; - const value = this.evalToValue(s[2]); - this.assignPattern(s[1], value); - return { type: "value", value: { type: "null" } }; - } - - evalIf(expr) { - const s = expr.values; - const cond = this.evalToValue(s[1]); - if (cond.type !== "bool") { - throw new Error( - `expected bool on line ${expr.line}`, - ); - } - if (cond.value) { - return this.eval(s[2]); - } else if (s[3]) { - return this.eval(s[3]); - } else { - return { type: "value", value: "null" }; - } - } - - evalLoop(expr) { - const s = expr.values; - while (true) { - const result = this.eval(s[1]); - if (result.type === "break") { - return { type: "value", value: result.value }; - } else if (result.type !== "value") { - return result; - } - } - } - - evalFor(expr) { - const s = expr.values; - - const value = this.evalToValue(s[2]); - if (value.type !== "list") { - throw new Error( - `expected list on line ${expr.line}`, - ); - } - - for (let i = 0; i < value.values.length; ++i) { - this.enterScope(); - this.assignPattern(s[1], value.values[i]); - this.enterScope(); - - const result = this.eval(s[3]); - - this.leaveScope(); - this.leaveScope(); - - if (result.type === "break") { - return { type: "value", value: result.value }; - } else if (result.type !== "value") { - return result; - } - } - return { type: "value", value: { type: "null" } }; - } - - evalDo(expr) { - const s = expr.values; - this.enterScope(); - - let lastValue = { type: "null" }; - - for (const expr of s.slice(1)) { - const result = this.eval(expr); - if (!result) { - console.log({ expr, result }); - } - if (result.type !== "value") { - return result; - } - lastValue = result.value; - } - - this.leaveScope(); - return { type: "value", value: lastValue }; - } - - evalCall(expr) { - const s = expr.values; - const args = s.slice(2).map((arg) => this.evalToValue(arg)); - const fnValue = this.evalToValue(s[1]); - - if (fnValue.type === "builtin") { - return { type: "value", value: fnValue.fn(...args) }; - } else if (fnValue.type !== "fn") { - throw new Error("cannot call non-function"); - } - - this.runtime.pushCall(fnValue.name, expr.line); - const callerSyms = this.syms; - this.syms = { - parent: fnValue.syms, - map: new Map(), - }; - if (fnValue.params.length !== args.length) { - this.panic( - `incorrect amount of arguments for function '${fnValue.name}'`, - ); - } - for (let i = 0; i < fnValue.params.length; ++i) { - this.syms.map.set(fnValue.params[i], args[i]); - } - - this.enterScope(); - let returnValue = { type: "null" }; - const result = this.eval(fnValue.body); - this.leaveScope(); - - if (result.type === "value" || result.type === "return") { - returnValue = result.value; - } else { - throw new Error(`illegal ${result.type} across boundry`); - } - - this.syms = callerSyms; - this.runtime.popCall(); - return { type: "value", value: returnValue }; - } - - evalAssign(expr) { - const s = expr.values; - const id = s[0].value; - if (s[1].type === "ident") { - const sym = this.findSym(s[1].value); - if (!sym) { - throw new Error( - `could not find symbol '${expr.value}' on line ${expr.line}`, - ); - } - const value = this.evalToValue(s[2]); - if (sym.type === "local") { - sym.value = this.assignOps[id](sym.value, value); - } else { - throw new Error( - `cannot assign to symbol on line ${expr.line}`, - ); - } - } else { - throw new Error( - `cannot assign to expression on line ${expr.line}`, - ); - } - return { type: "value", value: { type: "null" } }; - } - - /** @param {Expr} pattern */ - assignPattern(pattern, value) { - if (pattern.type === "ident") { - if (pattern.value === "_") { - return; - } - if (this.syms.map.has(pattern.value)) { - throw new Error( - `redeclaration of local symbol '${pattern.value}' on line ${pattern.line}`, - ); - } - this.syms.map.set(pattern.value, { - type: "local", - line: pattern.line, - value, - }); - } else if (pattern.type === "list") { - if (value.type !== "list") { - this.panic(`expected list on line ${pattern.line}`); - } - for (const [i, p] of pattern.values.entries()) { - this.assignPattern(p, value.values[i] ?? { type: "null" }); - } - } else { - throw new Error(`cannot assign to pattern on line ${pattern.line}`); - } - } - - findSym(ident, syms = this.syms) { - if (syms.map.has(ident)) { - return syms.map.get(ident); - } else if (syms.parent) { - return this.findSym(ident, syms.parent); - } else { - return undefined; - } - } - - panic(msg) { - this.runtime.setLine(this.currentLine); - this.runtime.panic(msg); - } - - enterScope() { - this.syms = { parent: this.syms, map: new Map() }; - } - - leaveScope() { - this.syms = this.syms.parent; - } - - artithmeticOps = { - "+": (left, right) => this.runtime.opAdd(left, right), - "-": (left, right) => this.runtime.opSub(left, right), - }; - comparisonOps = { - "<": (left, right) => left < right, - ">": (left, right) => left > right, - "<=": (left, right) => left <= right, - ">=": (left, right) => left >= right, - }; - assignOps = { - "=": (_, right) => right, - "+=": (left, right) => ({ - type: left.type === "string" && left.type === right.type - ? "string" - : "int", - value: left.value + right.value, - }), - "-=": (left, right) => ({ - type: "int", - value: left.value - right.value, - }), - }; - - builtinFns = { - "format": (...args) => this.runtime.builtinFormat(...args), - "print": (...args) => this.runtime.builtinPrint(...args), - "println": (...args) => this.runtime.builtinPrintln(...args), - "panic": (...args) => this.runtime.builtinPanic(...args), - "read_text_file": (...args) => - this.runtime.builtinReadTextFile(...args), - "write_text_file": (...args) => - this.runtime.builtinWriteTextFile(...args), - "push": (...args) => this.runtime.builtinPush(...args), - "at": (...args) => this.runtime.builtinAt(...args), - "set": (...args) => this.runtime.builtinSet(...args), - "len": (...args) => this.runtime.builtinLen(...args), - "string_to_int": (...args) => this.runtime.builtinStringToInt(...args), - "char_code": (...args) => this.runtime.builtinCharCode(...args), - "strings_join": (...args) => this.runtime.builtinStringsJoin(...args), - "get_args": (...args) => this.runtime.builtinGetArgs(...args), - }; - - consts = { - "null": { type: "null" }, - "false": { type: "bool", value: false }, - "true": { type: "bool", value: true }, - "is_phi_compiler": { type: "bool", value: false }, - }; - - builtins = [ - ...Object.entries(this.builtinFns) - .map(([key, fn]) => [key, { type: "builtin", fn }]), - ...Object.entries(this.consts), - ]; -} - -/** - * @param {Expr} expr - * @returns {string} - */ -function exprToString(expr) { - if (expr.type === "ident") { - return expr.value; - } else if (expr.type === "int") { - return `${expr.value}`; - } else if (expr.type === "string") { - return `"${expr.value}"`; - } else if (expr.type === "list") { - return `(${expr.values.map((v) => exprToString(v)).join(" ")})`; - } else { - throw new Error(`unknown value type ${expr.type}`); - } -} - -/** - * @typedef {{ type: string, line: number, value: any, values?: Expr } } Expr - */ - -class Parser { - constructor(text) { - const stringExtractor = new StringExtractor(text); - stringExtractor.extract(); - this.strings = stringExtractor.getStrings(); - this.text = stringExtractor.getOutputText(); - this.tokens = this.text - .replace(/\/\/.*?$/mg, "") - .replace(/([\(\)\n])/g, " $1 ") - .split(/[ \t\r]/) - .filter((tok) => tok !== ""); - this.idx = 0; - this.line = 1; - } - - /** - * @returns {Expr[]} - */ - parse() { - if (this.curr === "\n") { - this.step(); - } - - const exprs = []; - while (!this.done) { - exprs.push(this.parseExpr()); - } - return exprs; - } - - parseExpr() { - const line = this.line; - if (this.eat("(")) { - const values = []; - while (!this.test(")")) { - values.push(this.parseExpr()); - } - if (!this.test(")")) { - throw new Error(`expected ')'`); - } - this.step(); - return { type: "list", line, values }; - } else if (this.test(/STRING_\d+/)) { - const id = Number(this.curr.match(/STRING_(\d+)/)[1]); - this.step(); - return { type: "string", line, value: this.strings[id] }; - } else if (this.test(/0|(:?[1-9][0-9]*)/)) { - const value = Number(this.curr); - this.step(); - return { type: "int", line, value }; - } else if (this.test(/[a-zA-Z0-9\+\-\*/%&\|=\?\!<>'_]+/)) { - const value = this.curr; - this.step(); - return { type: "ident", line, value }; - } else { - throw new Error( - `expected expression, got ${this.curr} on line ${this.line}`, - ); - } - } - - eat(tok) { - if (!this.test(tok)) { - return false; - } - this.step(); - return true; - } - test(tok) { - if (this.done) { - return false; - } - if (typeof tok === "string") { - return this.curr === tok; - } else if (tok instanceof RegExp) { - return new RegExp(`^${tok.source}$`) - .test(this.curr); - } else { - throw new Error(); - } - } - step() { - do { - if (!this.done && this.curr === "\n") { - this.line += 1; - } - this.idx += 1; - } while (!this.done && this.curr === "\n"); - } - - get done() { - return this.idx >= this.tokens.length; - } - get curr() { - return this.tokens[this.idx]; - } -} - -class StringExtractor { - constructor(text) { - this.text = text; - this.idx = 0; - this.outputText = ""; - this.strings = []; - } - - extract() { - while (this.idx < this.text.length) { - if (this.text[this.idx] == '"') { - this.extractString(); - } else { - this.outputText += this.text[this.idx]; - this.idx += 1; - } - } - } - - extractString() { - this.idx += 1; - let value = ""; - while (this.idx < this.text.length && this.text[this.idx] != '"') { - if (this.text[this.idx] == "\\") { - this.idx += 1; - if (this.idx > this.text.length) { - break; - } - const ch = this.text[this.idx]; - value += { - "0": "\0", - "t": "\t", - "r": "\r", - "n": "\n", - }[ch] ?? ch; - } else { - value += this.text[this.idx]; - } - this.idx += 1; - } - if (this.idx >= this.text.length || this.text[this.idx] != '"') { - throw new Error("expected '\"'"); - } - this.idx += 1; - const id = this.strings.length; - this.strings.push(value); - this.outputText += `STRING_${id}`; - } - - getStrings() { - return this.strings; - } - getOutputText() { - return this.outputText; - } -} - -main(); diff --git a/stage1.js b/stage1.js deleted file mode 100644 index be32485..0000000 --- a/stage1.js +++ /dev/null @@ -1,1228 +0,0 @@ -#!/usr/bin/env node -import { Runtime } from "./runtime.js"; -const runtime = new Runtime({ filename: "compile.phi" }); -let _is_phi_compiler14 = { type: "bool", value: true }; -function _dbg15(_msg27) { -runtime.pushCall("dbg"); -if (runtime.truthy(_is_phi_compiler14)) { -(runtime.setLine(4), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "dbg: %" }), _msg27)); -}; -; -runtime.popCall(); -return { type: "null" }; -}; -function _Emitter16(_ast28, _filename29) { -runtime.pushCall("Emitter"); -const r_0 = ({ type: "list", values: [] }); -let _output44 = r_0; -const r_1 = (runtime.setLine(11), _Syms18()); -const r_2 = r_1.values[0] ?? { type: "null"}; -let _enter_scope45 = r_2; -const r_3 = r_1.values[1] ?? { type: "null"}; -let _leave_scope46 = r_3; -const r_4 = r_1.values[2] ?? { type: "null"}; -let _define_sym47 = r_4; -const r_5 = r_1.values[3] ?? { type: "null"}; -let _get_sym48 = r_5; -const r_6 = r_1.values[4] ?? { type: "null"}; -let _print_syms49 = r_6; -const r_7 = (runtime.setLine(13), _Counter17()); -const r_8 = r_7.values[0] ?? { type: "null"}; -let _let_node_reg_count50 = r_8; -const r_9 = r_7.values[1] ?? { type: "null"}; -let _let_node_reg_increment51 = r_9; -const r_10 = (runtime.setLine(14), _Counter17()); -const r_11 = r_10.values[0] ?? { type: "null"}; -let _sym_id_count52 = r_11; -const r_12 = r_10.values[1] ?? { type: "null"}; -let _sym_id_increment53 = r_12; -const r_13 = ({ type: "list", values: [({ type: "list", values: [({ type: "string", value: "format" }), ({ type: "string", value: "builtinFormat" })] }), ({ type: "list", values: [({ type: "string", value: "print" }), ({ type: "string", value: "builtinPrint" })] }), ({ type: "list", values: [({ type: "string", value: "println" }), ({ type: "string", value: "builtinPrintln" })] }), ({ type: "list", values: [({ type: "string", value: "panic" }), ({ type: "string", value: "builtinPanic" })] }), ({ type: "list", values: [({ type: "string", value: "read_text_file" }), ({ type: "string", value: "builtinReadTextFile" })] }), ({ type: "list", values: [({ type: "string", value: "write_text_file" }), ({ type: "string", value: "builtinWriteTextFile" })] }), ({ type: "list", values: [({ type: "string", value: "push" }), ({ type: "string", value: "builtinPush" })] }), ({ type: "list", values: [({ type: "string", value: "at" }), ({ type: "string", value: "builtinAt" })] }), ({ type: "list", values: [({ type: "string", value: "set" }), ({ type: "string", value: "builtinSet" })] }), ({ type: "list", values: [({ type: "string", value: "len" }), ({ type: "string", value: "builtinLen" })] }), ({ type: "list", values: [({ type: "string", value: "string_to_int" }), ({ type: "string", value: "builtinStringToInt" })] }), ({ type: "list", values: [({ type: "string", value: "char_code" }), ({ type: "string", value: "builtinCharCode" })] }), ({ type: "list", values: [({ type: "string", value: "strings_join" }), ({ type: "string", value: "builtinStringsJoin" })] }), ({ type: "list", values: [({ type: "string", value: "get_args" }), ({ type: "string", value: "builtinGetArgs" })] })] }); -let _builtin_syms54 = r_13; -function _generate30() { -runtime.pushCall("generate"); -(runtime.setLine(34), _emit39(({ type: "string", value: "#!/usr/bin/env node\n" }))); -(runtime.setLine(35), _emit39(({ type: "string", value: "import { Runtime } from \"./runtime.js\";\n" }))); -(runtime.setLine(36), _emit39(({ type: "string", value: "const runtime = new Runtime({ filename: \"" }))); -(runtime.setLine(37), _emit39(_filename29)); -(runtime.setLine(38), _emit39(({ type: "string", value: "\" });\n" }))); -for (const r_14 of _builtin_syms54.values) {; -const r_15 = r_14.values[0] ?? { type: "null"}; -let _ident55 = r_15; -const r_16 = r_14.values[1] ?? { type: "null"}; -let _builtin_id56 = r_16; -(runtime.setLine(41), _define_builtin40(_ident55, _builtin_id56)); -}; -const r_17 = (runtime.setLine(44), _define_let43(({ type: "string", value: "is_phi_compiler" }), ({ type: "int", value: 0 }))); -let _is_phi_compiler_sym_id57 = r_17; -(runtime.setLine(45), _emit39((runtime.setLine(45), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "let _is_phi_compiler% = { type: \"bool\", value: true };\n" }), _is_phi_compiler_sym_id57)))); -(runtime.setLine(50), _discover_syms32(_ast28)); -(runtime.setLine(51), _emit_exprs31(_ast28)); -runtime.popCall(); -return (runtime.setLine(52), ((...args) => runtime.builtinStringsJoin(...args))(_output44)); -; -runtime.popCall(); -return { type: "null" }; -}; -function _emit_exprs31(_exprs58) { -runtime.pushCall("emit_exprs"); -for (const r_18 of _exprs58.values) {; -let _expr59 = r_18; -(runtime.setLine(57), _emit_expr33(_expr59)); -(runtime.setLine(58), _emit39(({ type: "string", value: ";\n" }))); -}; -; -runtime.popCall(); -return { type: "null" }; -}; -function _discover_syms32(_exprs60) { -runtime.pushCall("discover_syms"); -for (const r_19 of _exprs60.values) {; -let _expr61 = r_19; -const r_20 = _expr61; -const r_21 = r_20.values[0] ?? { type: "null"}; -let _ty62 = r_21; -const r_22 = r_20.values[1] ?? { type: "null"}; -let _line63 = r_22; -if (runtime.truthy(runtime.opNe(_ty62, ({ type: "string", value: "list" })))) { -runtime.popCall(); -return { type: "null" }}; -const r_23 = _expr61; -const r_24 = r_23.values[0] ?? { type: "null"}; -const r_25 = r_23.values[1] ?? { type: "null"}; -const r_26 = r_23.values[2] ?? { type: "null"}; -let _s64 = r_26; -if (runtime.truthy(runtime.opEq((runtime.setLine(67), ((...args) => runtime.builtinLen(...args))(_s64)), ({ type: "int", value: 0 })))) { -runtime.popCall(); -return { type: "null" }}; -const r_27 = _s64; -const r_28 = r_27.values[0] ?? { type: "null"}; -const r_29 = r_28.values[0] ?? { type: "null"}; -const r_30 = r_28.values[1] ?? { type: "null"}; -const r_31 = r_28.values[2] ?? { type: "null"}; -let _id65 = r_31; -if (runtime.truthy(runtime.opEq(_id65, ({ type: "string", value: "fn" })))) { -const r_32 = _s64; -const r_33 = r_32.values[0] ?? { type: "null"}; -const r_34 = r_32.values[1] ?? { type: "null"}; -const r_35 = r_34.values[0] ?? { type: "null"}; -const r_36 = r_34.values[1] ?? { type: "null"}; -const r_37 = r_34.values[2] ?? { type: "null"}; -let _ident66 = r_37; -const r_38 = r_32.values[2] ?? { type: "null"}; -const r_39 = r_38.values[0] ?? { type: "null"}; -const r_40 = r_38.values[1] ?? { type: "null"}; -const r_41 = r_38.values[2] ?? { type: "null"}; -let _params67 = r_41; -const r_42 = r_32.values[3] ?? { type: "null"}; -let _body68 = r_42; -(runtime.setLine(71), _define_fn41(_ident66, _line63)); -}; -}; -; -runtime.popCall(); -return { type: "null" }; -}; -function _emit_expr33(_expr69) { -runtime.pushCall("emit_expr"); -const r_43 = _expr69; -const r_44 = r_43.values[0] ?? { type: "null"}; -let _ty70 = r_44; -const r_45 = r_43.values[1] ?? { type: "null"}; -let _line71 = r_45; -if (runtime.truthy(runtime.opEq(_ty70, ({ type: "string", value: "list" })))) { -(runtime.setLine(79), _emit_list34(_expr69)); -} else { -if (runtime.truthy(runtime.opEq(_ty70, ({ type: "string", value: "int" })))) { -const r_46 = _expr69; -const r_47 = r_46.values[0] ?? { type: "null"}; -const r_48 = r_46.values[1] ?? { type: "null"}; -const r_49 = r_46.values[2] ?? { type: "null"}; -let _value72 = r_49; -(runtime.setLine(82), _emit39((runtime.setLine(82), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "({ type: \"int\", value: % })" }), _value72)))); -} else { -if (runtime.truthy(runtime.opEq(_ty70, ({ type: "string", value: "string" })))) { -const r_50 = _expr69; -const r_51 = r_50.values[0] ?? { type: "null"}; -const r_52 = r_50.values[1] ?? { type: "null"}; -const r_53 = r_50.values[2] ?? { type: "null"}; -let _value73 = r_53; -(runtime.setLine(85), _emit39((runtime.setLine(85), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "({ type: \"string\", value: \"%\" })" }), (runtime.setLine(85), _string_escape19(_value73)))))); -} else { -if (runtime.truthy(runtime.opEq(_ty70, ({ type: "string", value: "ident" })))) { -const r_54 = _expr69; -const r_55 = r_54.values[0] ?? { type: "null"}; -const r_56 = r_54.values[1] ?? { type: "null"}; -const r_57 = r_54.values[2] ?? { type: "null"}; -let _value74 = r_57; -if (runtime.truthy(runtime.opEq(_value74, ({ type: "string", value: "null" })))) { -(runtime.setLine(90), _emit39(({ type: "string", value: "({ type: \"null\" })" }))); -runtime.popCall(); -return { type: "null" }; -} else { -if (runtime.truthy(runtime.opEq(_value74, ({ type: "string", value: "false" })))) { -(runtime.setLine(93), _emit39(({ type: "string", value: "({ type: \"bool\", value: false })" }))); -runtime.popCall(); -return { type: "null" }; -} else { -if (runtime.truthy(runtime.opEq(_value74, ({ type: "string", value: "true" })))) { -(runtime.setLine(96), _emit39(({ type: "string", value: "({ type: \"bool\", value: true })" }))); -runtime.popCall(); -return { type: "null" }; -}}}; -const r_58 = (runtime.setLine(100), _get_sym48(_value74)); -let _sym75 = r_58; -if (runtime.truthy(runtime.opEq(_sym75, ({ type: "null" })))) { -(runtime.setLine(102), _print_syms49()); -(runtime.setLine(103), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "undefined symbol '%' on line %" }), _value74, _line71)); -}; -const r_59 = _sym75; -const r_60 = r_59.values[0] ?? { type: "null"}; -let _sym_id76 = r_60; -const r_61 = r_59.values[1] ?? { type: "null"}; -let _sym_ty77 = r_61; -if (runtime.truthy(runtime.opEq(_sym_ty77, ({ type: "string", value: "builtin" })))) { -const r_62 = _sym75; -const r_63 = r_62.values[0] ?? { type: "null"}; -const r_64 = r_62.values[1] ?? { type: "null"}; -const r_65 = r_62.values[2] ?? { type: "null"}; -let _id78 = r_65; -(runtime.setLine(109), _emit39((runtime.setLine(109), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "((...args) => runtime.%(...args))" }), _id78)))); -} else { -if (runtime.truthy(runtime.opEq(_sym_ty77, ({ type: "string", value: "fn" })))) { -(runtime.setLine(111), _emit39((runtime.setLine(111), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _value74, _sym_id76)))); -} else { -if (runtime.truthy(runtime.opEq(_sym_ty77, ({ type: "string", value: "param" })))) { -(runtime.setLine(113), _emit39((runtime.setLine(113), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _value74, _sym_id76)))); -} else { -if (runtime.truthy(runtime.opEq(_sym_ty77, ({ type: "string", value: "let" })))) { -(runtime.setLine(115), _emit39((runtime.setLine(115), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _value74, _sym_id76)))); -} else { -(runtime.setLine(117), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "not implemented '%'" }), _sym_ty77)); -}}}}; -} else { -(runtime.setLine(120), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "unknown expr type '%' on line %" }), _ty70, _line71)); -}}}}; -; -runtime.popCall(); -return { type: "null" }; -}; -function _emit_list34(_expr79) { -runtime.pushCall("emit_list"); -const r_66 = _expr79; -const r_67 = r_66.values[0] ?? { type: "null"}; -let _ty80 = r_67; -const r_68 = r_66.values[1] ?? { type: "null"}; -let _line81 = r_68; -const r_69 = r_66.values[2] ?? { type: "null"}; -let _s82 = r_69; -if (runtime.truthy(runtime.opEq((runtime.setLine(126), ((...args) => runtime.builtinLen(...args))(_s82)), ({ type: "int", value: 0 })))) { -(runtime.setLine(127), _emit39(({ type: "string", value: "({ type: \"list\", values: [] })" }))); -runtime.popCall(); -return { type: "null" }; -}; -const r_70 = _s82; -const r_71 = r_70.values[0] ?? { type: "null"}; -const r_72 = r_71.values[0] ?? { type: "null"}; -let _id_ty83 = r_72; -const r_73 = r_71.values[1] ?? { type: "null"}; -const r_74 = r_71.values[2] ?? { type: "null"}; -let _id84 = r_74; -if (runtime.truthy(runtime.opNe(_id_ty83, ({ type: "string", value: "ident" })))) { -(runtime.setLine(132), _emit_list_literal35(_s82)); -runtime.popCall(); -return { type: "null" }; -}; -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "fn" })))) { -const r_75 = _s82; -const r_76 = r_75.values[0] ?? { type: "null"}; -const r_77 = r_75.values[1] ?? { type: "null"}; -const r_78 = r_77.values[0] ?? { type: "null"}; -const r_79 = r_77.values[1] ?? { type: "null"}; -const r_80 = r_77.values[2] ?? { type: "null"}; -let _ident85 = r_80; -const r_81 = r_75.values[2] ?? { type: "null"}; -const r_82 = r_81.values[0] ?? { type: "null"}; -const r_83 = r_81.values[1] ?? { type: "null"}; -const r_84 = r_81.values[2] ?? { type: "null"}; -let _params86 = r_84; -const r_85 = r_75.values[3] ?? { type: "null"}; -let _body87 = r_85; -const r_86 = (runtime.setLine(138), _get_sym48(_ident85)); -let _sym88 = r_86; -const r_87 = _sym88; -const r_88 = r_87.values[0] ?? { type: "null"}; -let _sym_id89 = r_88; -(runtime.setLine(141), _emit39((runtime.setLine(141), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "function _%%(" }), _ident85, _sym_id89)))); -(runtime.setLine(143), _enter_scope45()); -const r_89 = ({ type: "bool", value: true }); -let _first90 = r_89; -for (const r_90 of _params86.values) {; -const r_91 = r_90.values[0] ?? { type: "null"}; -const r_92 = r_90.values[1] ?? { type: "null"}; -const r_93 = r_90.values[2] ?? { type: "null"}; -let _ident91 = r_93; -if (runtime.truthy(runtime.opNot(_first90))) { -(runtime.setLine(148), _emit39(({ type: "string", value: ", " }))); -}; -(_first90 = ({ type: "bool", value: false })); -const r_94 = (runtime.setLine(152), _define_param42(_ident91, _line81)); -let _sym_id92 = r_94; -(runtime.setLine(153), _emit39((runtime.setLine(153), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _ident91, _sym_id92)))); -}; -(runtime.setLine(157), _emit39(({ type: "string", value: ") {\n" }))); -(runtime.setLine(158), _emit39((runtime.setLine(158), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.pushCall(\"%\");\n" }), _ident85)))); -(runtime.setLine(160), _emit_expr33(_body87)); -(runtime.setLine(161), _emit39(({ type: "string", value: ";\nruntime.popCall();\nreturn { type: \"null\" };\n}" }))); -(runtime.setLine(163), _leave_scope46()); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "let" })))) { -const r_95 = _s82; -const r_96 = r_95.values[0] ?? { type: "null"}; -const r_97 = r_95.values[1] ?? { type: "null"}; -let _pat93 = r_97; -const r_98 = r_95.values[2] ?? { type: "null"}; -let _expr94 = r_98; -const r_99 = (runtime.setLine(166), _let_node_reg_count50()); -let _reg95 = r_99; -(runtime.setLine(167), _let_node_reg_increment51()); -(runtime.setLine(168), _emit39((runtime.setLine(168), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "const r_% = " }), _reg95)))); -(runtime.setLine(169), _emit_expr33(_expr94)); -(runtime.setLine(170), _emit_let_node36(_pat93, _reg95)); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "do" })))) { -(runtime.setLine(172), _enter_scope45()); -(runtime.setLine(173), _discover_syms32((runtime.setLine(173), _slice26(_s82, ({ type: "int", value: 1 }))))); -(runtime.setLine(174), _emit_exprs31((runtime.setLine(174), _slice26(_s82, ({ type: "int", value: 1 }))))); -(runtime.setLine(175), _leave_scope46()); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "for" })))) { -const r_100 = _s82; -const r_101 = r_100.values[0] ?? { type: "null"}; -const r_102 = r_100.values[1] ?? { type: "null"}; -let _pat96 = r_102; -const r_103 = r_100.values[2] ?? { type: "null"}; -let _expr97 = r_103; -const r_104 = r_100.values[3] ?? { type: "null"}; -let _body98 = r_104; -const r_105 = (runtime.setLine(179), _let_node_reg_count50()); -let _reg99 = r_105; -(runtime.setLine(180), _let_node_reg_increment51()); -(runtime.setLine(181), _emit39((runtime.setLine(181), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "for (const r_% of " }), _reg99)))); -(runtime.setLine(182), _emit_expr33(_expr97)); -(runtime.setLine(183), _emit39(({ type: "string", value: ".values) {" }))); -(runtime.setLine(185), _enter_scope45()); -(runtime.setLine(186), _emit_let_node36(_pat96, _reg99)); -(runtime.setLine(187), _enter_scope45()); -(runtime.setLine(189), _emit39(({ type: "string", value: ";\n" }))); -(runtime.setLine(190), _emit_expr33(_body98)); -(runtime.setLine(191), _emit39(({ type: "string", value: "}" }))); -(runtime.setLine(193), _leave_scope46()); -(runtime.setLine(194), _leave_scope46()); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "loop" })))) { -const r_106 = _s82; -const r_107 = r_106.values[0] ?? { type: "null"}; -const r_108 = r_106.values[1] ?? { type: "null"}; -let _body100 = r_108; -(runtime.setLine(197), _emit39(({ type: "string", value: "while (true) {\n" }))); -(runtime.setLine(198), _emit_expr33(_body100)); -(runtime.setLine(199), _emit39(({ type: "string", value: "}" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "if" })))) { -const r_109 = _s82; -const r_110 = r_109.values[0] ?? { type: "null"}; -const r_111 = r_109.values[1] ?? { type: "null"}; -let _cond101 = r_111; -const r_112 = r_109.values[2] ?? { type: "null"}; -let _truthy102 = r_112; -const r_113 = r_109.values[3] ?? { type: "null"}; -let _falsy103 = r_113; -(runtime.setLine(202), _emit39(({ type: "string", value: "if (runtime.truthy(" }))); -(runtime.setLine(203), _emit_expr33(_cond101)); -(runtime.setLine(204), _emit39(({ type: "string", value: ")) {\n" }))); -(runtime.setLine(205), _emit_expr33(_truthy102)); -(runtime.setLine(206), _emit39(({ type: "string", value: "}" }))); -if (runtime.truthy(runtime.opNe(_falsy103, ({ type: "null" })))) { -(runtime.setLine(208), _emit39(({ type: "string", value: " else {\n" }))); -(runtime.setLine(209), _emit_expr33(_falsy103)); -(runtime.setLine(210), _emit39(({ type: "string", value: "}" }))); -}; -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "return" })))) { -const r_114 = _s82; -const r_115 = r_114.values[0] ?? { type: "null"}; -const r_116 = r_114.values[1] ?? { type: "null"}; -let _value104 = r_116; -(runtime.setLine(214), _emit39(({ type: "string", value: "runtime.popCall();\n" }))); -(runtime.setLine(215), _emit39(({ type: "string", value: "return " }))); -if (runtime.truthy(runtime.opNe(_value104, ({ type: "null" })))) { -(runtime.setLine(217), _emit_expr33(_value104)); -} else { -(runtime.setLine(219), _emit39(({ type: "string", value: "{ type: \"null\" }" }))); -}; -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "break" })))) { -const r_117 = _s82; -const r_118 = r_117.values[0] ?? { type: "null"}; -const r_119 = r_117.values[1] ?? { type: "null"}; -let _value105 = r_119; -(runtime.setLine(223), _emit39(({ type: "string", value: "break" }))); -if (runtime.truthy(runtime.opNe(_value105, ({ type: "null" })))) { -(runtime.setLine(225), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "not implemented" }))); -}; -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "call" })))) { -const r_120 = _s82; -const r_121 = r_120.values[0] ?? { type: "null"}; -const r_122 = r_120.values[1] ?? { type: "null"}; -let _callee106 = r_122; -const r_123 = (runtime.setLine(229), _slice26(_s82, ({ type: "int", value: 2 }))); -let _args107 = r_123; -(runtime.setLine(230), _emit39((runtime.setLine(230), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(runtime.setLine(%), " }), _line81)))); -(runtime.setLine(231), _emit_expr33(_callee106)); -(runtime.setLine(232), _emit39(({ type: "string", value: "(" }))); -const r_124 = ({ type: "bool", value: true }); -let _first108 = r_124; -for (const r_125 of _args107.values) {; -let _arg109 = r_125; -if (runtime.truthy(runtime.opNot(_first108))) { -(runtime.setLine(237), _emit39(({ type: "string", value: ", " }))); -}; -(_first108 = ({ type: "bool", value: false })); -(runtime.setLine(241), _emit_expr33(_arg109)); -}; -(runtime.setLine(244), _emit39(({ type: "string", value: "))" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "=" })))) { -(runtime.setLine(246), _emit_assign_expr38(_s82, _line81, ({ type: "string", value: "=" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "+=" })))) { -(runtime.setLine(248), _emit_assign_expr38(_s82, _line81, ({ type: "string", value: "+" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "-=" })))) { -(runtime.setLine(250), _emit_assign_expr38(_s82, _line81, ({ type: "string", value: "-" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "or" })))) { -const r_126 = _s82; -const r_127 = r_126.values[0] ?? { type: "null"}; -const r_128 = r_126.values[1] ?? { type: "null"}; -let _left110 = r_128; -const r_129 = r_126.values[2] ?? { type: "null"}; -let _right111 = r_129; -(runtime.setLine(253), _emit39((runtime.setLine(253), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(runtime.setLine(%)" }), _line81)))); -(runtime.setLine(254), _emit39(({ type: "string", value: ", { type: \"bool\", value: runtime.truthy(" }))); -(runtime.setLine(255), _emit_expr33(_left110)); -(runtime.setLine(256), _emit39(({ type: "string", value: ") || runtime.truthy(" }))); -(runtime.setLine(257), _emit_expr33(_right111)); -(runtime.setLine(258), _emit39(({ type: "string", value: ") })" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "and" })))) { -const r_130 = _s82; -const r_131 = r_130.values[0] ?? { type: "null"}; -const r_132 = r_130.values[1] ?? { type: "null"}; -let _left112 = r_132; -const r_133 = r_130.values[2] ?? { type: "null"}; -let _right113 = r_133; -(runtime.setLine(261), _emit39((runtime.setLine(261), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(runtime.setLine(%)" }), _line81)))); -(runtime.setLine(262), _emit39(({ type: "string", value: ", { type: \"bool\", value: runtime.truthy(" }))); -(runtime.setLine(263), _emit_expr33(_left112)); -(runtime.setLine(264), _emit39(({ type: "string", value: ") && runtime.truthy(" }))); -(runtime.setLine(265), _emit_expr33(_right113)); -(runtime.setLine(266), _emit39(({ type: "string", value: ") })" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "==" })))) { -(runtime.setLine(268), _emit_binary_op37(_s82, ({ type: "string", value: "opEq" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "!=" })))) { -(runtime.setLine(270), _emit_binary_op37(_s82, ({ type: "string", value: "opNe" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "<" })))) { -(runtime.setLine(272), _emit_binary_op37(_s82, ({ type: "string", value: "opLt" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: ">" })))) { -(runtime.setLine(274), _emit_binary_op37(_s82, ({ type: "string", value: "opGt" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "<=" })))) { -(runtime.setLine(276), _emit_binary_op37(_s82, ({ type: "string", value: "opLte" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: ">=" })))) { -(runtime.setLine(278), _emit_binary_op37(_s82, ({ type: "string", value: "opGte" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "+" })))) { -(runtime.setLine(280), _emit_binary_op37(_s82, ({ type: "string", value: "opAdd" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "-" })))) { -(runtime.setLine(282), _emit_binary_op37(_s82, ({ type: "string", value: "opSub" }))); -} else { -if (runtime.truthy(runtime.opEq(_id84, ({ type: "string", value: "not" })))) { -const r_134 = _s82; -const r_135 = r_134.values[0] ?? { type: "null"}; -const r_136 = r_134.values[1] ?? { type: "null"}; -let _expr114 = r_136; -(runtime.setLine(285), _emit39(({ type: "string", value: "runtime.opNot(" }))); -(runtime.setLine(286), _emit_expr33(_expr114)); -(runtime.setLine(287), _emit39(({ type: "string", value: ")" }))); -} else { -(runtime.setLine(289), _emit_list_literal35(_s82)); -}}}}}}}}}}}}}}}}}}}}}}}; -; -runtime.popCall(); -return { type: "null" }; -}; -function _emit_list_literal35(_s115) { -runtime.pushCall("emit_list_literal"); -(runtime.setLine(294), _emit39(({ type: "string", value: "({ type: \"list\", values: [" }))); -const r_137 = ({ type: "bool", value: true }); -let _first116 = r_137; -for (const r_138 of _s115.values) {; -let _e117 = r_138; -if (runtime.truthy(runtime.opNot(_first116))) { -(runtime.setLine(298), _emit39(({ type: "string", value: ", " }))); -}; -(_first116 = ({ type: "bool", value: false })); -(runtime.setLine(302), _emit_expr33(_e117)); -}; -(runtime.setLine(304), _emit39(({ type: "string", value: "] })" }))); -; -runtime.popCall(); -return { type: "null" }; -}; -function _emit_let_node36(_pat118, _base_reg119) { -runtime.pushCall("emit_let_node"); -const r_139 = _pat118; -const r_140 = r_139.values[0] ?? { type: "null"}; -let _pat_ty120 = r_140; -const r_141 = r_139.values[1] ?? { type: "null"}; -let _line121 = r_141; -if (runtime.truthy(runtime.opEq(_pat_ty120, ({ type: "string", value: "ident" })))) { -const r_142 = _pat118; -const r_143 = r_142.values[0] ?? { type: "null"}; -const r_144 = r_142.values[1] ?? { type: "null"}; -const r_145 = r_142.values[2] ?? { type: "null"}; -let _ident122 = r_145; -if (runtime.truthy(runtime.opEq(_ident122, ({ type: "string", value: "_" })))) { -runtime.popCall(); -return { type: "null" }}; -const r_146 = (runtime.setLine(314), _define_let43(_ident122, _line121)); -let _sym_id123 = r_146; -(runtime.setLine(315), _emit39((runtime.setLine(315), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: ";\nlet _%% = r_%" }), _ident122, _sym_id123, _base_reg119)))); -} else { -if (runtime.truthy(runtime.opEq(_pat_ty120, ({ type: "string", value: "list" })))) { -const r_147 = _pat118; -const r_148 = r_147.values[0] ?? { type: "null"}; -const r_149 = r_147.values[1] ?? { type: "null"}; -const r_150 = r_147.values[2] ?? { type: "null"}; -let _pats124 = r_150; -const r_151 = ({ type: "int", value: 0 }); -let _i125 = r_151; -for (const r_152 of _pats124.values) {; -let _pat126 = r_152; -const r_153 = (runtime.setLine(337), _let_node_reg_count50()); -let _reg127 = r_153; -(runtime.setLine(338), _let_node_reg_increment51()); -(runtime.setLine(339), _emit39((runtime.setLine(339), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: ";\nconst r_% = r_%.values[%] ?? { type: \"null\"}" }), _reg127, _base_reg119, _i125)))); -(runtime.setLine(343), _emit_let_node36(_pat126, _reg127)); -(_i125 = runtime.opAdd(_i125, ({ type: "int", value: 1 }))); -}; -} else { -(runtime.setLine(347), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "malformed pattern on line %" }), _line121)); -}}; -; -runtime.popCall(); -return { type: "null" }; -}; -function _emit_binary_op37(_s128, _id129) { -runtime.pushCall("emit_binary_op"); -const r_154 = _s128; -const r_155 = r_154.values[0] ?? { type: "null"}; -const r_156 = r_154.values[1] ?? { type: "null"}; -let _left130 = r_156; -const r_157 = r_154.values[2] ?? { type: "null"}; -let _right131 = r_157; -(runtime.setLine(353), _emit39((runtime.setLine(353), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.%(" }), _id129)))); -(runtime.setLine(354), _emit_expr33(_left130)); -(runtime.setLine(355), _emit39(({ type: "string", value: ", " }))); -(runtime.setLine(356), _emit_expr33(_right131)); -(runtime.setLine(357), _emit39(({ type: "string", value: ")" }))); -; -runtime.popCall(); -return { type: "null" }; -}; -function _emit_assign_expr38(_s132, _line133, _id134) { -runtime.pushCall("emit_assign_expr"); -const r_158 = _s132; -const r_159 = r_158.values[0] ?? { type: "null"}; -const r_160 = r_158.values[1] ?? { type: "null"}; -const r_161 = r_160.values[0] ?? { type: "null"}; -let _target_type135 = r_161; -const r_162 = r_158.values[2] ?? { type: "null"}; -let _expr136 = r_162; -if (runtime.truthy(runtime.opNe(_target_type135, ({ type: "string", value: "ident" })))) { -(runtime.setLine(363), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "cannot assign to expression on line %" }), _line133)); -}; -const r_163 = _s132; -const r_164 = r_163.values[0] ?? { type: "null"}; -const r_165 = r_163.values[1] ?? { type: "null"}; -const r_166 = r_165.values[0] ?? { type: "null"}; -const r_167 = r_165.values[1] ?? { type: "null"}; -const r_168 = r_165.values[2] ?? { type: "null"}; -let _ident137 = r_168; -const r_169 = (runtime.setLine(366), _get_sym48(_ident137)); -let _sym138 = r_169; -if (runtime.truthy(runtime.opEq(_sym138, ({ type: "null" })))) { -(runtime.setLine(368), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "could not find symbol '%' on line %" }), _ident137, _line133)); -}; -const r_170 = _sym138; -const r_171 = r_170.values[0] ?? { type: "null"}; -let _sym_id139 = r_171; -const r_172 = r_170.values[1] ?? { type: "null"}; -let _sym_type140 = r_172; -const r_173 = r_170.values[2] ?? { type: "null"}; -let _sym_ident141 = r_173; -const r_174 = r_170.values[3] ?? { type: "null"}; -if (runtime.truthy(runtime.opEq(_sym_type140, ({ type: "string", value: "let" })))) { -(runtime.setLine(372), _emit39((runtime.setLine(372), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(_%% = " }), _sym_ident141, _sym_id139)))); -if (runtime.truthy(runtime.opEq(_id134, ({ type: "string", value: "=" })))) { -(runtime.setLine(374), _emit_expr33(_expr136)); -} else { -if (runtime.truthy(runtime.opEq(_id134, ({ type: "string", value: "+" })))) { -(runtime.setLine(376), _emit39((runtime.setLine(376), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.opAdd(_%%, " }), _sym_ident141, _sym_id139)))); -(runtime.setLine(377), _emit_expr33(_expr136)); -(runtime.setLine(378), _emit39(({ type: "string", value: ")" }))); -} else { -if (runtime.truthy(runtime.opEq(_id134, ({ type: "string", value: "-" })))) { -(runtime.setLine(380), _emit39((runtime.setLine(380), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.opSub(_%%, " }), _sym_ident141, _sym_id139)))); -(runtime.setLine(381), _emit_expr33(_expr136)); -(runtime.setLine(382), _emit39(({ type: "string", value: ")" }))); -} else { -(runtime.setLine(384), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "not implemented" }))); -}}}; -(runtime.setLine(386), _emit39(({ type: "string", value: ")" }))); -} else { -(runtime.setLine(388), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "cannot assign to symbol '%' on line %" }), _sym_ident141, _line133)); -}; -; -runtime.popCall(); -return { type: "null" }; -}; -function _emit39(_str142) { -runtime.pushCall("emit"); -(runtime.setLine(393), ((...args) => runtime.builtinPush(...args))(_output44, _str142)); -; -runtime.popCall(); -return { type: "null" }; -}; -function _define_builtin40(_ident143, _builtin_id144) { -runtime.pushCall("define_builtin"); -const r_175 = (runtime.setLine(397), _sym_id_count52()); -let _sym_id145 = r_175; -(runtime.setLine(398), _sym_id_increment53()); -(runtime.setLine(400), _define_sym47(_ident143, ({ type: "list", values: [_sym_id145, ({ type: "string", value: "builtin" }), _builtin_id144] }))); -runtime.popCall(); -return _sym_id145; -; -runtime.popCall(); -return { type: "null" }; -}; -function _define_fn41(_ident146, _line147) { -runtime.pushCall("define_fn"); -const r_176 = (runtime.setLine(405), _sym_id_count52()); -let _sym_id148 = r_176; -(runtime.setLine(406), _sym_id_increment53()); -(runtime.setLine(408), _define_sym47(_ident146, ({ type: "list", values: [_sym_id148, ({ type: "string", value: "fn" }), _ident146, _line147] }))); -runtime.popCall(); -return _sym_id148; -; -runtime.popCall(); -return { type: "null" }; -}; -function _define_param42(_ident149, _line150) { -runtime.pushCall("define_param"); -const r_177 = (runtime.setLine(413), _sym_id_count52()); -let _sym_id151 = r_177; -(runtime.setLine(414), _sym_id_increment53()); -(runtime.setLine(416), _define_sym47(_ident149, ({ type: "list", values: [_sym_id151, ({ type: "string", value: "param" }), _ident149, _line150] }))); -runtime.popCall(); -return _sym_id151; -; -runtime.popCall(); -return { type: "null" }; -}; -function _define_let43(_ident152, _line153) { -runtime.pushCall("define_let"); -const r_178 = (runtime.setLine(421), _sym_id_count52()); -let _sym_id154 = r_178; -(runtime.setLine(422), _sym_id_increment53()); -(runtime.setLine(424), _define_sym47(_ident152, ({ type: "list", values: [_sym_id154, ({ type: "string", value: "let" }), _ident152, _line153] }))); -runtime.popCall(); -return _sym_id154; -; -runtime.popCall(); -return { type: "null" }; -}; -runtime.popCall(); -return ({ type: "list", values: [_generate30] }); -; -runtime.popCall(); -return { type: "null" }; -}; -function _Counter17() { -runtime.pushCall("Counter"); -const r_179 = ({ type: "int", value: 0 }); -let _counter157 = r_179; -function _count155() { -runtime.pushCall("count"); -runtime.popCall(); -return _counter157; -; -runtime.popCall(); -return { type: "null" }; -}; -function _increment156() { -runtime.pushCall("increment"); -(_counter157 = runtime.opAdd(_counter157, ({ type: "int", value: 1 }))); -; -runtime.popCall(); -return { type: "null" }; -}; -runtime.popCall(); -return ({ type: "list", values: [_count155, _increment156] }); -; -runtime.popCall(); -return { type: "null" }; -}; -function _Syms18() { -runtime.pushCall("Syms"); -const r_180 = ({ type: "list", values: [({ type: "null" }), ({ type: "list", values: [] })] }); -let _syms165 = r_180; -function _enter_scope158() { -runtime.pushCall("enter_scope"); -(_syms165 = ({ type: "list", values: [_syms165, ({ type: "list", values: [] })] })); -; -runtime.popCall(); -return { type: "null" }; -}; -function _leave_scope159() { -runtime.pushCall("leave_scope"); -const r_181 = _syms165; -const r_182 = r_181.values[0] ?? { type: "null"}; -let _parent166 = r_182; -const r_183 = r_181.values[1] ?? { type: "null"}; -(_syms165 = _parent166); -; -runtime.popCall(); -return { type: "null" }; -}; -function _define160(_ident167, _sym168) { -runtime.pushCall("define"); -const r_184 = _syms165; -const r_185 = r_184.values[0] ?? { type: "null"}; -const r_186 = r_184.values[1] ?? { type: "null"}; -let _map169 = r_186; -const r_187 = ({ type: "int", value: 0 }); -let _i170 = r_187; -while (true) { -if (runtime.truthy(runtime.opGte(_i170, (runtime.setLine(461), ((...args) => runtime.builtinLen(...args))(_map169))))) { -break}; -const r_188 = (runtime.setLine(462), ((...args) => runtime.builtinAt(...args))(_map169, _i170)); -const r_189 = r_188.values[0] ?? { type: "null"}; -let _s_ident171 = r_189; -const r_190 = r_188.values[1] ?? { type: "null"}; -if (runtime.truthy(runtime.opEq(_ident167, _s_ident171))) { -(runtime.setLine(464), ((...args) => runtime.builtinSet(...args))(_map169, _i170, ({ type: "list", values: [_ident167, _sym168] }))); -runtime.popCall(); -return { type: "null" }; -}; -(_i170 = runtime.opAdd(_i170, ({ type: "int", value: 1 }))); -}; -(runtime.setLine(469), ((...args) => runtime.builtinPush(...args))(_map169, ({ type: "list", values: [_ident167, _sym168] }))); -; -runtime.popCall(); -return { type: "null" }; -}; -function _find_sym161(_syms172, _ident173) { -runtime.pushCall("find_sym"); -const r_191 = _syms172; -const r_192 = r_191.values[0] ?? { type: "null"}; -let _parent174 = r_192; -const r_193 = r_191.values[1] ?? { type: "null"}; -let _map175 = r_193; -const r_194 = ({ type: "int", value: 0 }); -let _i176 = r_194; -while (true) { -if (runtime.truthy(runtime.opGte(_i176, (runtime.setLine(476), ((...args) => runtime.builtinLen(...args))(_map175))))) { -break}; -const r_195 = (runtime.setLine(477), ((...args) => runtime.builtinAt(...args))(_map175, _i176)); -const r_196 = r_195.values[0] ?? { type: "null"}; -let _s_ident177 = r_196; -const r_197 = r_195.values[1] ?? { type: "null"}; -let _s_sym178 = r_197; -if (runtime.truthy(runtime.opEq(_ident173, _s_ident177))) { -runtime.popCall(); -return _s_sym178; -}; -(_i176 = runtime.opAdd(_i176, ({ type: "int", value: 1 }))); -}; -if (runtime.truthy(runtime.opNe(_parent174, ({ type: "null" })))) { -runtime.popCall(); -return (runtime.setLine(484), _find_sym161(_parent174, _ident173)); -}; -runtime.popCall(); -return ({ type: "null" }); -; -runtime.popCall(); -return { type: "null" }; -}; -function _get162(_ident179) { -runtime.pushCall("get"); -runtime.popCall(); -return (runtime.setLine(490), _find_sym161(_syms165, _ident179)); -; -runtime.popCall(); -return { type: "null" }; -}; -function _print_syms_node163(_syms180, _depth181) { -runtime.pushCall("print_syms_node"); -const r_198 = _syms180; -const r_199 = r_198.values[0] ?? { type: "null"}; -let _parent182 = r_199; -const r_200 = r_198.values[1] ?? { type: "null"}; -let _map183 = r_200; -for (const r_201 of _map183.values) {; -const r_202 = r_201.values[0] ?? { type: "null"}; -let _ident184 = r_202; -const r_203 = r_201.values[1] ?? { type: "null"}; -let _sym185 = r_203; -(runtime.setLine(496), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%- %: %" }), (runtime.setLine(496), _indent25(_depth181)), _ident184, _sym185)); -}; -if (runtime.truthy(runtime.opNe(_parent182, ({ type: "null" })))) { -(runtime.setLine(499), _print_syms_node163(_parent182, runtime.opAdd(_depth181, ({ type: "int", value: 1 })))); -}; -; -runtime.popCall(); -return { type: "null" }; -}; -function _print_syms164() { -runtime.pushCall("print_syms"); -(runtime.setLine(504), _print_syms_node163(_syms165, ({ type: "int", value: 0 }))); -; -runtime.popCall(); -return { type: "null" }; -}; -runtime.popCall(); -return ({ type: "list", values: [_enter_scope158, _leave_scope159, _define160, _get162, _print_syms164] }); -; -runtime.popCall(); -return { type: "null" }; -}; -function _string_escape19(_str186) { -runtime.pushCall("string_escape"); -const r_204 = (runtime.setLine(518), ((...args) => runtime.builtinLen(...args))(_str186)); -let _str_len187 = r_204; -const r_205 = ({ type: "int", value: 0 }); -let _i188 = r_205; -const r_206 = ({ type: "string", value: "" }); -let _result189 = r_206; -while (true) { -if (runtime.truthy(runtime.opGte(_i188, _str_len187))) { -break}; -const r_207 = (runtime.setLine(523), ((...args) => runtime.builtinAt(...args))(_str186, _i188)); -let _ch190 = r_207; -if (runtime.truthy(runtime.opEq(_ch190, ({ type: "string", value: "\\" })))) { -(_result189 = runtime.opAdd(_result189, ({ type: "string", value: "\\\\" }))); -} else { -if (runtime.truthy(runtime.opEq(_ch190, ({ type: "string", value: "\"" })))) { -(_result189 = runtime.opAdd(_result189, ({ type: "string", value: "\\\"" }))); -} else { -if (runtime.truthy(runtime.opEq(_ch190, ({ type: "string", value: "\t" })))) { -(_result189 = runtime.opAdd(_result189, ({ type: "string", value: "\\t" }))); -} else { -if (runtime.truthy(runtime.opEq(_ch190, ({ type: "string", value: "\r" })))) { -(_result189 = runtime.opAdd(_result189, ({ type: "string", value: "\\r" }))); -} else { -if (runtime.truthy(runtime.opEq(_ch190, ({ type: "string", value: "\n" })))) { -(_result189 = runtime.opAdd(_result189, ({ type: "string", value: "\\n" }))); -} else { -if (runtime.truthy(runtime.opEq(_ch190, ({ type: "string", value: "\n" })))) { -(_result189 = runtime.opAdd(_result189, ({ type: "string", value: "\\0" }))); -} else { -(_result189 = runtime.opAdd(_result189, _ch190)); -}}}}}}; -(_i188 = runtime.opAdd(_i188, ({ type: "int", value: 1 }))); -}; -runtime.popCall(); -return _result189; -; -runtime.popCall(); -return { type: "null" }; -}; -function _Parser20(_tokens191) { -runtime.pushCall("Parser"); -const r_208 = ({ type: "int", value: 0 }); -let _i198 = r_208; -const r_209 = (runtime.setLine(546), ((...args) => runtime.builtinAt(...args))(_tokens191, _i198)); -let _tok199 = r_209; -function _parse192() { -runtime.pushCall("parse"); -const r_210 = ({ type: "list", values: [] }); -let _exprs200 = r_210; -while (true) { -if (runtime.truthy((runtime.setLine(551), _done197()))) { -break}; -(runtime.setLine(552), ((...args) => runtime.builtinPush(...args))(_exprs200, (runtime.setLine(552), _parse_expr193()))); -}; -runtime.popCall(); -return _exprs200; -; -runtime.popCall(); -return { type: "null" }; -}; -function _parse_expr193() { -runtime.pushCall("parse_expr"); -const r_211 = _tok199; -const r_212 = r_211.values[0] ?? { type: "null"}; -let _ty201 = r_212; -const r_213 = r_211.values[1] ?? { type: "null"}; -let _line202 = r_213; -const r_214 = r_211.values[2] ?? { type: "null"}; -let _value203 = r_214; -if (runtime.truthy((runtime.setLine(559), _eat194(({ type: "string", value: "(" }))))) { -const r_215 = ({ type: "list", values: [] }); -let _values204 = r_215; -while (true) { -if (runtime.truthy((runtime.setLine(562), _test196(({ type: "string", value: ")" }))))) { -break}; -(runtime.setLine(563), ((...args) => runtime.builtinPush(...args))(_values204, (runtime.setLine(563), _parse_expr193()))); -}; -if (runtime.truthy(runtime.opNot((runtime.setLine(565), _eat194(({ type: "string", value: ")" })))))) { -(runtime.setLine(566), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "expected ')' on line %" }), (runtime.setLine(566), ((...args) => runtime.builtinAt(...args))(_tok199, ({ type: "int", value: 1 }))))); -}; -runtime.popCall(); -return ({ type: "list", values: [({ type: "string", value: "list" }), _line202, _values204] }); -} else { -if (runtime.truthy((runtime.setLine(569), _eat194(({ type: "string", value: "string" }))))) { -runtime.popCall(); -return ({ type: "list", values: [({ type: "string", value: "string" }), _line202, _value203] }); -} else { -if (runtime.truthy((runtime.setLine(571), _eat194(({ type: "string", value: "int" }))))) { -runtime.popCall(); -return ({ type: "list", values: [({ type: "string", value: "int" }), _line202, (runtime.setLine(572), ((...args) => runtime.builtinStringToInt(...args))(_value203))] }); -} else { -if (runtime.truthy((runtime.setLine(573), _eat194(({ type: "string", value: "ident" }))))) { -runtime.popCall(); -return ({ type: "list", values: [({ type: "string", value: "ident" }), _line202, _value203] }); -} else { -(runtime.setLine(576), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "expected expression, got '%' on line %" }), _ty201, _line202)); -}}}}; -; -runtime.popCall(); -return { type: "null" }; -}; -function _eat194(_pat205) { -runtime.pushCall("eat"); -if (runtime.truthy(runtime.opNot((runtime.setLine(581), _test196(_pat205))))) { -runtime.popCall(); -return ({ type: "bool", value: false })}; -(runtime.setLine(582), _step195()); -runtime.popCall(); -return ({ type: "bool", value: true }); -; -runtime.popCall(); -return { type: "null" }; -}; -function _step195() { -runtime.pushCall("step"); -(_i198 = runtime.opAdd(_i198, ({ type: "int", value: 1 }))); -if (runtime.truthy(runtime.opNot((runtime.setLine(588), _done197())))) { -const r_216 = (runtime.setLine(589), ((...args) => runtime.builtinAt(...args))(_tokens191, _i198)); -let _new_tok206 = r_216; -(_tok199 = _new_tok206); -}; -; -runtime.popCall(); -return { type: "null" }; -}; -function _test196(_pat207) { -runtime.pushCall("test"); -if (runtime.truthy((runtime.setLine(595), _done197()))) { -runtime.popCall(); -return ({ type: "bool", value: false })}; -const r_217 = _tok199; -const r_218 = r_217.values[0] ?? { type: "null"}; -let _ty208 = r_218; -runtime.popCall(); -return runtime.opEq(_pat207, _ty208); -; -runtime.popCall(); -return { type: "null" }; -}; -function _done197() { -runtime.pushCall("done"); -runtime.popCall(); -return runtime.opGte(_i198, (runtime.setLine(601), ((...args) => runtime.builtinLen(...args))(_tokens191))); -; -runtime.popCall(); -return { type: "null" }; -}; -runtime.popCall(); -return ({ type: "list", values: [_parse192] }); -; -runtime.popCall(); -return { type: "null" }; -}; -function _tokenize21(_text209) { -runtime.pushCall("tokenize"); -const r_219 = (runtime.setLine(608), ((...args) => runtime.builtinLen(...args))(_text209)); -let _text_len210 = r_219; -const r_220 = ({ type: "list", values: [] }); -let _tokens211 = r_220; -const r_221 = ({ type: "int", value: 0 }); -let _i212 = r_221; -const r_222 = ({ type: "int", value: 1 }); -let _line213 = r_222; -const r_223 = runtime.opAdd(({ type: "string", value: "abcdefghijklmnopqrstuvwxyz" }), ({ type: "string", value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890+-*/%&|=?!<>'_" })); -let _ident_chars214 = r_223; -while (true) { -if (runtime.truthy(runtime.opGte(_i212, _text_len210))) { -break}; -const r_224 = (runtime.setLine(620), ((...args) => runtime.builtinAt(...args))(_text209, _i212)); -let _ch215 = r_224; -if (runtime.truthy((runtime.setLine(622), _contains22(({ type: "string", value: " \t\r\n" }), _ch215)))) { -if (runtime.truthy(runtime.opEq(_ch215, ({ type: "string", value: "\n" })))) { -(_line213 = runtime.opAdd(_line213, ({ type: "int", value: 1 }))); -}; -(_i212 = runtime.opAdd(_i212, ({ type: "int", value: 1 }))); -} else { -if (runtime.truthy((runtime.setLine(627), _slice_eq23(_text209, _i212, ({ type: "string", value: "//" }))))) { -while (true) { -if (runtime.truthy((runtime.setLine(629), { type: "bool", value: runtime.truthy(runtime.opGte(_i212, _text_len210)) || runtime.truthy(runtime.opEq((runtime.setLine(629), ((...args) => runtime.builtinAt(...args))(_text209, _i212)), ({ type: "string", value: "\n" }))) }))) { -break; -}; -(_i212 = runtime.opAdd(_i212, ({ type: "int", value: 1 }))); -}; -} else { -if (runtime.truthy((runtime.setLine(634), _contains22(({ type: "string", value: "()" }), _ch215)))) { -(runtime.setLine(635), ((...args) => runtime.builtinPush(...args))(_tokens211, ({ type: "list", values: [_ch215, _line213] }))); -(_i212 = runtime.opAdd(_i212, ({ type: "int", value: 1 }))); -} else { -if (runtime.truthy(runtime.opEq(_ch215, ({ type: "string", value: "\"" })))) { -const r_225 = ({ type: "string", value: "" }); -let _value216 = r_225; -(_i212 = runtime.opAdd(_i212, ({ type: "int", value: 1 }))); -(_ch215 = (runtime.setLine(640), ((...args) => runtime.builtinAt(...args))(_text209, _i212))); -while (true) { -if (runtime.truthy((runtime.setLine(642), { type: "bool", value: runtime.truthy(runtime.opGte(_i212, _text_len210)) || runtime.truthy(runtime.opEq(_ch215, ({ type: "string", value: "\"" }))) }))) { -break; -}; -if (runtime.truthy(runtime.opEq(_ch215, ({ type: "string", value: "\\" })))) { -(_i212 = runtime.opAdd(_i212, ({ type: "int", value: 1 }))); -if (runtime.truthy(runtime.opGte(_i212, _text_len210))) { -break; -}; -(_ch215 = (runtime.setLine(650), ((...args) => runtime.builtinAt(...args))(_text209, _i212))); -if (runtime.truthy(runtime.opEq(_ch215, ({ type: "string", value: "t" })))) { -(_value216 = runtime.opAdd(_value216, ({ type: "string", value: "\t" }))); -} else { -if (runtime.truthy(runtime.opEq(_ch215, ({ type: "string", value: "r" })))) { -(_value216 = runtime.opAdd(_value216, ({ type: "string", value: "\r" }))); -} else { -if (runtime.truthy(runtime.opEq(_ch215, ({ type: "string", value: "n" })))) { -(_value216 = runtime.opAdd(_value216, ({ type: "string", value: "\n" }))); -} else { -if (runtime.truthy(runtime.opEq(_ch215, ({ type: "string", value: "0" })))) { -(_value216 = runtime.opAdd(_value216, ({ type: "string", value: "\n" }))); -} else { -(_value216 = runtime.opAdd(_value216, _ch215)); -}}}}; -} else { -(_value216 = runtime.opAdd(_value216, _ch215)); -}; -(_i212 = runtime.opAdd(_i212, ({ type: "int", value: 1 }))); -(_ch215 = (runtime.setLine(666), ((...args) => runtime.builtinAt(...args))(_text209, _i212))); -}; -if (runtime.truthy((runtime.setLine(668), { type: "bool", value: runtime.truthy(runtime.opGte(_i212, _text_len210)) || runtime.truthy(runtime.opNe(_ch215, ({ type: "string", value: "\"" }))) }))) { -(runtime.setLine(669), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "expected '\"' on line %" }), _line213)); -}; -(_i212 = runtime.opAdd(_i212, ({ type: "int", value: 1 }))); -(runtime.setLine(672), ((...args) => runtime.builtinPush(...args))(_tokens211, ({ type: "list", values: [({ type: "string", value: "string" }), _line213, _value216] }))); -} else { -if (runtime.truthy((runtime.setLine(673), _contains22(({ type: "string", value: "0123456789" }), _ch215)))) { -const r_226 = ({ type: "string", value: "" }); -let _value217 = r_226; -while (true) { -(_ch215 = (runtime.setLine(676), ((...args) => runtime.builtinAt(...args))(_text209, _i212))); -if (runtime.truthy((runtime.setLine(677), { type: "bool", value: runtime.truthy(runtime.opGte(_i212, _text_len210)) || runtime.truthy(runtime.opNot((runtime.setLine(677), _contains22(({ type: "string", value: "0123456789" }), _ch215)))) }))) { -break; -}; -(_value217 = runtime.opAdd(_value217, _ch215)); -(_i212 = runtime.opAdd(_i212, ({ type: "int", value: 1 }))); -}; -(runtime.setLine(683), ((...args) => runtime.builtinPush(...args))(_tokens211, ({ type: "list", values: [({ type: "string", value: "int" }), _line213, _value217] }))); -} else { -if (runtime.truthy((runtime.setLine(684), _contains22(_ident_chars214, _ch215)))) { -const r_227 = ({ type: "string", value: "" }); -let _value218 = r_227; -while (true) { -(_ch215 = (runtime.setLine(687), ((...args) => runtime.builtinAt(...args))(_text209, _i212))); -if (runtime.truthy((runtime.setLine(688), { type: "bool", value: runtime.truthy(runtime.opGte(_i212, _text_len210)) || runtime.truthy(runtime.opNot((runtime.setLine(688), _contains22(_ident_chars214, _ch215)))) }))) { -break; -}; -(_value218 = runtime.opAdd(_value218, _ch215)); -(_i212 = runtime.opAdd(_i212, ({ type: "int", value: 1 }))); -}; -(runtime.setLine(694), ((...args) => runtime.builtinPush(...args))(_tokens211, ({ type: "list", values: [({ type: "string", value: "ident" }), _line213, _value218] }))); -} else { -(runtime.setLine(696), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "illegal char '%'" }), _ch215)); -(_i212 = runtime.opAdd(_i212, ({ type: "int", value: 1 }))); -}}}}}}; -}; -runtime.popCall(); -return _tokens211; -; -runtime.popCall(); -return { type: "null" }; -}; -function _contains22(_text219, _ch220) { -runtime.pushCall("contains"); -const r_228 = (runtime.setLine(704), ((...args) => runtime.builtinLen(...args))(_text219)); -let _text_len221 = r_228; -const r_229 = ({ type: "int", value: 0 }); -let _i222 = r_229; -while (true) { -if (runtime.truthy(runtime.opGte(_i222, _text_len221))) { -break}; -if (runtime.truthy(runtime.opEq((runtime.setLine(708), ((...args) => runtime.builtinAt(...args))(_text219, _i222)), _ch220))) { -runtime.popCall(); -return ({ type: "bool", value: true }); -}; -(_i222 = runtime.opAdd(_i222, ({ type: "int", value: 1 }))); -}; -runtime.popCall(); -return ({ type: "bool", value: false }); -; -runtime.popCall(); -return { type: "null" }; -}; -function _slice_eq23(_str223, _slice_idx224, _substr225) { -runtime.pushCall("slice_eq"); -const r_230 = (runtime.setLine(717), ((...args) => runtime.builtinLen(...args))(_str223)); -let _str_len226 = r_230; -const r_231 = (runtime.setLine(718), ((...args) => runtime.builtinLen(...args))(_substr225)); -let _substr_len227 = r_231; -const r_232 = ({ type: "int", value: 0 }); -let _i228 = r_232; -while (true) { -if (runtime.truthy(runtime.opGte(_i228, _substr_len227))) { -runtime.popCall(); -return ({ type: "bool", value: true })}; -if (runtime.truthy(runtime.opGte(runtime.opAdd(_slice_idx224, _i228), _str_len226))) { -runtime.popCall(); -return ({ type: "bool", value: false })}; -if (runtime.truthy(runtime.opNe((runtime.setLine(725), ((...args) => runtime.builtinAt(...args))(_str223, runtime.opAdd(_slice_idx224, _i228))), (runtime.setLine(725), ((...args) => runtime.builtinAt(...args))(_substr225, _i228))))) { -runtime.popCall(); -return ({ type: "bool", value: false })}; -(_i228 = runtime.opAdd(_i228, ({ type: "int", value: 1 }))); -}; -runtime.popCall(); -return ({ type: "bool", value: true }); -; -runtime.popCall(); -return { type: "null" }; -}; -function _print_expr24(_expr229, _depth230) { -runtime.pushCall("print_expr"); -const r_233 = _expr229; -const r_234 = r_233.values[0] ?? { type: "null"}; -let _ty231 = r_234; -const r_235 = r_233.values[1] ?? { type: "null"}; -let _line232 = r_235; -const r_236 = r_233.values[2] ?? { type: "null"}; -let _value233 = r_236; -if (runtime.truthy(runtime.opEq(_ty231, ({ type: "string", value: "list" })))) { -(runtime.setLine(735), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%(% %" }), (runtime.setLine(735), _indent25(_depth230)), _ty231, _line232)); -for (const r_237 of _value233.values) {; -let _e234 = r_237; -(runtime.setLine(737), _print_expr24(_e234, runtime.opAdd(_depth230, ({ type: "int", value: 1 })))); -}; -(runtime.setLine(739), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%)" }), (runtime.setLine(739), _indent25(_depth230)))); -} else { -(runtime.setLine(741), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%%" }), (runtime.setLine(741), _indent25(_depth230)), _expr229)); -}; -; -runtime.popCall(); -return { type: "null" }; -}; -function _indent25(_depth235) { -runtime.pushCall("indent"); -const r_238 = ({ type: "string", value: "" }); -let _space236 = r_238; -const r_239 = ({ type: "int", value: 0 }); -let _i237 = r_239; -while (true) { -if (runtime.truthy(runtime.opGte(_i237, _depth235))) { -break}; -(_space236 = runtime.opAdd(_space236, ({ type: "string", value: " " }))); -(_i237 = runtime.opAdd(_i237, ({ type: "int", value: 1 }))); -}; -runtime.popCall(); -return _space236; -; -runtime.popCall(); -return { type: "null" }; -}; -function _slice26(_list238, _idx239) { -runtime.pushCall("slice"); -const r_240 = (runtime.setLine(757), ((...args) => runtime.builtinLen(...args))(_list238)); -let _list_len240 = r_240; -const r_241 = ({ type: "list", values: [] }); -let _elems241 = r_241; -const r_242 = _idx239; -let _i242 = r_242; -while (true) { -if (runtime.truthy(runtime.opGte(_i242, _list_len240))) { -break}; -(runtime.setLine(762), ((...args) => runtime.builtinPush(...args))(_elems241, (runtime.setLine(762), ((...args) => runtime.builtinAt(...args))(_list238, _i242)))); -(_i242 = runtime.opAdd(_i242, ({ type: "int", value: 1 }))); -}; -runtime.popCall(); -return _elems241; -; -runtime.popCall(); -return { type: "null" }; -}; -const r_243 = ({ type: "bool", value: false }); -let _silent243 = r_243; -const r_244 = (runtime.setLine(770), ((...args) => runtime.builtinGetArgs(...args))()); -const r_245 = r_244.values[0] ?? { type: "null"}; -let _input_filename244 = r_245; -const r_246 = r_244.values[1] ?? { type: "null"}; -let _output_filename245 = r_246; -if (runtime.truthy(runtime.opNot(_silent243))) { -(runtime.setLine(772), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "reading file '%'..." }), _input_filename244))}; -const r_247 = (runtime.setLine(773), ((...args) => runtime.builtinReadTextFile(...args))(_input_filename244)); -let _text246 = r_247; -if (runtime.truthy(runtime.opNot(_silent243))) { -(runtime.setLine(779), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "tokenizing..." })))}; -const r_248 = (runtime.setLine(780), _tokenize21(_text246)); -let _tokens247 = r_248; -if (runtime.truthy(runtime.opNot(_silent243))) { -(runtime.setLine(793), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "parsing..." })))}; -const r_249 = (runtime.setLine(794), _Parser20(_tokens247)); -let _parser248 = r_249; -const r_250 = _parser248; -const r_251 = r_250.values[0] ?? { type: "null"}; -let _parse249 = r_251; -const r_252 = (runtime.setLine(796), _parse249()); -let _ast250 = r_252; -if (runtime.truthy(runtime.opNot(_silent243))) { -(runtime.setLine(803), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "emitting..." })))}; -const r_253 = (runtime.setLine(804), _Emitter16(_ast250, _input_filename244)); -let _emitter251 = r_253; -const r_254 = _emitter251; -const r_255 = r_254.values[0] ?? { type: "null"}; -let _emit252 = r_255; -const r_256 = (runtime.setLine(806), _emit252()); -let _js_code253 = r_256; -if (runtime.truthy(runtime.opNot(_silent243))) { -(runtime.setLine(811), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "writing file '%'..." }), _output_filename245))}; -(runtime.setLine(812), ((...args) => runtime.builtinWriteTextFile(...args))(_output_filename245, _js_code253));