private Expr or() { Expr expr = and(); while (match(TokenType.OR)) { Token _operator = previous(); Expr right = and(); expr = new Expr.logicalExpr(expr, _operator, right); } return(expr); }
private Expr and() { Expr expr = equality(); while (match(TokenType.AND)) { Token _operator = previous(); Expr right = ternaryExpression(); expr = new Expr.logicalExpr(expr, _operator, right); } return(expr); }
public object visitLogicalExpr(Expr.logicalExpr logicalExpr) { object left = evaluate(logicalExpr.left); if (logicalExpr._operator.type == TokenType.OR) { if (isTruthy(left)) { return(left); } } else { if (!isTruthy(left)) { return(left); } } return(evaluate(logicalExpr.right)); }
public object visitLogicalExpr(Expr.logicalExpr logicalExpr) { resolve(logicalExpr.left); resolve(logicalExpr.right); return(null); }
public string visitLogicalExpr(Expr.logicalExpr logicalExpr) { return(parenthesize(logicalExpr._operator.lexeme, new Expr[] { logicalExpr.left, logicalExpr.right })); }