fn consume_token(&mut self) -> Option<TokenKind> {
        self.advance().map(|ch| match ch {
            ',' => TokenKind::Comma,
            ';' => TokenKind::Semicolon,
            '?' => TokenKind::Question,
            '(' => TokenKind::Open(DelimKind::Paren),
            ')' => TokenKind::Close(DelimKind::Paren),
            '{' => TokenKind::Open(DelimKind::Brace),
            '}' => TokenKind::Close(DelimKind::Brace),
            '[' => TokenKind::Open(DelimKind::Bracket),
            ']' => TokenKind::Close(DelimKind::Bracket),
            '"' => self.consume_string_literal(),
            '\'' => self.consume_char_literal(),
            '0' => self.consume_zero_number(),
            ch if is_dec_digit(ch) => self.consume_dec_literal(),
            ch if is_whitespace(ch) => self.consume_whitespace(),
            ch if is_symbol(ch) => self.consume_symbol(),
            ch if is_identifier_start(ch) => self.consume_identifier(),
            ch => {
                self.add_diagnostic(
                    Diagnostic::new_error(format!("unexpected character `{}`", ch))
                        .with_label(Label::new_primary(self.token_span())),
                );
                TokenKind::Error
            },
        })
    }
/// Consume a token, returning its tag or none on end of file.
Consume a token, returning its tag or none on end of file.
Consume a token returning its tag or none on end of file .
fn consume_token(&mut self) -> Option<TokenKind> {
        self.advance().map(|ch| match ch {
            ',' => TokenKind::Comma,
            ';' => TokenKind::Semicolon,
            '?' => TokenKind::Question,
            '(' => TokenKind::Open(DelimKind::Paren),
            ')' => TokenKind::Close(DelimKind::Paren),
            '{' => TokenKind::Open(DelimKind::Brace),
            '}' => TokenKind::Close(DelimKind::Brace),
            '[' => TokenKind::Open(DelimKind::Bracket),
            ']' => TokenKind::Close(DelimKind::Bracket),
            '"' => self.consume_string_literal(),
            '\'' => self.consume_char_literal(),
            '0' => self.consume_zero_number(),
            ch if is_dec_digit(ch) => self.consume_dec_literal(),
            ch if is_whitespace(ch) => self.consume_whitespace(),
            ch if is_symbol(ch) => self.consume_symbol(),
            ch if is_identifier_start(ch) => self.consume_identifier(),
            ch => {
                self.add_diagnostic(
                    Diagnostic::new_error(format!("unexpected character `{}`", ch))
                        .with_label(Label::new_primary(self.token_span())),
                );
                TokenKind::Error
            },
        })
    }
fn consume_token ( & mut self ) -> Option < TokenKind > { self . advance ( ) . map ( | ch | match ch { ',' => TokenKind :: Comma , ';' => TokenKind :: Semicolon , '?' => TokenKind :: Question , '(' => TokenKind :: Open ( DelimKind :: Paren ) , ')' => TokenKind :: Close ( DelimKind :: Paren ) , '{' => TokenKind :: Open ( DelimKind :: Brace ) , '}' => TokenKind :: Close ( DelimKind :: Brace ) , '[' => TokenKind :: Open ( DelimKind :: Bracket ) , ']' => TokenKind :: Close ( DelimKind :: Bracket ) , '"' => self . consume_string_literal ( ) , '\'' => self . consume_char_literal ( ) , '0' => self . consume_zero_number ( ) , ch if is_dec_digit ( ch ) => self . consume_dec_literal ( ) , ch if is_whitespace ( ch ) => self . consume_whitespace ( ) , ch if is_symbol ( ch ) => self . consume_symbol ( ) , ch if is_identifier_start ( ch ) => self . consume_identifier ( ) , ch => { self . add_diagnostic ( Diagnostic :: new_error ( format ! ( " " ch ) ) . with_label ( Label :: new_primary ( self . token_span ( ) ) ) , ) ; TokenKind :: Error } , } ) }
Consume a token, returning its tag or none on end of file.
Consume a token returning its tag or none on end of file .
&mut self
&mut self