package parser import ( "code.osinet.fr/fgm/waiig15/ast" "code.osinet.fr/fgm/waiig15/token" ) func (p *Parser) parseLetStatement() *ast.LetStatement { stmt := &ast.LetStatement{ Token: p.curToken, } // Let statement starts with an IDENT token, so if next token is not an // IDENT, the next statement cannot be a Let statement. if !p.expectPeek(token.IDENT) { return nil } stmt.Name = &ast.Identifier{ Token: p.curToken, Value: p.curToken.Literal, } // The previous expectPeek() call fetched the next token, so we should now // be on the assignment. if !p.expectPeek(token.ASSIGN) { return nil } // Skip the expression for now, progress to the semicolon terminating the // statement. for !p.curTokenIs(token.SEMICOLON) { p.nextToken() } return stmt }