|
|
@ -158,8 +158,8 @@ impl<'a> Iterator for Scanner<'a> {
|
|
|
|
Some(match self.advance() {
|
|
|
|
Some(match self.advance() {
|
|
|
|
c if is_alpha(c) => self.identifier(),
|
|
|
|
c if is_alpha(c) => self.identifier(),
|
|
|
|
c if c.is_ascii_digit() => self.number(),
|
|
|
|
c if c.is_ascii_digit() => self.number(),
|
|
|
|
// '(' => Token::new(self, TokenKind::LeftParen),
|
|
|
|
'(' => Token::new(self, TokenKind::LeftParen),
|
|
|
|
'(' => self.make_token(TokenKind::LeftParen),
|
|
|
|
// '(' => self.make_token(TokenKind::LeftParen),
|
|
|
|
// ')' => self.make_token(TokenKind::RightParen),
|
|
|
|
// ')' => self.make_token(TokenKind::RightParen),
|
|
|
|
// '{' => self.make_token(TokenKind::LeftBrace),
|
|
|
|
// '{' => self.make_token(TokenKind::LeftBrace),
|
|
|
|
// '}' => self.make_token(TokenKind::RightBrace),
|
|
|
|
// '}' => self.make_token(TokenKind::RightBrace),
|
|
|
@ -211,7 +211,7 @@ pub struct Token<'a> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl<'a> Token<'a> {
|
|
|
|
impl<'a> Token<'a> {
|
|
|
|
fn new(scanner: &'a Scanner, kind: TokenKind) -> Self {
|
|
|
|
fn new(scanner: &Scanner<'a>, kind: TokenKind) -> Self {
|
|
|
|
Token {
|
|
|
|
Token {
|
|
|
|
kind,
|
|
|
|
kind,
|
|
|
|
value: std::str::from_utf8(&scanner.source[..scanner.current]).unwrap(),
|
|
|
|
value: std::str::from_utf8(&scanner.source[..scanner.current]).unwrap(),
|
|
|
|