private GExpr.Expr or() { GExpr.Expr expr = and(); while (Match(tt.OR)) { Token op = previous(); GExpr.Expr right = and(); expr = new GExpr.Logical(expr, op, right); } return(expr); }
private GExpr.Expr and() { GExpr.Expr expr = equality(); while (Match(tt.AND)) { Token op = previous(); GExpr.Expr right = equality(); expr = new GExpr.Logical(expr, op, right); } return(expr); }
public Object visit_Logical_Expr(GExpr.Logical expr) { Object left = evaluate(expr.left); if (expr.Operator.type == tt.OR) { if (isTruthy(left)) { return(left); } } else { if (!isTruthy(left)) { return(left); } } return(evaluate(expr.right)); }