public string Visit_LiteralExpr(LiteralExpr expr) { if (expr.value == null) { return("nil"); } return("'" + expr.value.ToString() + "'"); }
public object VisitLiteralExpr(LiteralExpr expr) { return(expr.Value); }
private Stmt ForStatement() { Expect(TokenType.LeftParen, ErrorType.ExpectedOpenParen); Stmt initializer; if (CheckCurrentToken(TokenType.Semicolon)) { initializer = null; Advance(); } else if (CheckCurrentToken(TokenType.Var)) { Advance(); initializer = VarDeclaration(); } else { initializer = ExpressionStatement(); } Expr condition = null; if (!CheckCurrentToken(TokenType.Semicolon)) { condition = Expression(); } Expect(TokenType.Semicolon, ErrorType.ExpectedSemicolon); Expr increment = null; if (!CheckCurrentToken(TokenType.RightParen)) { increment = Expression(); } Expect(TokenType.RightParen, ErrorType.ExpectedClosedParen); Stmt body = Statement(); if (increment != null) { body = new BlockStmt(new List <Stmt> { body, new ExpressionStmt(increment) }); } if (condition == null) { condition = new LiteralExpr(true); } body = new WhileStmt(condition, body); if (initializer != null) { body = new BlockStmt(new List <Stmt> { initializer, body }); } return(body); }
public object VisitLiteralExpr(LiteralExpr expr) { return(null); }
public Object Visit_LiteralExpr(LiteralExpr expr) { return(expr.value); }
public Void Visit_LiteralExpr(LiteralExpr expr) { return(null); }