Beispiel #1
0
        private Expr ParseLeftAssociativeBinaryOperation(
            Func <Expr> higherPrecedence,
            params TokenType[] tokenTypes)
        {
            var expr = higherPrecedence();

            while (Match(tokenTypes))
            {
                var op    = Previous();
                var right = higherPrecedence();
                expr = new Expr.Binary(expr, op, right);
            }

            return(expr);
        }
Beispiel #2
0
 public string VisitBinaryExpr(Expr.Binary expr)
 {
     return(Parenthesize(expr.Operator.Lexeme, expr.Left, expr.Right));
 }
Beispiel #3
0
 public object VisitBinaryExpr(Expr.Binary expr)
 {
     Resolve(expr.Left);
     Resolve(expr.Right);
     return(null);
 }