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(ctxParseExpression(exp.sub(0)), ctxParseExpression(exp.sub(1))); if (exp.is("or")) ret new CtxOr(ctxParseExpression(exp.sub(0)), ctxParseExpression(exp.sub(1))); if (exp.is("neg")) ret new CtxNeg(ctxParseExpression(exp.sub(0)); if (exp.is("quoted")) ret new CtxRegexp(unquoteCtx(exp.tok().get(1))); if (exp.is("comp")) ret new CtxComp(exp.str(0), exp.str(1)); if (exp.is("uneq")) ret new CtxUneq(exp.str(0), exp.str(1)); if (exp.is("match")) ret new CtxMatch(exp.str(0), unquoteCtx(exp.str(1))); if (exp.singleEqualChild()) ret ctxParseExpression(exp.sub(0)); } catch e { printExplainTree(exp); throw rethrow(e); } throw todo(exp.className()); }