fn scan_identifier(&mut self, head: char, start: Span<Location>) -> SpannedToken {
        let mut ident = String::new();

        if !is_ident_start(head) {
            self.errors
                .push(LexerError::UnexpectedCharacter { start, found: head });
        } else {
            ident.push(head);
        }

        let mut end = start.end();
        let mut offset = 0usize;

        for curr in self.remaining.chars() {
            if is_separator(curr) {
                break;
            }

            end.shift(curr);

            if is_ident_continue(curr) {
                ident.push(curr);
                offset += 1;
            } else {
                self.errors.push(LexerError::UnexpectedCharacter {
                    start: span(start.start(), end),
                    found: curr,
                })
            }
        }
        self.current = end;

        self.remaining = &self.remaining[offset..];

        let token = if ident.ends_with('\'') {
            // Remove apostrophe before sending token.
            ident.pop();
            Token::TypeVar(ident)
        } else {
            match ident.as_str() {
                "not" => Token::Logic(LogicOp::Not),
                "and" => Token::Logic(LogicOp::And),
                "or"  => Token::Logic(LogicOp::Or),

                "data"   => Token::Data,
                "type"   => Token::Type,
                "new"    => Token::New,
                "struct" => Token::Struct,
                "impl"   => Token::Impl,
                "forall" => Token::Forall,

                "if"     => Token::If,
                "else"   => Token::Else,
                "unless" => Token::Unless,
                "while"  => Token::While,
                "until"  => Token::Until,
                "for"    => Token::For,
                "in"     => Token::In,
                "loop"   => Token::Loop,
                "break"  => Token::Break,
                "continue" => Token::Continue,
                "return" => Token::Return,

                "with"  => Token::With,
                "match" => Token::Match,
                "let"   => Token::Let,
                "mut"   => Token::Mut,
                "self" => Token::SelfLit,
                "true" => Token::BoolLiteral(true),
                "false" => Token::BoolLiteral(false),
                _ => Token::Identifier(ident)
            }
        };

        spanned2(start.start(), end, token)
    }
/// Scans the source input for an identifier.
Scans the source input for an identifier.
Scans the source input for an identifier .
fn scan_identifier(&mut self, head: char, start: Span<Location>) -> SpannedToken {
        let mut ident = String::new();
        if !is_ident_start(head) {
            self.errors
                .push(LexerError::UnexpectedCharacter { start, found: head });
        } else {
            ident.push(head);
        }
        let mut end = start.end();
        let mut offset = 0usize;
        for curr in self.remaining.chars() {
            if is_separator(curr) {
                break;
            }
            end.shift(curr);
            if is_ident_continue(curr) {
                ident.push(curr);
                offset += 1;
            } else {
                self.errors.push(LexerError::UnexpectedCharacter {
                    start: span(start.start(), end),
                    found: curr,
                })
            }
        }
        self.current = end;
        self.remaining = &self.remaining[offset..];
        let token = if ident.ends_with('\'') {
            // Remove apostrophe before sending token.
            ident.pop();
            Token::TypeVar(ident)
        } else {
            match ident.as_str() {
                "not" => Token::Logic(LogicOp::Not),
                "and" => Token::Logic(LogicOp::And),
                "or"  => Token::Logic(LogicOp::Or),
                "data"   => Token::Data,
                "type"   => Token::Type,
                "new"    => Token::New,
                "struct" => Token::Struct,
                "impl"   => Token::Impl,
                "forall" => Token::Forall,
                "if"     => Token::If,
                "else"   => Token::Else,
                "unless" => Token::Unless,
                "while"  => Token::While,
                "until"  => Token::Until,
                "for"    => Token::For,
                "in"     => Token::In,
                "loop"   => Token::Loop,
                "break"  => Token::Break,
                "continue" => Token::Continue,
                "return" => Token::Return,
                "with"  => Token::With,
                "match" => Token::Match,
                "let"   => Token::Let,
                "mut"   => Token::Mut,
                "self" => Token::SelfLit,
                "true" => Token::BoolLiteral(true),
                "false" => Token::BoolLiteral(false),
                _ => Token::Identifier(ident)
            }
        };
        spanned2(start.start(), end, token)
    }
fn scan_identifier ( & mut self , head : char , start : Span < Location > ) -> SpannedToken { let mut ident = String :: new ( ) ; if ! is_ident_start ( head ) { self . errors . push ( LexerError :: UnexpectedCharacter { start , found : head } ) ; } else { ident . push ( head ) ; } let mut end = start . end ( ) ; let mut offset = 0usize ; for curr in self . remaining . chars ( ) { if is_separator ( curr ) { break ; } end . shift ( curr ) ; if is_ident_continue ( curr ) { ident . push ( curr ) ; offset += 1 ; } else { self . errors . push ( LexerError :: UnexpectedCharacter { start : span ( start . start ( ) , end ) , found : curr , } ) } } self . current = end ; self . remaining = & self . remaining [ offset .. ] ; let token = if ident . ends_with ( '\'' ) { // Remove apostrophe before sending token. ident . pop ( ) ; Token :: TypeVar ( ident ) } else { match ident . as_str ( ) { " " => Token :: Logic ( LogicOp :: Not ) , " " => Token :: Logic ( LogicOp :: And ) , " " => Token :: Logic ( LogicOp :: Or ) , " " => Token :: Data , " " => Token :: Type , " " => Token :: New , " " => Token :: Struct , " " => Token :: Impl , " " => Token :: Forall , " " => Token :: If , " " => Token :: Else , " " => Token :: Unless , " " => Token :: While , " " => Token :: Until , " " => Token :: For , " " => Token :: In , " " => Token :: Loop , " " => Token :: Break , " " => Token :: Continue , " " => Token :: Return , " " => Token :: With , " " => Token :: Match , " " => Token :: Let , " " => Token :: Mut , " " => Token :: SelfLit , " " => Token :: BoolLiteral ( true ) , " " => Token :: BoolLiteral ( false ) , _ => Token :: Identifier ( ident ) } } ; spanned2 ( start . start ( ) , end , token ) }
Scans the source input for an identifier.
Scans the source input for an identifier .
&mut self
head
char
start
Span<Location>
&mut self
head
char
start
Span<Location>