public object VisitTernaryExpr(Ternary expr) { Resolve(expr.Condition); Resolve(expr.ThenBranch); Resolve(expr.ElseBranch); return(null); }
public object VisitTernaryExpr(Ternary expr) { if (IsTruthy(Evaluate(expr.Condition))) { return(Evaluate(expr.ThenBranch)); } else { return(Evaluate(expr.ElseBranch)); } }
private Expr Ternary() { Expr expr = Or(); if (Match(TokenType.QUERY)) { Expr thenBranch = Expression(); Consume(TokenType.COLON, "Expect ':' after expression."); Expr elseBranch = Ternary(); expr = new Ternary(expr, thenBranch, elseBranch); } return(expr); }
public string VisitTernaryExpr(Ternary expr) { throw new System.NotImplementedException(); }