Libraryless. Click here for Pure Java version (4842L/33K/107K).
!759 static Class parser; p { print("parser bot loading"); parser = hotwire_overBot("#1002719"); print("parser bot loaded"); makeBot(); } answer { // turing-testable! if "does * parse as * with rules *" exceptionToUser { S text = m.unq(0); S className = m.unq(1); S rules = m.unq(2); ret doesParse(text, className, rules); } if "does * jparse as *" exceptionToUser { S text = m.unq(0); S className = m.unq(1); S rules = "#1002329"; // Java parsing rules ret doesParse(text, className, rules); } if "parse * with rules *" exceptionToUser { S text = m.unq(0); S rules = m.unq(1); S explainClass = null; O result; time { result = call(parser, "parse", text, rules); } /*if (debug) ret "```" + call(result, "prettierAnalysis") + "```"; else if (explain) ret structure(call(result, "explain", explainClass)); else*/ { L<S> classes = cast call(result, "fullMatchClasses"); ret (empty(classes) ? "not parsed" : "parsed as " + structure(classes)) + " [" + getLastTiming() + " ms, " + getOpt(parser, "timing") + " ms actual]"; } } } static S doesParse(S text, S className, S rules) { O result; L<S> classes; time { result = call(parser, "parse", text, rules); classes = (L) call(result, "fullMatchClasses"); } S answer = classes.contains(className) ? "yes" : "no"; S timing = " [" + getLastTiming() + " ms]"; ret answer + timing; }
Began life as a copy of #1002372
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment