!759 static S codeSnippetID = "#1002758"; static Lisp code; static new L memory; static LogicEngine engine; !include #1002759 // LogicEngine static class MyEngine extends LogicEngine { *(Lisp code, L 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 out = engine.run(); if (nempty(out)) ret "[SNL: " + snlFromTree(in) + "])\n" + snlAllToText(out); } static Lisp quickrun(L memory, S userInput) { engine = new LogicEngine(code, memory); Lisp statement = snlToTree("user < says < [" + userInput + "]"); engine.stmAdd(statement); ret snlMakeJuxta(engine.run()); }