private Expr multiplication() { Expr expr = unary(); while (match(TokenType.SLASH, TokenType.STAR)) { Token operator_ = previous(); Expr right = unary(); expr = new Expr.Binary(expr, operator_, right); } return(expr); }
private Expr addition() { Expr expr = multiplication(); while (match(TokenType.MINUS, TokenType.PLUS)) { Token operator_ = previous(); Expr right = multiplication(); expr = new Expr.Binary(expr, operator_, right); } return(expr); }
private Expr comparison() { Expr expr = addition(); while (match(TokenType.GREATER, TokenType.GREATER_EQUAL, TokenType.LESS, TokenType.LESS_EQUAL)) { Token operator_ = previous(); Expr right = addition(); expr = new Expr.Binary(expr, operator_, right); } return(expr); }
private Expr equality() { Expr expr = comparison(); while (match(TokenType.BANG_EQUAL, TokenType.EQUAL_EQUAL)) { Token operator_ = previous(); Expr right = comparison(); expr = new Expr.Binary(expr, operator_, right); } return(expr); }
public string visitBinaryExpr(Expr.Binary expr) { return(parenthesize(expr.operator_.lexeme, expr.left, expr.right)); }
public object visitBinaryExpr(Expr.Binary expr) { resolve(expr.left); resolve(expr.right); return(null); }