diff --git a/cc.bqn b/cc.bqn index f670deff..2ea22df8 100755 --- a/cc.bqn +++ b/cc.bqn @@ -54,12 +54,13 @@ RT ← { CArg ← {J (¯5⊸↓∾𝕩˙)⌾⊑ FLines "c.bqn"} SVG ← {∾⟨"Modify←GetHighlights←⊢⋄"⟩∾ FChars∘∾⟜".bqn"¨ "../svg"‿𝕩} -(@+10)∾˜ •Out⍟(¬return) (⊑"r"‿"r0"‿"r1"‿"c"‿"cc"‿"f"‿"e"‿"p"⊐⊏)◶⟨ +(@+10)∾˜ •Out⍟(¬return) (⊑"r"‿"r0"‿"r1"‿"c"‿"cc"‿"f"‿"e"‿"eu"‿"p"⊐⊏)◶⟨ RT∘2, RT∘0, RT∘1 {𝕩⋄LFC CArg "⟨"∾"⟩"«∾","⊸∾¨'"'(⊣∾∾˜)¨glyphs} {𝕩⋄LFC "{"∾"}"∾˜CArg"𝕩"} {𝕩⋄LFC FChars "f.bqn"} {𝕩⋄LFC SVG "e"} + {𝕩⋄LFC FChars "eu.bqn"} {𝕩⋄LFC SVG "p"} ∾LFC¨ # ¯1 ↓ · J L∘Fout∘Comp¨ diff --git a/genRuntime b/genRuntime index 1591902b..45182f54 100755 --- a/genRuntime +++ b/genRuntime @@ -9,4 +9,5 @@ CC ← {𝕨 •FChars ⟨1,path,𝕩⟩ •Import "cc.bqn"} "src/gen/runtime0"CC"r0" "src/gen/runtime1"CC"r1" "src/gen/formatter"CC"f" +"src/gen/explain"CC"eu" "src/gen/customRuntime"•FChars"" diff --git a/src/h.h b/src/h.h index 14aebb33..a4376cce 100644 --- a/src/h.h +++ b/src/h.h @@ -346,6 +346,7 @@ B m_str32(u32* s); // meant to be used as m_str32(U"{𝕨‿𝕩}"), so doesn't B bqn_exec(B str, B path, B args); // consumes all B bqn_execFile(B path, B args); // consumes +B bqn_explain(B str, B path); // consumes str B bqn_fmt(B x); // consumes B bqn_repr(B x); // consumes diff --git a/src/load.c b/src/load.c index 69f35fb4..6bcd11c6 100644 --- a/src/load.c +++ b/src/load.c @@ -130,6 +130,7 @@ B load_compgen; B load_rtObj; B load_compArg; B load_glyphs; +B load_explain; #if FORMATTER B load_fmt, load_repr; @@ -169,6 +170,15 @@ void load_gcFn() { i64 prevEnvPos = comp_currEnvPos; comp_currEnvPos = envCurr-envStart; \ if (CATCH) { POP_COMP; rethrow(); } +B bqn_explain(B str, B path) { + B args = bi_N; + PUSH_COMP; + B c = c2(load_comp, incG(load_compArg), inc(str)); + POP_COMP; + B ret = c2(load_explain, c, str); + return ret; +} + static NOINLINE Block* bqn_compc(B str, B path, B args, B comp, B compArg) { // consumes str,path,args PUSH_COMP; Block* r = load_compObj(c2(comp, incG(compArg), inc(str)), str, path, NULL); @@ -479,6 +489,12 @@ void load_init() { // very last init function load_repr = Get(fmtR, 1); gc_add(load_repr); decG(fmtR); #endif + Block* expl_b = load_compImport("(explain)", + #include "gen/explain" + ); + load_explain = evalFunBlock(expl_b, 0); ptr_dec(expl_b); + gc_add(load_explain); + gc_enable(); #endif // PRECOMP } diff --git a/src/main.c b/src/main.c index 1505be5d..a65ea72b 100644 --- a/src/main.c +++ b/src/main.c @@ -179,6 +179,16 @@ void cbqn_runLine0(char* ln, i64 read) { } else if (isCmd(cmdS, &cmdE, "internalPrint ")) { code = utf8Decode0(cmdE); output = 2; + } else if (isCmd(cmdS, &cmdE, "e ") || isCmd(cmdS, &cmdE, "explain ")) { + B expl = bqn_explain(utf8Decode0(cmdE), inc(replPath)); + HArr* expla = toHArr(expl); + usz ia=expla->ia; + for(usz i=0; ia[i]); + putchar('\n'); + } + dec(expl); + return; } else { printf("Unknown REPL command\n"); return;