Libraryless. Click here for Pure Java version (628L/5K/15K).
!752 static O interpret(S java) { ret new JavaInterpreter().interpret(java); } // to trigger function inclusion static void dummy() { eq(null, null); collapseWord(null); } static class JavaInterpreter { int i; L<S> tok; L<S> allowedFunctions = litlist("eq", "collapseWord"); O interpret(S java) { i = 1; tok = javaTok(java); if (litlist("ret", "returns").contains(get(tok, i))) { i += 2; O result = expression(); consume(";"); ret result; } throw fail("huh? " + i + " " + get(tok, i)); } void consume(S x) { assertEquals(get(tok, i), x); i += 2; } S consume() { S t = t(); assertNotNull(t); i += 2; ret t; } S t() { ret get(tok, i); } O expression() { if (isQuoted(t())) ret unquote(consume()); if (isIdentifier(t())) { S fname = consume(); consume("("); new L args; while (neq(t(), ")")) { args.add(expression()); if (eq(t(), ",")) consume(); } consume(")"); ret call(mainClass(), fname, toObjectArray(args)); } throw fail(t()); } }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002015 |
Snippet name: | Java Interpreter (hotwirable) |
Eternal ID of this version: | #1002015/1 |
Text MD5: | 0af211027b0c00b87d68af2a84a605e9 |
Transpilation MD5: | e9d7b9c8518ab6fe24c691dd73b1aa74 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-12-13 19:12:44 |
Source code size: | 1215 bytes / 65 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 641 / 955 |
Referenced in: | [show references] |