Exemple #1
0
        public object VisitTernaryExpr(Ternary expr)
        {
            Resolve(expr.Condition);
            Resolve(expr.ThenBranch);
            Resolve(expr.ElseBranch);

            return(null);
        }
Exemple #2
0
 public object VisitTernaryExpr(Ternary expr)
 {
     if (IsTruthy(Evaluate(expr.Condition)))
     {
         return(Evaluate(expr.ThenBranch));
     }
     else
     {
         return(Evaluate(expr.ElseBranch));
     }
 }
Exemple #3
0
        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);
        }
Exemple #4
0
 public string VisitTernaryExpr(Ternary expr)
 {
     throw new System.NotImplementedException();
 }