From d3066748b2e65868d1aa0e835700f7fb9b7a7706 Mon Sep 17 00:00:00 2001 From: sfja Date: Tue, 23 Sep 2025 16:16:06 +0200 Subject: [PATCH] add list mnemonic --- compile.phi | 8 +- stage2.js | 438 ++++++++++++++++++++++++++-------------------------- 2 files changed, 226 insertions(+), 220 deletions(-) diff --git a/compile.phi b/compile.phi index d163ab7..ecaacc0 100644 --- a/compile.phi +++ b/compile.phi @@ -229,6 +229,8 @@ )) (call emit "))") + ) (if (== id "list") (do + (call emit_list_literal (call slice s 1)) ) (if (== id "=") (do (call emit_assign_expr s line "=") ) (if (== id "+=") (do @@ -274,7 +276,7 @@ (call emit ")") ) (do (call emit_list_literal s) - )))))))))))))))))))))))) + ))))))))))))))))))))))))) )) (fn emit_list_literal (s) (do @@ -792,8 +794,8 @@ (let (emit) emitter) (let js_code (call emit)) -// (call println "=== js ===") -// (call println js_code) + (call println "=== js ===") + (call println js_code) (if (not silent) (call println "writing file '%'..." output_filename)) (call write_text_file output_filename js_code) diff --git a/stage2.js b/stage2.js index e68193d..b6c5cd4 100644 --- a/stage2.js +++ b/stage2.js @@ -159,8 +159,7 @@ return { type: "null" }; const r_57 = (runtime.setLine(88), _get_sym45(_value70)); let _sym71 = r_57; if (runtime.truthy(runtime.opEq(_sym71, ({ type: "null" })))) { -(runtime.setLine(90), _print_syms46()); -(runtime.setLine(91), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "undefined symbol '%' on line %" }), _value70, _line67)); +(runtime.setLine(90), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "undefined symbol '%' on line %" }), _value70, _line67)); }; const r_58 = _sym71; const r_59 = r_58.values[0] ?? { type: "null"}; @@ -173,21 +172,21 @@ const r_62 = r_61.values[0] ?? { type: "null"}; const r_63 = r_61.values[1] ?? { type: "null"}; const r_64 = r_61.values[2] ?? { type: "null"}; let _id74 = r_64; -(runtime.setLine(97), _emit36((runtime.setLine(97), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "((...args) => runtime.%(...args))" }), _id74)))); +(runtime.setLine(96), _emit36((runtime.setLine(96), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "((...args) => runtime.%(...args))" }), _id74)))); } else { if (runtime.truthy(runtime.opEq(_sym_ty73, ({ type: "string", value: "fn" })))) { -(runtime.setLine(99), _emit36((runtime.setLine(99), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _value70, _sym_id72)))); +(runtime.setLine(98), _emit36((runtime.setLine(98), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _value70, _sym_id72)))); } else { if (runtime.truthy(runtime.opEq(_sym_ty73, ({ type: "string", value: "param" })))) { -(runtime.setLine(101), _emit36((runtime.setLine(101), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _value70, _sym_id72)))); +(runtime.setLine(100), _emit36((runtime.setLine(100), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _value70, _sym_id72)))); } else { if (runtime.truthy(runtime.opEq(_sym_ty73, ({ type: "string", value: "let" })))) { -(runtime.setLine(103), _emit36((runtime.setLine(103), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _value70, _sym_id72)))); +(runtime.setLine(102), _emit36((runtime.setLine(102), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _value70, _sym_id72)))); } else { -(runtime.setLine(105), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "not implemented '%'" }), _sym_ty73)); +(runtime.setLine(104), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "not implemented '%'" }), _sym_ty73)); }}}}; } else { -(runtime.setLine(108), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "unknown expr type '%' on line %" }), _ty66, _line67)); +(runtime.setLine(107), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "unknown expr type '%' on line %" }), _ty66, _line67)); }}}}; ; runtime.popCall(); @@ -202,8 +201,8 @@ const r_67 = r_65.values[1] ?? { type: "null"}; let _line77 = r_67; const r_68 = r_65.values[2] ?? { type: "null"}; let _s78 = r_68; -if (runtime.truthy(runtime.opEq((runtime.setLine(114), ((...args) => runtime.builtinLen(...args))(_s78)), ({ type: "int", value: 0 })))) { -(runtime.setLine(115), _emit36(({ type: "string", value: "({ type: \"list\", values: [] })" }))); +if (runtime.truthy(runtime.opEq((runtime.setLine(113), ((...args) => runtime.builtinLen(...args))(_s78)), ({ type: "int", value: 0 })))) { +(runtime.setLine(114), _emit36(({ type: "string", value: "({ type: \"list\", values: [] })" }))); runtime.popCall(); return { type: "null" }; }; @@ -215,7 +214,7 @@ const r_72 = r_70.values[1] ?? { type: "null"}; const r_73 = r_70.values[2] ?? { type: "null"}; let _id80 = r_73; if (runtime.truthy(runtime.opNe(_id_ty79, ({ type: "string", value: "ident" })))) { -(runtime.setLine(120), _emit_list_literal32(_s78)); +(runtime.setLine(119), _emit_list_literal32(_s78)); runtime.popCall(); return { type: "null" }; }; @@ -234,13 +233,13 @@ const r_83 = r_80.values[2] ?? { type: "null"}; let _params82 = r_83; const r_84 = r_74.values[3] ?? { type: "null"}; let _body83 = r_84; -const r_85 = (runtime.setLine(126), _get_sym45(_ident81)); +const r_85 = (runtime.setLine(125), _get_sym45(_ident81)); let _sym84 = r_85; const r_86 = _sym84; const r_87 = r_86.values[0] ?? { type: "null"}; let _sym_id85 = r_87; -(runtime.setLine(129), _emit36((runtime.setLine(129), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "function _%%(" }), _ident81, _sym_id85)))); -(runtime.setLine(131), _enter_scope42()); +(runtime.setLine(128), _emit36((runtime.setLine(128), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "function _%%(" }), _ident81, _sym_id85)))); +(runtime.setLine(130), _enter_scope42()); const r_88 = ({ type: "bool", value: true }); let _first86 = r_88; for (const r_89 of _params82.values) {; @@ -249,18 +248,18 @@ const r_91 = r_89.values[1] ?? { type: "null"}; const r_92 = r_89.values[2] ?? { type: "null"}; let _ident87 = r_92; if (runtime.truthy(runtime.opNot(_first86))) { -(runtime.setLine(136), _emit36(({ type: "string", value: ", " }))); +(runtime.setLine(135), _emit36(({ type: "string", value: ", " }))); }; (_first86 = ({ type: "bool", value: false })); -const r_93 = (runtime.setLine(140), _define_param39(_ident87, _line77)); +const r_93 = (runtime.setLine(139), _define_param39(_ident87, _line77)); let _sym_id88 = r_93; -(runtime.setLine(141), _emit36((runtime.setLine(141), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _ident87, _sym_id88)))); +(runtime.setLine(140), _emit36((runtime.setLine(140), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "_%%" }), _ident87, _sym_id88)))); }; -(runtime.setLine(145), _emit36(({ type: "string", value: ") {\n" }))); -(runtime.setLine(146), _emit36((runtime.setLine(146), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.pushCall(\"%\");\n" }), _ident81)))); -(runtime.setLine(148), _emit_expr30(_body83)); -(runtime.setLine(149), _emit36(({ type: "string", value: ";\nruntime.popCall();\nreturn { type: \"null\" };\n}" }))); -(runtime.setLine(151), _leave_scope43()); +(runtime.setLine(144), _emit36(({ type: "string", value: ") {\n" }))); +(runtime.setLine(145), _emit36((runtime.setLine(145), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.pushCall(\"%\");\n" }), _ident81)))); +(runtime.setLine(147), _emit_expr30(_body83)); +(runtime.setLine(148), _emit36(({ type: "string", value: ";\nruntime.popCall();\nreturn { type: \"null\" };\n}" }))); +(runtime.setLine(150), _leave_scope43()); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "let" })))) { const r_94 = _s78; @@ -269,18 +268,18 @@ const r_96 = r_94.values[1] ?? { type: "null"}; let _pat89 = r_96; const r_97 = r_94.values[2] ?? { type: "null"}; let _expr90 = r_97; -const r_98 = (runtime.setLine(154), _let_node_reg_count47()); +const r_98 = (runtime.setLine(153), _let_node_reg_count47()); let _reg91 = r_98; -(runtime.setLine(155), _let_node_reg_increment48()); -(runtime.setLine(156), _emit36((runtime.setLine(156), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "const r_% = " }), _reg91)))); -(runtime.setLine(157), _emit_expr30(_expr90)); -(runtime.setLine(158), _emit_let_node33(_pat89, _reg91)); +(runtime.setLine(154), _let_node_reg_increment48()); +(runtime.setLine(155), _emit36((runtime.setLine(155), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "const r_% = " }), _reg91)))); +(runtime.setLine(156), _emit_expr30(_expr90)); +(runtime.setLine(157), _emit_let_node33(_pat89, _reg91)); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "do" })))) { -(runtime.setLine(160), _enter_scope42()); -(runtime.setLine(161), _discover_syms29((runtime.setLine(161), _slice24(_s78, ({ type: "int", value: 1 }))))); -(runtime.setLine(162), _emit_exprs28((runtime.setLine(162), _slice24(_s78, ({ type: "int", value: 1 }))))); -(runtime.setLine(163), _leave_scope43()); +(runtime.setLine(159), _enter_scope42()); +(runtime.setLine(160), _discover_syms29((runtime.setLine(160), _slice24(_s78, ({ type: "int", value: 1 }))))); +(runtime.setLine(161), _emit_exprs28((runtime.setLine(161), _slice24(_s78, ({ type: "int", value: 1 }))))); +(runtime.setLine(162), _leave_scope43()); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "for" })))) { const r_99 = _s78; @@ -291,29 +290,29 @@ const r_102 = r_99.values[2] ?? { type: "null"}; let _expr93 = r_102; const r_103 = r_99.values[3] ?? { type: "null"}; let _body94 = r_103; -const r_104 = (runtime.setLine(167), _let_node_reg_count47()); +const r_104 = (runtime.setLine(166), _let_node_reg_count47()); let _reg95 = r_104; -(runtime.setLine(168), _let_node_reg_increment48()); -(runtime.setLine(169), _emit36((runtime.setLine(169), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "for (const r_% of " }), _reg95)))); -(runtime.setLine(170), _emit_expr30(_expr93)); -(runtime.setLine(171), _emit36(({ type: "string", value: ".values) {" }))); -(runtime.setLine(173), _enter_scope42()); -(runtime.setLine(174), _emit_let_node33(_pat92, _reg95)); -(runtime.setLine(175), _enter_scope42()); -(runtime.setLine(177), _emit36(({ type: "string", value: ";\n" }))); -(runtime.setLine(178), _emit_expr30(_body94)); -(runtime.setLine(179), _emit36(({ type: "string", value: "}" }))); +(runtime.setLine(167), _let_node_reg_increment48()); +(runtime.setLine(168), _emit36((runtime.setLine(168), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "for (const r_% of " }), _reg95)))); +(runtime.setLine(169), _emit_expr30(_expr93)); +(runtime.setLine(170), _emit36(({ type: "string", value: ".values) {" }))); +(runtime.setLine(172), _enter_scope42()); +(runtime.setLine(173), _emit_let_node33(_pat92, _reg95)); +(runtime.setLine(174), _enter_scope42()); +(runtime.setLine(176), _emit36(({ type: "string", value: ";\n" }))); +(runtime.setLine(177), _emit_expr30(_body94)); +(runtime.setLine(178), _emit36(({ type: "string", value: "}" }))); +(runtime.setLine(180), _leave_scope43()); (runtime.setLine(181), _leave_scope43()); -(runtime.setLine(182), _leave_scope43()); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "loop" })))) { const r_105 = _s78; const r_106 = r_105.values[0] ?? { type: "null"}; const r_107 = r_105.values[1] ?? { type: "null"}; let _body96 = r_107; -(runtime.setLine(185), _emit36(({ type: "string", value: "while (true) {\n" }))); -(runtime.setLine(186), _emit_expr30(_body96)); -(runtime.setLine(187), _emit36(({ type: "string", value: "}" }))); +(runtime.setLine(184), _emit36(({ type: "string", value: "while (true) {\n" }))); +(runtime.setLine(185), _emit_expr30(_body96)); +(runtime.setLine(186), _emit36(({ type: "string", value: "}" }))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "if" })))) { const r_108 = _s78; @@ -324,15 +323,15 @@ const r_111 = r_108.values[2] ?? { type: "null"}; let _truthy98 = r_111; const r_112 = r_108.values[3] ?? { type: "null"}; let _falsy99 = r_112; -(runtime.setLine(190), _emit36(({ type: "string", value: "if (runtime.truthy(" }))); -(runtime.setLine(191), _emit_expr30(_cond97)); -(runtime.setLine(192), _emit36(({ type: "string", value: ")) {\n" }))); -(runtime.setLine(193), _emit_expr30(_truthy98)); -(runtime.setLine(194), _emit36(({ type: "string", value: "}" }))); +(runtime.setLine(189), _emit36(({ type: "string", value: "if (runtime.truthy(" }))); +(runtime.setLine(190), _emit_expr30(_cond97)); +(runtime.setLine(191), _emit36(({ type: "string", value: ")) {\n" }))); +(runtime.setLine(192), _emit_expr30(_truthy98)); +(runtime.setLine(193), _emit36(({ type: "string", value: "}" }))); if (runtime.truthy(runtime.opNe(_falsy99, ({ type: "null" })))) { -(runtime.setLine(196), _emit36(({ type: "string", value: " else {\n" }))); -(runtime.setLine(197), _emit_expr30(_falsy99)); -(runtime.setLine(198), _emit36(({ type: "string", value: "}" }))); +(runtime.setLine(195), _emit36(({ type: "string", value: " else {\n" }))); +(runtime.setLine(196), _emit_expr30(_falsy99)); +(runtime.setLine(197), _emit36(({ type: "string", value: "}" }))); }; } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "return" })))) { @@ -340,12 +339,12 @@ const r_113 = _s78; const r_114 = r_113.values[0] ?? { type: "null"}; const r_115 = r_113.values[1] ?? { type: "null"}; let _value100 = r_115; -(runtime.setLine(202), _emit36(({ type: "string", value: "runtime.popCall();\n" }))); -(runtime.setLine(203), _emit36(({ type: "string", value: "return " }))); +(runtime.setLine(201), _emit36(({ type: "string", value: "runtime.popCall();\n" }))); +(runtime.setLine(202), _emit36(({ type: "string", value: "return " }))); if (runtime.truthy(runtime.opNe(_value100, ({ type: "null" })))) { -(runtime.setLine(205), _emit_expr30(_value100)); +(runtime.setLine(204), _emit_expr30(_value100)); } else { -(runtime.setLine(207), _emit36(({ type: "string", value: "{ type: \"null\" }" }))); +(runtime.setLine(206), _emit36(({ type: "string", value: "{ type: \"null\" }" }))); }; } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "break" })))) { @@ -353,9 +352,9 @@ const r_116 = _s78; const r_117 = r_116.values[0] ?? { type: "null"}; const r_118 = r_116.values[1] ?? { type: "null"}; let _value101 = r_118; -(runtime.setLine(211), _emit36(({ type: "string", value: "break" }))); +(runtime.setLine(210), _emit36(({ type: "string", value: "break" }))); if (runtime.truthy(runtime.opNe(_value101, ({ type: "null" })))) { -(runtime.setLine(213), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "not implemented" }))); +(runtime.setLine(212), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "not implemented" }))); }; } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "call" })))) { @@ -363,31 +362,34 @@ const r_119 = _s78; const r_120 = r_119.values[0] ?? { type: "null"}; const r_121 = r_119.values[1] ?? { type: "null"}; let _callee102 = r_121; -const r_122 = (runtime.setLine(217), _slice24(_s78, ({ type: "int", value: 2 }))); +const r_122 = (runtime.setLine(216), _slice24(_s78, ({ type: "int", value: 2 }))); let _args103 = r_122; -(runtime.setLine(218), _emit36((runtime.setLine(218), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(runtime.setLine(%), " }), _line77)))); -(runtime.setLine(219), _emit_expr30(_callee102)); -(runtime.setLine(220), _emit36(({ type: "string", value: "(" }))); +(runtime.setLine(217), _emit36((runtime.setLine(217), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(runtime.setLine(%), " }), _line77)))); +(runtime.setLine(218), _emit_expr30(_callee102)); +(runtime.setLine(219), _emit36(({ type: "string", value: "(" }))); const r_123 = ({ type: "bool", value: true }); let _first104 = r_123; for (const r_124 of _args103.values) {; let _arg105 = r_124; if (runtime.truthy(runtime.opNot(_first104))) { -(runtime.setLine(225), _emit36(({ type: "string", value: ", " }))); +(runtime.setLine(224), _emit36(({ type: "string", value: ", " }))); }; (_first104 = ({ type: "bool", value: false })); -(runtime.setLine(229), _emit_expr30(_arg105)); +(runtime.setLine(228), _emit_expr30(_arg105)); }; -(runtime.setLine(232), _emit36(({ type: "string", value: "))" }))); +(runtime.setLine(231), _emit36(({ type: "string", value: "))" }))); +} else { +if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "list" })))) { +(runtime.setLine(233), _emit_list_literal32((runtime.setLine(233), _slice24(_s78, ({ type: "int", value: 1 }))))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "=" })))) { -(runtime.setLine(234), _emit_assign_expr35(_s78, _line77, ({ type: "string", value: "=" }))); +(runtime.setLine(235), _emit_assign_expr35(_s78, _line77, ({ type: "string", value: "=" }))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "+=" })))) { -(runtime.setLine(236), _emit_assign_expr35(_s78, _line77, ({ type: "string", value: "+" }))); +(runtime.setLine(237), _emit_assign_expr35(_s78, _line77, ({ type: "string", value: "+" }))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "-=" })))) { -(runtime.setLine(238), _emit_assign_expr35(_s78, _line77, ({ type: "string", value: "-" }))); +(runtime.setLine(239), _emit_assign_expr35(_s78, _line77, ({ type: "string", value: "-" }))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "or" })))) { const r_125 = _s78; @@ -396,12 +398,12 @@ const r_127 = r_125.values[1] ?? { type: "null"}; let _left106 = r_127; const r_128 = r_125.values[2] ?? { type: "null"}; let _right107 = r_128; -(runtime.setLine(241), _emit36((runtime.setLine(241), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(runtime.setLine(%)" }), _line77)))); -(runtime.setLine(242), _emit36(({ type: "string", value: ", { type: \"bool\", value: runtime.truthy(" }))); -(runtime.setLine(243), _emit_expr30(_left106)); -(runtime.setLine(244), _emit36(({ type: "string", value: ") || runtime.truthy(" }))); -(runtime.setLine(245), _emit_expr30(_right107)); -(runtime.setLine(246), _emit36(({ type: "string", value: ") })" }))); +(runtime.setLine(242), _emit36((runtime.setLine(242), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(runtime.setLine(%)" }), _line77)))); +(runtime.setLine(243), _emit36(({ type: "string", value: ", { type: \"bool\", value: runtime.truthy(" }))); +(runtime.setLine(244), _emit_expr30(_left106)); +(runtime.setLine(245), _emit36(({ type: "string", value: ") || runtime.truthy(" }))); +(runtime.setLine(246), _emit_expr30(_right107)); +(runtime.setLine(247), _emit36(({ type: "string", value: ") })" }))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "and" })))) { const r_129 = _s78; @@ -410,66 +412,66 @@ const r_131 = r_129.values[1] ?? { type: "null"}; let _left108 = r_131; const r_132 = r_129.values[2] ?? { type: "null"}; let _right109 = r_132; -(runtime.setLine(249), _emit36((runtime.setLine(249), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(runtime.setLine(%)" }), _line77)))); -(runtime.setLine(250), _emit36(({ type: "string", value: ", { type: \"bool\", value: runtime.truthy(" }))); -(runtime.setLine(251), _emit_expr30(_left108)); -(runtime.setLine(252), _emit36(({ type: "string", value: ") && runtime.truthy(" }))); -(runtime.setLine(253), _emit_expr30(_right109)); -(runtime.setLine(254), _emit36(({ type: "string", value: ") })" }))); +(runtime.setLine(250), _emit36((runtime.setLine(250), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(runtime.setLine(%)" }), _line77)))); +(runtime.setLine(251), _emit36(({ type: "string", value: ", { type: \"bool\", value: runtime.truthy(" }))); +(runtime.setLine(252), _emit_expr30(_left108)); +(runtime.setLine(253), _emit36(({ type: "string", value: ") && runtime.truthy(" }))); +(runtime.setLine(254), _emit_expr30(_right109)); +(runtime.setLine(255), _emit36(({ type: "string", value: ") })" }))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "==" })))) { -(runtime.setLine(256), _emit_binary_op34(_s78, ({ type: "string", value: "opEq" }))); +(runtime.setLine(257), _emit_binary_op34(_s78, ({ type: "string", value: "opEq" }))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "!=" })))) { -(runtime.setLine(258), _emit_binary_op34(_s78, ({ type: "string", value: "opNe" }))); +(runtime.setLine(259), _emit_binary_op34(_s78, ({ type: "string", value: "opNe" }))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "<" })))) { -(runtime.setLine(260), _emit_binary_op34(_s78, ({ type: "string", value: "opLt" }))); +(runtime.setLine(261), _emit_binary_op34(_s78, ({ type: "string", value: "opLt" }))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: ">" })))) { -(runtime.setLine(262), _emit_binary_op34(_s78, ({ type: "string", value: "opGt" }))); +(runtime.setLine(263), _emit_binary_op34(_s78, ({ type: "string", value: "opGt" }))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "<=" })))) { -(runtime.setLine(264), _emit_binary_op34(_s78, ({ type: "string", value: "opLte" }))); +(runtime.setLine(265), _emit_binary_op34(_s78, ({ type: "string", value: "opLte" }))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: ">=" })))) { -(runtime.setLine(266), _emit_binary_op34(_s78, ({ type: "string", value: "opGte" }))); +(runtime.setLine(267), _emit_binary_op34(_s78, ({ type: "string", value: "opGte" }))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "+" })))) { -(runtime.setLine(268), _emit_binary_op34(_s78, ({ type: "string", value: "opAdd" }))); +(runtime.setLine(269), _emit_binary_op34(_s78, ({ type: "string", value: "opAdd" }))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "-" })))) { -(runtime.setLine(270), _emit_binary_op34(_s78, ({ type: "string", value: "opSub" }))); +(runtime.setLine(271), _emit_binary_op34(_s78, ({ type: "string", value: "opSub" }))); } else { if (runtime.truthy(runtime.opEq(_id80, ({ type: "string", value: "not" })))) { const r_133 = _s78; const r_134 = r_133.values[0] ?? { type: "null"}; const r_135 = r_133.values[1] ?? { type: "null"}; let _expr110 = r_135; -(runtime.setLine(273), _emit36(({ type: "string", value: "runtime.opNot(" }))); -(runtime.setLine(274), _emit_expr30(_expr110)); -(runtime.setLine(275), _emit36(({ type: "string", value: ")" }))); +(runtime.setLine(274), _emit36(({ type: "string", value: "runtime.opNot(" }))); +(runtime.setLine(275), _emit_expr30(_expr110)); +(runtime.setLine(276), _emit36(({ type: "string", value: ")" }))); } else { -(runtime.setLine(277), _emit_list_literal32(_s78)); -}}}}}}}}}}}}}}}}}}}}}}}; +(runtime.setLine(278), _emit_list_literal32(_s78)); +}}}}}}}}}}}}}}}}}}}}}}}}; ; runtime.popCall(); return { type: "null" }; }; function _emit_list_literal32(_s111) { runtime.pushCall("emit_list_literal"); -(runtime.setLine(282), _emit36(({ type: "string", value: "({ type: \"list\", values: [" }))); +(runtime.setLine(283), _emit36(({ type: "string", value: "({ type: \"list\", values: [" }))); const r_136 = ({ type: "bool", value: true }); let _first112 = r_136; for (const r_137 of _s111.values) {; let _e113 = r_137; if (runtime.truthy(runtime.opNot(_first112))) { -(runtime.setLine(286), _emit36(({ type: "string", value: ", " }))); +(runtime.setLine(287), _emit36(({ type: "string", value: ", " }))); }; (_first112 = ({ type: "bool", value: false })); -(runtime.setLine(290), _emit_expr30(_e113)); +(runtime.setLine(291), _emit_expr30(_e113)); }; -(runtime.setLine(292), _emit36(({ type: "string", value: "] })" }))); +(runtime.setLine(293), _emit36(({ type: "string", value: "] })" }))); ; runtime.popCall(); return { type: "null" }; @@ -490,9 +492,9 @@ let _ident118 = r_144; if (runtime.truthy(runtime.opEq(_ident118, ({ type: "string", value: "_" })))) { runtime.popCall(); return { type: "null" }}; -const r_145 = (runtime.setLine(302), _define_let40(_ident118, _line117)); +const r_145 = (runtime.setLine(303), _define_let40(_ident118, _line117)); let _sym_id119 = r_145; -(runtime.setLine(303), _emit36((runtime.setLine(303), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: ";\nlet _%% = r_%" }), _ident118, _sym_id119, _base_reg115)))); +(runtime.setLine(304), _emit36((runtime.setLine(304), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: ";\nlet _%% = r_%" }), _ident118, _sym_id119, _base_reg115)))); } else { if (runtime.truthy(runtime.opEq(_pat_ty116, ({ type: "string", value: "list" })))) { const r_146 = _pat114; @@ -504,15 +506,15 @@ const r_150 = ({ type: "int", value: 0 }); let _i121 = r_150; for (const r_151 of _pats120.values) {; let _pat122 = r_151; -const r_152 = (runtime.setLine(325), _let_node_reg_count47()); +const r_152 = (runtime.setLine(326), _let_node_reg_count47()); let _reg123 = r_152; -(runtime.setLine(326), _let_node_reg_increment48()); -(runtime.setLine(327), _emit36((runtime.setLine(327), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: ";\nconst r_% = r_%.values[%] ?? { type: \"null\"}" }), _reg123, _base_reg115, _i121)))); -(runtime.setLine(331), _emit_let_node33(_pat122, _reg123)); +(runtime.setLine(327), _let_node_reg_increment48()); +(runtime.setLine(328), _emit36((runtime.setLine(328), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: ";\nconst r_% = r_%.values[%] ?? { type: \"null\"}" }), _reg123, _base_reg115, _i121)))); +(runtime.setLine(332), _emit_let_node33(_pat122, _reg123)); (_i121 = runtime.opAdd(_i121, ({ type: "int", value: 1 }))); }; } else { -(runtime.setLine(335), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "malformed pattern on line %" }), _line117)); +(runtime.setLine(336), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "malformed pattern on line %" }), _line117)); }}; ; runtime.popCall(); @@ -526,11 +528,11 @@ const r_155 = r_153.values[1] ?? { type: "null"}; let _left126 = r_155; const r_156 = r_153.values[2] ?? { type: "null"}; let _right127 = r_156; -(runtime.setLine(341), _emit36((runtime.setLine(341), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.%(" }), _id125)))); -(runtime.setLine(342), _emit_expr30(_left126)); -(runtime.setLine(343), _emit36(({ type: "string", value: ", " }))); -(runtime.setLine(344), _emit_expr30(_right127)); -(runtime.setLine(345), _emit36(({ type: "string", value: ")" }))); +(runtime.setLine(342), _emit36((runtime.setLine(342), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.%(" }), _id125)))); +(runtime.setLine(343), _emit_expr30(_left126)); +(runtime.setLine(344), _emit36(({ type: "string", value: ", " }))); +(runtime.setLine(345), _emit_expr30(_right127)); +(runtime.setLine(346), _emit36(({ type: "string", value: ")" }))); ; runtime.popCall(); return { type: "null" }; @@ -545,7 +547,7 @@ let _target_type131 = r_160; const r_161 = r_157.values[2] ?? { type: "null"}; let _expr132 = r_161; if (runtime.truthy(runtime.opNe(_target_type131, ({ type: "string", value: "ident" })))) { -(runtime.setLine(351), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "cannot assign to expression on line %" }), _line129)); +(runtime.setLine(352), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "cannot assign to expression on line %" }), _line129)); }; const r_162 = _s128; const r_163 = r_162.values[0] ?? { type: "null"}; @@ -554,10 +556,10 @@ const r_165 = r_164.values[0] ?? { type: "null"}; const r_166 = r_164.values[1] ?? { type: "null"}; const r_167 = r_164.values[2] ?? { type: "null"}; let _ident133 = r_167; -const r_168 = (runtime.setLine(354), _get_sym45(_ident133)); +const r_168 = (runtime.setLine(355), _get_sym45(_ident133)); let _sym134 = r_168; if (runtime.truthy(runtime.opEq(_sym134, ({ type: "null" })))) { -(runtime.setLine(356), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "could not find symbol '%' on line %" }), _ident133, _line129)); +(runtime.setLine(357), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "could not find symbol '%' on line %" }), _ident133, _line129)); }; const r_169 = _sym134; const r_170 = r_169.values[0] ?? { type: "null"}; @@ -568,25 +570,25 @@ const r_172 = r_169.values[2] ?? { type: "null"}; let _sym_ident137 = r_172; const r_173 = r_169.values[3] ?? { type: "null"}; if (runtime.truthy(runtime.opEq(_sym_type136, ({ type: "string", value: "let" })))) { -(runtime.setLine(360), _emit36((runtime.setLine(360), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(_%% = " }), _sym_ident137, _sym_id135)))); +(runtime.setLine(361), _emit36((runtime.setLine(361), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "(_%% = " }), _sym_ident137, _sym_id135)))); if (runtime.truthy(runtime.opEq(_id130, ({ type: "string", value: "=" })))) { -(runtime.setLine(362), _emit_expr30(_expr132)); +(runtime.setLine(363), _emit_expr30(_expr132)); } else { if (runtime.truthy(runtime.opEq(_id130, ({ type: "string", value: "+" })))) { -(runtime.setLine(364), _emit36((runtime.setLine(364), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.opAdd(_%%, " }), _sym_ident137, _sym_id135)))); -(runtime.setLine(365), _emit_expr30(_expr132)); -(runtime.setLine(366), _emit36(({ type: "string", value: ")" }))); +(runtime.setLine(365), _emit36((runtime.setLine(365), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.opAdd(_%%, " }), _sym_ident137, _sym_id135)))); +(runtime.setLine(366), _emit_expr30(_expr132)); +(runtime.setLine(367), _emit36(({ type: "string", value: ")" }))); } else { if (runtime.truthy(runtime.opEq(_id130, ({ type: "string", value: "-" })))) { -(runtime.setLine(368), _emit36((runtime.setLine(368), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.opSub(_%%, " }), _sym_ident137, _sym_id135)))); -(runtime.setLine(369), _emit_expr30(_expr132)); -(runtime.setLine(370), _emit36(({ type: "string", value: ")" }))); +(runtime.setLine(369), _emit36((runtime.setLine(369), ((...args) => runtime.builtinFormat(...args))(({ type: "string", value: "runtime.opSub(_%%, " }), _sym_ident137, _sym_id135)))); +(runtime.setLine(370), _emit_expr30(_expr132)); +(runtime.setLine(371), _emit36(({ type: "string", value: ")" }))); } else { -(runtime.setLine(372), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "not implemented" }))); +(runtime.setLine(373), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "not implemented" }))); }}}; -(runtime.setLine(374), _emit36(({ type: "string", value: ")" }))); +(runtime.setLine(375), _emit36(({ type: "string", value: ")" }))); } else { -(runtime.setLine(376), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "cannot assign to symbol '%' on line %" }), _sym_ident137, _line129)); +(runtime.setLine(377), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "cannot assign to symbol '%' on line %" }), _sym_ident137, _line129)); }; ; runtime.popCall(); @@ -594,17 +596,17 @@ return { type: "null" }; }; function _emit36(_str138) { runtime.pushCall("emit"); -(runtime.setLine(381), ((...args) => runtime.builtinPush(...args))(_output41, _str138)); +(runtime.setLine(382), ((...args) => runtime.builtinPush(...args))(_output41, _str138)); ; runtime.popCall(); return { type: "null" }; }; function _define_builtin37(_ident139, _builtin_id140) { runtime.pushCall("define_builtin"); -const r_174 = (runtime.setLine(385), _sym_id_count49()); +const r_174 = (runtime.setLine(386), _sym_id_count49()); let _sym_id141 = r_174; -(runtime.setLine(386), _sym_id_increment50()); -(runtime.setLine(388), _define_sym44(_ident139, ({ type: "list", values: [_sym_id141, ({ type: "string", value: "builtin" }), _builtin_id140] }))); +(runtime.setLine(387), _sym_id_increment50()); +(runtime.setLine(389), _define_sym44(_ident139, ({ type: "list", values: [_sym_id141, ({ type: "string", value: "builtin" }), _builtin_id140] }))); runtime.popCall(); return _sym_id141; ; @@ -613,10 +615,10 @@ return { type: "null" }; }; function _define_fn38(_ident142, _line143) { runtime.pushCall("define_fn"); -const r_175 = (runtime.setLine(393), _sym_id_count49()); +const r_175 = (runtime.setLine(394), _sym_id_count49()); let _sym_id144 = r_175; -(runtime.setLine(394), _sym_id_increment50()); -(runtime.setLine(396), _define_sym44(_ident142, ({ type: "list", values: [_sym_id144, ({ type: "string", value: "fn" }), _ident142, _line143] }))); +(runtime.setLine(395), _sym_id_increment50()); +(runtime.setLine(397), _define_sym44(_ident142, ({ type: "list", values: [_sym_id144, ({ type: "string", value: "fn" }), _ident142, _line143] }))); runtime.popCall(); return _sym_id144; ; @@ -625,10 +627,10 @@ return { type: "null" }; }; function _define_param39(_ident145, _line146) { runtime.pushCall("define_param"); -const r_176 = (runtime.setLine(401), _sym_id_count49()); +const r_176 = (runtime.setLine(402), _sym_id_count49()); let _sym_id147 = r_176; -(runtime.setLine(402), _sym_id_increment50()); -(runtime.setLine(404), _define_sym44(_ident145, ({ type: "list", values: [_sym_id147, ({ type: "string", value: "param" }), _ident145, _line146] }))); +(runtime.setLine(403), _sym_id_increment50()); +(runtime.setLine(405), _define_sym44(_ident145, ({ type: "list", values: [_sym_id147, ({ type: "string", value: "param" }), _ident145, _line146] }))); runtime.popCall(); return _sym_id147; ; @@ -637,10 +639,10 @@ return { type: "null" }; }; function _define_let40(_ident148, _line149) { runtime.pushCall("define_let"); -const r_177 = (runtime.setLine(409), _sym_id_count49()); +const r_177 = (runtime.setLine(410), _sym_id_count49()); let _sym_id150 = r_177; -(runtime.setLine(410), _sym_id_increment50()); -(runtime.setLine(412), _define_sym44(_ident148, ({ type: "list", values: [_sym_id150, ({ type: "string", value: "let" }), _ident148, _line149] }))); +(runtime.setLine(411), _sym_id_increment50()); +(runtime.setLine(413), _define_sym44(_ident148, ({ type: "list", values: [_sym_id150, ({ type: "string", value: "let" }), _ident148, _line149] }))); runtime.popCall(); return _sym_id150; ; @@ -709,20 +711,20 @@ let _map165 = r_185; const r_186 = ({ type: "int", value: 0 }); let _i166 = r_186; while (true) { -if (runtime.truthy(runtime.opGte(_i166, (runtime.setLine(449), ((...args) => runtime.builtinLen(...args))(_map165))))) { +if (runtime.truthy(runtime.opGte(_i166, (runtime.setLine(450), ((...args) => runtime.builtinLen(...args))(_map165))))) { break}; -const r_187 = (runtime.setLine(450), ((...args) => runtime.builtinAt(...args))(_map165, _i166)); +const r_187 = (runtime.setLine(451), ((...args) => runtime.builtinAt(...args))(_map165, _i166)); const r_188 = r_187.values[0] ?? { type: "null"}; let _s_ident167 = r_188; const r_189 = r_187.values[1] ?? { type: "null"}; if (runtime.truthy(runtime.opEq(_ident163, _s_ident167))) { -(runtime.setLine(452), ((...args) => runtime.builtinSet(...args))(_map165, _i166, ({ type: "list", values: [_ident163, _sym164] }))); +(runtime.setLine(453), ((...args) => runtime.builtinSet(...args))(_map165, _i166, ({ type: "list", values: [_ident163, _sym164] }))); runtime.popCall(); return { type: "null" }; }; (_i166 = runtime.opAdd(_i166, ({ type: "int", value: 1 }))); }; -(runtime.setLine(457), ((...args) => runtime.builtinPush(...args))(_map165, ({ type: "list", values: [_ident163, _sym164] }))); +(runtime.setLine(458), ((...args) => runtime.builtinPush(...args))(_map165, ({ type: "list", values: [_ident163, _sym164] }))); ; runtime.popCall(); return { type: "null" }; @@ -737,9 +739,9 @@ let _map171 = r_192; const r_193 = ({ type: "int", value: 0 }); let _i172 = r_193; while (true) { -if (runtime.truthy(runtime.opGte(_i172, (runtime.setLine(464), ((...args) => runtime.builtinLen(...args))(_map171))))) { +if (runtime.truthy(runtime.opGte(_i172, (runtime.setLine(465), ((...args) => runtime.builtinLen(...args))(_map171))))) { break}; -const r_194 = (runtime.setLine(465), ((...args) => runtime.builtinAt(...args))(_map171, _i172)); +const r_194 = (runtime.setLine(466), ((...args) => runtime.builtinAt(...args))(_map171, _i172)); const r_195 = r_194.values[0] ?? { type: "null"}; let _s_ident173 = r_195; const r_196 = r_194.values[1] ?? { type: "null"}; @@ -752,7 +754,7 @@ return _s_sym174; }; if (runtime.truthy(runtime.opNe(_parent170, ({ type: "null" })))) { runtime.popCall(); -return (runtime.setLine(472), _find_sym157(_parent170, _ident169)); +return (runtime.setLine(473), _find_sym157(_parent170, _ident169)); }; runtime.popCall(); return ({ type: "null" }); @@ -763,7 +765,7 @@ return { type: "null" }; function _get158(_ident175) { runtime.pushCall("get"); runtime.popCall(); -return (runtime.setLine(478), _find_sym157(_syms161, _ident175)); +return (runtime.setLine(479), _find_sym157(_syms161, _ident175)); ; runtime.popCall(); return { type: "null" }; @@ -780,10 +782,10 @@ const r_201 = r_200.values[0] ?? { type: "null"}; let _ident180 = r_201; const r_202 = r_200.values[1] ?? { type: "null"}; let _sym181 = r_202; -(runtime.setLine(484), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%- %: %" }), (runtime.setLine(484), _indent23(_depth177)), _ident180, _sym181)); +(runtime.setLine(485), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%- %: %" }), (runtime.setLine(485), _indent23(_depth177)), _ident180, _sym181)); }; if (runtime.truthy(runtime.opNe(_parent178, ({ type: "null" })))) { -(runtime.setLine(487), _print_syms_node159(_parent178, runtime.opAdd(_depth177, ({ type: "int", value: 1 })))); +(runtime.setLine(488), _print_syms_node159(_parent178, runtime.opAdd(_depth177, ({ type: "int", value: 1 })))); }; ; runtime.popCall(); @@ -791,7 +793,7 @@ return { type: "null" }; }; function _print_syms160() { runtime.pushCall("print_syms"); -(runtime.setLine(492), _print_syms_node159(_syms161, ({ type: "int", value: 0 }))); +(runtime.setLine(493), _print_syms_node159(_syms161, ({ type: "int", value: 0 }))); ; runtime.popCall(); return { type: "null" }; @@ -804,7 +806,7 @@ return { type: "null" }; }; function _string_escape17(_str182) { runtime.pushCall("string_escape"); -const r_203 = (runtime.setLine(506), ((...args) => runtime.builtinLen(...args))(_str182)); +const r_203 = (runtime.setLine(507), ((...args) => runtime.builtinLen(...args))(_str182)); let _str_len183 = r_203; const r_204 = ({ type: "int", value: 0 }); let _i184 = r_204; @@ -813,7 +815,7 @@ let _result185 = r_205; while (true) { if (runtime.truthy(runtime.opGte(_i184, _str_len183))) { break}; -const r_206 = (runtime.setLine(511), ((...args) => runtime.builtinAt(...args))(_str182, _i184)); +const r_206 = (runtime.setLine(512), ((...args) => runtime.builtinAt(...args))(_str182, _i184)); let _ch186 = r_206; if (runtime.truthy(runtime.opEq(_ch186, ({ type: "string", value: "\\" })))) { (_result185 = runtime.opAdd(_result185, ({ type: "string", value: "\\\\" }))); @@ -847,16 +849,16 @@ function _Parser18(_tokens187) { runtime.pushCall("Parser"); const r_207 = ({ type: "int", value: 0 }); let _i194 = r_207; -const r_208 = (runtime.setLine(534), ((...args) => runtime.builtinAt(...args))(_tokens187, _i194)); +const r_208 = (runtime.setLine(535), ((...args) => runtime.builtinAt(...args))(_tokens187, _i194)); let _tok195 = r_208; function _parse188() { runtime.pushCall("parse"); const r_209 = ({ type: "list", values: [] }); let _exprs196 = r_209; while (true) { -if (runtime.truthy((runtime.setLine(539), _done193()))) { +if (runtime.truthy((runtime.setLine(540), _done193()))) { break}; -(runtime.setLine(540), ((...args) => runtime.builtinPush(...args))(_exprs196, (runtime.setLine(540), _parse_expr189()))); +(runtime.setLine(541), ((...args) => runtime.builtinPush(...args))(_exprs196, (runtime.setLine(541), _parse_expr189()))); }; runtime.popCall(); return _exprs196; @@ -873,33 +875,33 @@ const r_212 = r_210.values[1] ?? { type: "null"}; let _line198 = r_212; const r_213 = r_210.values[2] ?? { type: "null"}; let _value199 = r_213; -if (runtime.truthy((runtime.setLine(547), _eat190(({ type: "string", value: "(" }))))) { +if (runtime.truthy((runtime.setLine(548), _eat190(({ type: "string", value: "(" }))))) { const r_214 = ({ type: "list", values: [] }); let _values200 = r_214; while (true) { -if (runtime.truthy((runtime.setLine(550), _test192(({ type: "string", value: ")" }))))) { +if (runtime.truthy((runtime.setLine(551), _test192(({ type: "string", value: ")" }))))) { break}; -(runtime.setLine(551), ((...args) => runtime.builtinPush(...args))(_values200, (runtime.setLine(551), _parse_expr189()))); +(runtime.setLine(552), ((...args) => runtime.builtinPush(...args))(_values200, (runtime.setLine(552), _parse_expr189()))); }; -if (runtime.truthy(runtime.opNot((runtime.setLine(553), _eat190(({ type: "string", value: ")" })))))) { -(runtime.setLine(554), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "expected ')' on line %" }), (runtime.setLine(554), ((...args) => runtime.builtinAt(...args))(_tok195, ({ type: "int", value: 1 }))))); +if (runtime.truthy(runtime.opNot((runtime.setLine(554), _eat190(({ type: "string", value: ")" })))))) { +(runtime.setLine(555), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "expected ')' on line %" }), (runtime.setLine(555), ((...args) => runtime.builtinAt(...args))(_tok195, ({ type: "int", value: 1 }))))); }; runtime.popCall(); return ({ type: "list", values: [({ type: "string", value: "list" }), _line198, _values200] }); } else { -if (runtime.truthy((runtime.setLine(557), _eat190(({ type: "string", value: "string" }))))) { +if (runtime.truthy((runtime.setLine(558), _eat190(({ type: "string", value: "string" }))))) { runtime.popCall(); return ({ type: "list", values: [({ type: "string", value: "string" }), _line198, _value199] }); } else { -if (runtime.truthy((runtime.setLine(559), _eat190(({ type: "string", value: "int" }))))) { +if (runtime.truthy((runtime.setLine(560), _eat190(({ type: "string", value: "int" }))))) { runtime.popCall(); -return ({ type: "list", values: [({ type: "string", value: "int" }), _line198, (runtime.setLine(560), ((...args) => runtime.builtinStringToInt(...args))(_value199))] }); +return ({ type: "list", values: [({ type: "string", value: "int" }), _line198, (runtime.setLine(561), ((...args) => runtime.builtinStringToInt(...args))(_value199))] }); } else { -if (runtime.truthy((runtime.setLine(561), _eat190(({ type: "string", value: "ident" }))))) { +if (runtime.truthy((runtime.setLine(562), _eat190(({ type: "string", value: "ident" }))))) { runtime.popCall(); return ({ type: "list", values: [({ type: "string", value: "ident" }), _line198, _value199] }); } else { -(runtime.setLine(564), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "expected expression, got '%' on line %" }), _ty197, _line198)); +(runtime.setLine(565), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "expected expression, got '%' on line %" }), _ty197, _line198)); }}}}; ; runtime.popCall(); @@ -907,10 +909,10 @@ return { type: "null" }; }; function _eat190(_pat201) { runtime.pushCall("eat"); -if (runtime.truthy(runtime.opNot((runtime.setLine(569), _test192(_pat201))))) { +if (runtime.truthy(runtime.opNot((runtime.setLine(570), _test192(_pat201))))) { runtime.popCall(); return ({ type: "bool", value: false })}; -(runtime.setLine(570), _step191()); +(runtime.setLine(571), _step191()); runtime.popCall(); return ({ type: "bool", value: true }); ; @@ -920,8 +922,8 @@ return { type: "null" }; function _step191() { runtime.pushCall("step"); (_i194 = runtime.opAdd(_i194, ({ type: "int", value: 1 }))); -if (runtime.truthy(runtime.opNot((runtime.setLine(576), _done193())))) { -const r_215 = (runtime.setLine(577), ((...args) => runtime.builtinAt(...args))(_tokens187, _i194)); +if (runtime.truthy(runtime.opNot((runtime.setLine(577), _done193())))) { +const r_215 = (runtime.setLine(578), ((...args) => runtime.builtinAt(...args))(_tokens187, _i194)); let _new_tok202 = r_215; (_tok195 = _new_tok202); }; @@ -931,7 +933,7 @@ return { type: "null" }; }; function _test192(_pat203) { runtime.pushCall("test"); -if (runtime.truthy((runtime.setLine(583), _done193()))) { +if (runtime.truthy((runtime.setLine(584), _done193()))) { runtime.popCall(); return ({ type: "bool", value: false })}; const r_216 = _tok195; @@ -946,7 +948,7 @@ return { type: "null" }; function _done193() { runtime.pushCall("done"); runtime.popCall(); -return runtime.opGte(_i194, (runtime.setLine(589), ((...args) => runtime.builtinLen(...args))(_tokens187))); +return runtime.opGte(_i194, (runtime.setLine(590), ((...args) => runtime.builtinLen(...args))(_tokens187))); ; runtime.popCall(); return { type: "null" }; @@ -959,7 +961,7 @@ return { type: "null" }; }; function _tokenize19(_text205) { runtime.pushCall("tokenize"); -const r_218 = (runtime.setLine(596), ((...args) => runtime.builtinLen(...args))(_text205)); +const r_218 = (runtime.setLine(597), ((...args) => runtime.builtinLen(...args))(_text205)); let _text_len206 = r_218; const r_219 = ({ type: "list", values: [] }); let _tokens207 = r_219; @@ -972,33 +974,33 @@ let _ident_chars210 = r_222; while (true) { if (runtime.truthy(runtime.opGte(_i208, _text_len206))) { break}; -const r_223 = (runtime.setLine(608), ((...args) => runtime.builtinAt(...args))(_text205, _i208)); +const r_223 = (runtime.setLine(609), ((...args) => runtime.builtinAt(...args))(_text205, _i208)); let _ch211 = r_223; -if (runtime.truthy((runtime.setLine(610), _contains20(({ type: "string", value: " \t\r\n" }), _ch211)))) { +if (runtime.truthy((runtime.setLine(611), _contains20(({ type: "string", value: " \t\r\n" }), _ch211)))) { if (runtime.truthy(runtime.opEq(_ch211, ({ type: "string", value: "\n" })))) { (_line209 = runtime.opAdd(_line209, ({ type: "int", value: 1 }))); }; (_i208 = runtime.opAdd(_i208, ({ type: "int", value: 1 }))); } else { -if (runtime.truthy((runtime.setLine(615), _slice_eq21(_text205, _i208, ({ type: "string", value: "//" }))))) { +if (runtime.truthy((runtime.setLine(616), _slice_eq21(_text205, _i208, ({ type: "string", value: "//" }))))) { while (true) { -if (runtime.truthy((runtime.setLine(617), { type: "bool", value: runtime.truthy(runtime.opGte(_i208, _text_len206)) || runtime.truthy(runtime.opEq((runtime.setLine(617), ((...args) => runtime.builtinAt(...args))(_text205, _i208)), ({ type: "string", value: "\n" }))) }))) { +if (runtime.truthy((runtime.setLine(618), { type: "bool", value: runtime.truthy(runtime.opGte(_i208, _text_len206)) || runtime.truthy(runtime.opEq((runtime.setLine(618), ((...args) => runtime.builtinAt(...args))(_text205, _i208)), ({ type: "string", value: "\n" }))) }))) { break; }; (_i208 = runtime.opAdd(_i208, ({ type: "int", value: 1 }))); }; } else { -if (runtime.truthy((runtime.setLine(622), _contains20(({ type: "string", value: "()" }), _ch211)))) { -(runtime.setLine(623), ((...args) => runtime.builtinPush(...args))(_tokens207, ({ type: "list", values: [_ch211, _line209] }))); +if (runtime.truthy((runtime.setLine(623), _contains20(({ type: "string", value: "()" }), _ch211)))) { +(runtime.setLine(624), ((...args) => runtime.builtinPush(...args))(_tokens207, ({ type: "list", values: [_ch211, _line209] }))); (_i208 = runtime.opAdd(_i208, ({ type: "int", value: 1 }))); } else { if (runtime.truthy(runtime.opEq(_ch211, ({ type: "string", value: "\"" })))) { const r_224 = ({ type: "string", value: "" }); let _value212 = r_224; (_i208 = runtime.opAdd(_i208, ({ type: "int", value: 1 }))); -(_ch211 = (runtime.setLine(628), ((...args) => runtime.builtinAt(...args))(_text205, _i208))); +(_ch211 = (runtime.setLine(629), ((...args) => runtime.builtinAt(...args))(_text205, _i208))); while (true) { -if (runtime.truthy((runtime.setLine(630), { type: "bool", value: runtime.truthy(runtime.opGte(_i208, _text_len206)) || runtime.truthy(runtime.opEq(_ch211, ({ type: "string", value: "\"" }))) }))) { +if (runtime.truthy((runtime.setLine(631), { type: "bool", value: runtime.truthy(runtime.opGte(_i208, _text_len206)) || runtime.truthy(runtime.opEq(_ch211, ({ type: "string", value: "\"" }))) }))) { break; }; if (runtime.truthy(runtime.opEq(_ch211, ({ type: "string", value: "\\" })))) { @@ -1006,7 +1008,7 @@ if (runtime.truthy(runtime.opEq(_ch211, ({ type: "string", value: "\\" })))) { if (runtime.truthy(runtime.opGte(_i208, _text_len206))) { break; }; -(_ch211 = (runtime.setLine(638), ((...args) => runtime.builtinAt(...args))(_text205, _i208))); +(_ch211 = (runtime.setLine(639), ((...args) => runtime.builtinAt(...args))(_text205, _i208))); if (runtime.truthy(runtime.opEq(_ch211, ({ type: "string", value: "t" })))) { (_value212 = runtime.opAdd(_value212, ({ type: "string", value: "\t" }))); } else { @@ -1025,41 +1027,41 @@ if (runtime.truthy(runtime.opEq(_ch211, ({ type: "string", value: "0" })))) { (_value212 = runtime.opAdd(_value212, _ch211)); }; (_i208 = runtime.opAdd(_i208, ({ type: "int", value: 1 }))); -(_ch211 = (runtime.setLine(654), ((...args) => runtime.builtinAt(...args))(_text205, _i208))); +(_ch211 = (runtime.setLine(655), ((...args) => runtime.builtinAt(...args))(_text205, _i208))); }; -if (runtime.truthy((runtime.setLine(656), { type: "bool", value: runtime.truthy(runtime.opGte(_i208, _text_len206)) || runtime.truthy(runtime.opNe(_ch211, ({ type: "string", value: "\"" }))) }))) { -(runtime.setLine(657), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "expected '\"' on line %" }), _line209)); +if (runtime.truthy((runtime.setLine(657), { type: "bool", value: runtime.truthy(runtime.opGte(_i208, _text_len206)) || runtime.truthy(runtime.opNe(_ch211, ({ type: "string", value: "\"" }))) }))) { +(runtime.setLine(658), ((...args) => runtime.builtinPanic(...args))(({ type: "string", value: "expected '\"' on line %" }), _line209)); }; (_i208 = runtime.opAdd(_i208, ({ type: "int", value: 1 }))); -(runtime.setLine(660), ((...args) => runtime.builtinPush(...args))(_tokens207, ({ type: "list", values: [({ type: "string", value: "string" }), _line209, _value212] }))); +(runtime.setLine(661), ((...args) => runtime.builtinPush(...args))(_tokens207, ({ type: "list", values: [({ type: "string", value: "string" }), _line209, _value212] }))); } else { -if (runtime.truthy((runtime.setLine(661), _contains20(({ type: "string", value: "0123456789" }), _ch211)))) { +if (runtime.truthy((runtime.setLine(662), _contains20(({ type: "string", value: "0123456789" }), _ch211)))) { const r_225 = ({ type: "string", value: "" }); let _value213 = r_225; while (true) { -(_ch211 = (runtime.setLine(664), ((...args) => runtime.builtinAt(...args))(_text205, _i208))); -if (runtime.truthy((runtime.setLine(665), { type: "bool", value: runtime.truthy(runtime.opGte(_i208, _text_len206)) || runtime.truthy(runtime.opNot((runtime.setLine(665), _contains20(({ type: "string", value: "0123456789" }), _ch211)))) }))) { +(_ch211 = (runtime.setLine(665), ((...args) => runtime.builtinAt(...args))(_text205, _i208))); +if (runtime.truthy((runtime.setLine(666), { type: "bool", value: runtime.truthy(runtime.opGte(_i208, _text_len206)) || runtime.truthy(runtime.opNot((runtime.setLine(666), _contains20(({ type: "string", value: "0123456789" }), _ch211)))) }))) { break; }; (_value213 = runtime.opAdd(_value213, _ch211)); (_i208 = runtime.opAdd(_i208, ({ type: "int", value: 1 }))); }; -(runtime.setLine(671), ((...args) => runtime.builtinPush(...args))(_tokens207, ({ type: "list", values: [({ type: "string", value: "int" }), _line209, _value213] }))); +(runtime.setLine(672), ((...args) => runtime.builtinPush(...args))(_tokens207, ({ type: "list", values: [({ type: "string", value: "int" }), _line209, _value213] }))); } else { -if (runtime.truthy((runtime.setLine(672), _contains20(_ident_chars210, _ch211)))) { +if (runtime.truthy((runtime.setLine(673), _contains20(_ident_chars210, _ch211)))) { const r_226 = ({ type: "string", value: "" }); let _value214 = r_226; while (true) { -(_ch211 = (runtime.setLine(675), ((...args) => runtime.builtinAt(...args))(_text205, _i208))); -if (runtime.truthy((runtime.setLine(676), { type: "bool", value: runtime.truthy(runtime.opGte(_i208, _text_len206)) || runtime.truthy(runtime.opNot((runtime.setLine(676), _contains20(_ident_chars210, _ch211)))) }))) { +(_ch211 = (runtime.setLine(676), ((...args) => runtime.builtinAt(...args))(_text205, _i208))); +if (runtime.truthy((runtime.setLine(677), { type: "bool", value: runtime.truthy(runtime.opGte(_i208, _text_len206)) || runtime.truthy(runtime.opNot((runtime.setLine(677), _contains20(_ident_chars210, _ch211)))) }))) { break; }; (_value214 = runtime.opAdd(_value214, _ch211)); (_i208 = runtime.opAdd(_i208, ({ type: "int", value: 1 }))); }; -(runtime.setLine(682), ((...args) => runtime.builtinPush(...args))(_tokens207, ({ type: "list", values: [({ type: "string", value: "ident" }), _line209, _value214] }))); +(runtime.setLine(683), ((...args) => runtime.builtinPush(...args))(_tokens207, ({ type: "list", values: [({ type: "string", value: "ident" }), _line209, _value214] }))); } else { -(runtime.setLine(684), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "illegal char '%'" }), _ch211)); +(runtime.setLine(685), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "illegal char '%'" }), _ch211)); (_i208 = runtime.opAdd(_i208, ({ type: "int", value: 1 }))); }}}}}}; }; @@ -1071,14 +1073,14 @@ return { type: "null" }; }; function _contains20(_text215, _ch216) { runtime.pushCall("contains"); -const r_227 = (runtime.setLine(692), ((...args) => runtime.builtinLen(...args))(_text215)); +const r_227 = (runtime.setLine(693), ((...args) => runtime.builtinLen(...args))(_text215)); let _text_len217 = r_227; const r_228 = ({ type: "int", value: 0 }); let _i218 = r_228; while (true) { if (runtime.truthy(runtime.opGte(_i218, _text_len217))) { break}; -if (runtime.truthy(runtime.opEq((runtime.setLine(696), ((...args) => runtime.builtinAt(...args))(_text215, _i218)), _ch216))) { +if (runtime.truthy(runtime.opEq((runtime.setLine(697), ((...args) => runtime.builtinAt(...args))(_text215, _i218)), _ch216))) { runtime.popCall(); return ({ type: "bool", value: true }); }; @@ -1092,9 +1094,9 @@ return { type: "null" }; }; function _slice_eq21(_str219, _slice_idx220, _substr221) { runtime.pushCall("slice_eq"); -const r_229 = (runtime.setLine(705), ((...args) => runtime.builtinLen(...args))(_str219)); +const r_229 = (runtime.setLine(706), ((...args) => runtime.builtinLen(...args))(_str219)); let _str_len222 = r_229; -const r_230 = (runtime.setLine(706), ((...args) => runtime.builtinLen(...args))(_substr221)); +const r_230 = (runtime.setLine(707), ((...args) => runtime.builtinLen(...args))(_substr221)); let _substr_len223 = r_230; const r_231 = ({ type: "int", value: 0 }); let _i224 = r_231; @@ -1105,7 +1107,7 @@ return ({ type: "bool", value: true })}; if (runtime.truthy(runtime.opGte(runtime.opAdd(_slice_idx220, _i224), _str_len222))) { runtime.popCall(); return ({ type: "bool", value: false })}; -if (runtime.truthy(runtime.opNe((runtime.setLine(713), ((...args) => runtime.builtinAt(...args))(_str219, runtime.opAdd(_slice_idx220, _i224))), (runtime.setLine(713), ((...args) => runtime.builtinAt(...args))(_substr221, _i224))))) { +if (runtime.truthy(runtime.opNe((runtime.setLine(714), ((...args) => runtime.builtinAt(...args))(_str219, runtime.opAdd(_slice_idx220, _i224))), (runtime.setLine(714), ((...args) => runtime.builtinAt(...args))(_substr221, _i224))))) { runtime.popCall(); return ({ type: "bool", value: false })}; (_i224 = runtime.opAdd(_i224, ({ type: "int", value: 1 }))); @@ -1126,14 +1128,14 @@ let _line228 = r_234; const r_235 = r_232.values[2] ?? { type: "null"}; let _value229 = r_235; if (runtime.truthy(runtime.opEq(_ty227, ({ type: "string", value: "list" })))) { -(runtime.setLine(723), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%(% %" }), (runtime.setLine(723), _indent23(_depth226)), _ty227, _line228)); +(runtime.setLine(724), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%(% %" }), (runtime.setLine(724), _indent23(_depth226)), _ty227, _line228)); for (const r_236 of _value229.values) {; let _e230 = r_236; -(runtime.setLine(725), _print_expr22(_e230, runtime.opAdd(_depth226, ({ type: "int", value: 1 })))); +(runtime.setLine(726), _print_expr22(_e230, runtime.opAdd(_depth226, ({ type: "int", value: 1 })))); }; -(runtime.setLine(727), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%)" }), (runtime.setLine(727), _indent23(_depth226)))); +(runtime.setLine(728), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%)" }), (runtime.setLine(728), _indent23(_depth226)))); } else { -(runtime.setLine(729), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%%" }), (runtime.setLine(729), _indent23(_depth226)), _expr225)); +(runtime.setLine(730), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "%%" }), (runtime.setLine(730), _indent23(_depth226)), _expr225)); }; ; runtime.popCall(); @@ -1159,7 +1161,7 @@ return { type: "null" }; }; function _slice24(_list234, _idx235) { runtime.pushCall("slice"); -const r_239 = (runtime.setLine(745), ((...args) => runtime.builtinLen(...args))(_list234)); +const r_239 = (runtime.setLine(746), ((...args) => runtime.builtinLen(...args))(_list234)); let _list_len236 = r_239; const r_240 = ({ type: "list", values: [] }); let _elems237 = r_240; @@ -1168,7 +1170,7 @@ let _i238 = r_241; while (true) { if (runtime.truthy(runtime.opGte(_i238, _list_len236))) { break}; -(runtime.setLine(750), ((...args) => runtime.builtinPush(...args))(_elems237, (runtime.setLine(750), ((...args) => runtime.builtinAt(...args))(_list234, _i238)))); +(runtime.setLine(751), ((...args) => runtime.builtinPush(...args))(_elems237, (runtime.setLine(751), ((...args) => runtime.builtinAt(...args))(_list234, _i238)))); (_i238 = runtime.opAdd(_i238, ({ type: "int", value: 1 }))); }; runtime.popCall(); @@ -1179,37 +1181,39 @@ return { type: "null" }; }; const r_242 = ({ type: "bool", value: false }); let _silent239 = r_242; -const r_243 = (runtime.setLine(758), ((...args) => runtime.builtinGetArgs(...args))()); +const r_243 = (runtime.setLine(759), ((...args) => runtime.builtinGetArgs(...args))()); const r_244 = r_243.values[0] ?? { type: "null"}; let _input_filename240 = r_244; const r_245 = r_243.values[1] ?? { type: "null"}; let _output_filename241 = r_245; if (runtime.truthy(runtime.opNot(_silent239))) { -(runtime.setLine(760), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "reading file '%'..." }), _input_filename240))}; -const r_246 = (runtime.setLine(761), ((...args) => runtime.builtinReadTextFile(...args))(_input_filename240)); +(runtime.setLine(761), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "reading file '%'..." }), _input_filename240))}; +const r_246 = (runtime.setLine(762), ((...args) => runtime.builtinReadTextFile(...args))(_input_filename240)); let _text242 = r_246; if (runtime.truthy(runtime.opNot(_silent239))) { -(runtime.setLine(767), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "tokenizing..." })))}; -const r_247 = (runtime.setLine(768), _tokenize19(_text242)); +(runtime.setLine(768), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "tokenizing..." })))}; +const r_247 = (runtime.setLine(769), _tokenize19(_text242)); let _tokens243 = r_247; if (runtime.truthy(runtime.opNot(_silent239))) { -(runtime.setLine(781), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "parsing..." })))}; -const r_248 = (runtime.setLine(782), _Parser18(_tokens243)); +(runtime.setLine(782), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "parsing..." })))}; +const r_248 = (runtime.setLine(783), _Parser18(_tokens243)); let _parser244 = r_248; const r_249 = _parser244; const r_250 = r_249.values[0] ?? { type: "null"}; let _parse245 = r_250; -const r_251 = (runtime.setLine(784), _parse245()); +const r_251 = (runtime.setLine(785), _parse245()); let _ast246 = r_251; if (runtime.truthy(runtime.opNot(_silent239))) { -(runtime.setLine(791), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "emitting..." })))}; -const r_252 = (runtime.setLine(792), _Emitter14(_ast246, _input_filename240)); +(runtime.setLine(792), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "emitting..." })))}; +const r_252 = (runtime.setLine(793), _Emitter14(_ast246, _input_filename240)); let _emitter247 = r_252; const r_253 = _emitter247; const r_254 = r_253.values[0] ?? { type: "null"}; let _emit248 = r_254; -const r_255 = (runtime.setLine(794), _emit248()); +const r_255 = (runtime.setLine(795), _emit248()); let _js_code249 = r_255; +(runtime.setLine(797), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "=== js ===" }))); +(runtime.setLine(798), ((...args) => runtime.builtinPrintln(...args))(_js_code249)); if (runtime.truthy(runtime.opNot(_silent239))) { -(runtime.setLine(799), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "writing file '%'..." }), _output_filename241))}; -(runtime.setLine(800), ((...args) => runtime.builtinWriteTextFile(...args))(_output_filename241, _js_code249)); +(runtime.setLine(800), ((...args) => runtime.builtinPrintln(...args))(({ type: "string", value: "writing file '%'..." }), _output_filename241))}; +(runtime.setLine(801), ((...args) => runtime.builtinWriteTextFile(...args))(_output_filename241, _js_code249));