Expr AndRule() { Expr expr = EqualityRule(); if (Match(AND_AND)) { Token token = Previous(); Expr right = AndRule(); expr = new Logical(expr, token, right); } return(expr); }
Expr OrRule() { Expr expr = AndRule(); if (Match(OR_OR)) { Token token = Previous(); Expr right = OrRule(); expr = new Logical(expr, token, right); } return(expr); }
public object Visit(Logical expr) { object left = Evaluate(expr.left); if (expr.oper.type == OR_OR) { if (CheckIsTruthy(left)) { return(left); } } else { if (!CheckIsTruthy(left)) { return(left); } } return(Evaluate(expr.right)); }
public object Visit(Logical expr) { Resolve(expr.left); Resolve(expr.right); return(null); }