expectAndNext method checks if the next token is of the expected type and advances the lexer to the next token if it is. It returns true if the next token is of the expected type, and false otherwise.
(t token.Type)
| 575 | |
| 576 | // expectAndNext method checks if the next token is of the expected type and advances the lexer to the next token if it is. It returns true if the next token is of the expected type, and false otherwise. |
| 577 | func (p *Parser) expectAndNext(t token.Type) bool { |
| 578 | // if the next token is of the expected type, advance the lexer to the next token and return true |
| 579 | if p.peekTokenIs(t) { |
| 580 | p.next() |
| 581 | return true |
| 582 | } |
| 583 | // otherwise, generate an error message indicating that the expected token type was not found and return false |
| 584 | p.peekError(t) |
| 585 | return false |
| 586 | } |
| 587 | |
| 588 | // expect method checks if the next token is of the expected type, without advancing the lexer. It returns true if the next token is of the expected type, and false otherwise. |
| 589 | func (p *Parser) expect(t token.Type) bool { |
no test coverage detected