fn scan_symbol(&mut self) {
        use TokenType::*;
        let mut did_you_mean = None;
        let start = self.pos;
        let mut span = None;
        let ty = match self.next().unwrap() {
            '+' => Plus,
            '-' => Minus,
            '*' => Mult,
            '/' => Div,
            '%' => Mod,
            '^' => Exp,
            '=' => Equal,
            ':' => {
                if self.peek() == Some(&'=') {
                    self.next();
                    AssignDefine
                } else {
                    span = Some(start..start + 1);
                    self.collect_while(|c| c.is_whitespace());
                    if self.peek() == Some(&'=') {
                        did_you_mean = Some((":=", start..self.pos + 1));
                    }
                    Invalid(":".to_owned())
                }
            }
            '(' => OpenParen,
            ')' => CloseParen,
            '[' => OpenBracket,
            ']' => CloseBracket,
            c => Invalid(c.to_string()),
        };
        let span = span.unwrap_or(start..self.pos);

        if matches!(ty, Invalid(..)) {
            self.push_diag(InvalidToken!(span.clone(), did_you_mean));
        }
        self.push_tok(ty, span);
    }
/// Matches a symbol with a token and creates it.
Matches a symbol with a token and creates it.
Matches a symbol with a token and creates it .
fn scan_symbol(&mut self) {
        use TokenType::*;
        let mut did_you_mean = None;
        let start = self.pos;
        let mut span = None;
        let ty = match self.next().unwrap() {
            '+' => Plus,
            '-' => Minus,
            '*' => Mult,
            '/' => Div,
            '%' => Mod,
            '^' => Exp,
            '=' => Equal,
            ':' => {
                if self.peek() == Some(&'=') {
                    self.next();
                    AssignDefine
                } else {
                    span = Some(start..start + 1);
                    self.collect_while(|c| c.is_whitespace());
                    if self.peek() == Some(&'=') {
                        did_you_mean = Some((":=", start..self.pos + 1));
                    }
                    Invalid(":".to_owned())
                }
            }
            '(' => OpenParen,
            ')' => CloseParen,
            '[' => OpenBracket,
            ']' => CloseBracket,
            c => Invalid(c.to_string()),
        };
        let span = span.unwrap_or(start..self.pos);
        if matches!(ty, Invalid(..)) {
            self.push_diag(InvalidToken!(span.clone(), did_you_mean));
        }
        self.push_tok(ty, span);
    }
fn scan_symbol ( & mut self ) { use TokenType :: * ; let mut did_you_mean = None ; let start = self . pos ; let mut span = None ; let ty = match self . next ( ) . unwrap ( ) { '+' => Plus , '-' => Minus , '*' => Mult , '/' => Div , '%' => Mod , '^' => Exp , '=' => Equal , ':' => { if self . peek ( ) == Some ( & '=' ) { self . next ( ) ; AssignDefine } else { span = Some ( start .. start + 1 ) ; self . collect_while ( | c | c . is_whitespace ( ) ) ; if self . peek ( ) == Some ( & '=' ) { did_you_mean = Some ( ( " " , start .. self . pos + 1 ) ) ; } Invalid ( " " . to_owned ( ) ) } } '(' => OpenParen , ')' => CloseParen , '[' => OpenBracket , ']' => CloseBracket , c => Invalid ( c . to_string ( ) ) , } ; let span = span . unwrap_or ( start .. self . pos ) ; if matches ! ( ty Invalid ( ) ) { self . push_diag ( InvalidToken ! ( span clone ( ) did_you_mean ) ) ; } self . push_tok ( ty , span ) ; }
Matches a symbol with a token and creates it.
Matches a symbol with a token and creates it .
&mut self
&mut self