static CtxExpr ctxParseExpression(S exp) { Explain e = explain(exp, ctxParsingRules(), "exp"); if (e == null) fail("Couldn't parse expression: " + exp); ret ctxParseExpression(e); } static CtxExpr ctxParseExpression(Explain exp) { try { if (exp.is("bracket")) ret ctxParseExpression(exp.sub(0)); if (exp.is("and")) ret new CtxAnd(ctxParseSub(exp, 0), ctxParseSub(exp, 1)); if (exp.is("or")) ret new CtxOr(ctxParseSub(exp, 0), ctxParseSub(exp, 1)); if (exp.is("neg")) ret new CtxNeg(ctxParseSub(exp, 0)); if (exp.is("quoted")) ret new CtxConst(unquoteCtx(exp.tok().get(1))); //ret new CtxRegexp(unquoteCtx(exp.tok().get(1))); if (exp.is("comp")) ret new CtxComp(ctxParseSub(exp, 0), ctxParseSub(exp, 1)); if (exp.is("uneq")) ret new CtxUneq(ctxParseSub(exp, 0), ctxParseSub(exp, 1)); if (exp.is("match")) ret new CtxMatch(ctxParseSub(exp, 0), unquoteCtx(exp.str(1))); if (exp.singleEqualChild()) ret ctxParseExpression(exp.sub(0)); } catch e { printExplainTree(exp); throw rethrow(e); } throw todo(exp.className()); }