X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fxwt%2Fjs%2FInterpreter.java;fp=src%2Forg%2Fxwt%2Fjs%2FInterpreter.java;h=32bf03eae825f1af691e4ea55cb7c29f82ef4d96;hb=434205ebc29c9da561a6c1cd4f869cc6d2b9bec4;hp=ae8dc1f5de4fa4ca416014ca8cc2eb1e4480d356;hpb=96cc912c45623abf8a8a37d7c1d6103e5fe58bd5;p=org.ibex.core.git diff --git a/src/org/xwt/js/Interpreter.java b/src/org/xwt/js/Interpreter.java index ae8dc1f..32bf03e 100644 --- a/src/org/xwt/js/Interpreter.java +++ b/src/org/xwt/js/Interpreter.java @@ -356,6 +356,28 @@ class Interpreter implements ByteCodes, Tokens { case THROW: throw new JSExn(stack.pop()); + case MAKE_GRAMMAR: { + final Grammar r = (Grammar)arg; + final JSScope final_scope = scope; + Grammar r2 = new Grammar() { + public int match(String s, int start, Hash v, JSScope scope) throws JSExn { + return r.match(s, start, v, final_scope); + } + public int matchAndWrite(String s, int start, Hash v, JSScope scope, String key) throws JSExn { + return r.matchAndWrite(s, start, v, final_scope, key); + } + public Object call(Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JSExn { + Hash v = new Hash(); + r.matchAndWrite((String)a0, 0, v, final_scope, "foo"); + return v.get("foo"); + } + }; + Object obj = stack.pop(); + if (obj != null && obj instanceof Grammar) r2 = new Grammar.Alternative((Grammar)obj, r2); + stack.push(r2); + break; + } + case ASSIGN_SUB: case ASSIGN_ADD: { Object val = stack.pop(); Object key = stack.pop();