previousTokenIs checks if the Parser's previousToken type matches any of the given types
(tokens ...token.Type)
| 124 | |
| 125 | // previousTokenIs checks if the Parser's previousToken type matches any of the given types |
| 126 | func (p *Parser) previousTokenIs(tokens ...token.Type) bool { // Check if previous token matches any type |
| 127 | for _, tokenType := range tokens { // Iterate through token types |
| 128 | if p.previousToken.Type == tokenType { // Check for match |
| 129 | return true // Match found |
| 130 | } // Continue if no match |
| 131 | } // All types checked |
| 132 | return false // No match found |
| 133 | } // End previousTokenIs |
| 134 | // peekTokenIs checks if the Parser's peekToken is any of the given token types |
| 135 | func (p *Parser) peekTokenIs(tokens ...token.Type) bool { |
| 136 | // iterate through the given token types and check if any of them match the peekToken's type |