Libraryless. Click here for Pure Java version (4525L/29K/93K).
!759 static S codeSnippetID = "#1002758"; static Lisp code; static new L<Lisp> memory; static LogicEngine engine; !include #1002759 // LogicEngine static class MyEngine extends LogicEngine { *(Lisp code, L<Lisp> memory) { super(code, memory); } public boolean yo(Lisp snl, SNLMatches m) { if (super.yo(snl, m)) ret true; new SNLMatches mInner; if (snlMatch2("[the > length < of < string < S] < is < L < characters", snl, mInner)) { // TODO: variable renaming? S s = snlGetString(mInner.map, "S"); putMatchX(m.map, mInner.map, "L", lstr(s)); ret true; } ret false; } } p { code = snlToTree(loadSnippet(codeSnippetID)); print(getProgramID() + ": parse result = " + code); load("memory"); } synchronized answer { if (!attn()) ret null; if (match("log " + parseSnippetID(programID()), s)) ret engine == null ? "nullie haven't run yet": slackSnippet(fromLines(engine.log)); if (match("memory " + parseSnippetID(programID()), s)) ret slackSnippet(snlAllToText(memory)); // convert to SNL first s = or((S) callOpt/*Safe*/(getBot ("#1002700"), "naiveSNL", s), s); Lisp in = snlToTree(s); Lisp statement = snlToTree("user < says < [" + snlFromTree(in) + "]"); engine = new MyEngine(code, memory) { void saveMemory() { save("memory"); } }; engine.stmAdd(statement); L<Lisp> out = engine.run(); if (nempty(out)) ret "[SNL: " + snlFromTree(in) + "])\n" + snlAllToText(out); } static Lisp quickrun(L<Lisp> memory, S userInput) { engine = new LogicEngine(code, memory); Lisp statement = snlToTree("user < says < [" + userInput + "]"); engine.stmAdd(statement); ret snlMakeJuxta(engine.run()); }
Began life as a copy of #1002751
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment