fn match_token(&mut self, token_type: TokenType) -> Result<Token, Box<dyn Error>> {
        match &self.current_token {
            Some(tok) => {
                if tok.token_type == token_type {
                    return self.consume();
                } else {
                    return Err(format!(
                        "Syntax error, expected '{}' token but '{}' was found instead.",
                        token_type, tok.token_type
                    )
                    .into());
                }
            }
            None => {
                return Err(format!(
                    "Syntax error, expected '{}' token but no more tokens were found.",
                    token_type
                )
                .into());
            }
        }
    }
// Consume the current if it matches the given type, else returns an error
Consume the current if it matches the given type, else returns an error
Consume the current if it matches the given type else returns an error
fn match_token(&mut self, token_type: TokenType) -> Result<Token, Box<dyn Error>> {
        match &self.current_token {
            Some(tok) => {
                if tok.token_type == token_type {
                    return self.consume();
                } else {
                    return Err(format!(
                        "Syntax error, expected '{}' token but '{}' was found instead.",
                        token_type, tok.token_type
                    )
                    .into());
                }
            }
            None => {
                return Err(format!(
                    "Syntax error, expected '{}' token but no more tokens were found.",
                    token_type
                )
                .into());
            }
        }
    }
fn match_token ( & mut self , token_type : TokenType ) -> Result < Token , Box < dyn Error > > { match & self . current_token { Some ( tok ) => { if tok . token_type == token_type { return self . consume ( ) ; } else { return Err ( format ! ( " " token_type tok token_type ) . into ( ) ) ; } } None => { return Err ( format ! ( " " token_type ) . into ( ) ) ; } } }
Consume the current if it matches the given type, else returns an error
Consume the current if it matches the given type else returns an error
&mut self
token_type
TokenType