public LetStatement ParseLetStatement() { var statement = new LetStatement(); statement.Token = this.CurrentToken; if (!this.ExpectPeek(TokenType.IDENT)) { return(null); } statement.Name = new Identifier(this.CurrentToken, this.CurrentToken.Literal); if (!this.ExpectPeek(TokenType.ASSIGN)) { return(null); } while (this.CurrentToken.Type != TokenType.SEMICOLON) { this.ReadToken(); } return(statement); }
private LetStatement ParseAssignmentOperatorStatement() { var statement = new LetStatement(new Token(Token.Let, "let")); var ident = new Identifier(_current) { Value = _current.Literal }; statement.Name = ident; statement.Value = AssignmentOperatorInfixExpression(ident); if (PeekTokenIs(Token.Semicolon)) { NextToken(); } return(statement); }
private LetStatement ParseLetStatement() { var statement = new LetStatement(_current); if (!ExpectPeek(Token.Ident)) { return(null); } statement.Name = new Identifier(_current) { Value = _current.Literal }; if (PeekTokenIsAssignmentOperator()) { statement.Value = AssignmentOperatorInfixExpression(statement.Name); } else { if (!ExpectPeek(Token.Assign)) { return(null); } NextToken(); statement.Value = ParseExpression(Lowest); } if (PeekTokenIs(Token.Semicolon)) { NextToken(); } return(statement); }