Implement challenge 26 ez katka
This commit is contained in:
@@ -40,14 +40,13 @@ fn scan(code: &str, mut ix: usize, mut tokens: Tokens) -> Tokens {
|
||||
let c: char = code[ix..ix + 1].chars().next().unwrap();
|
||||
if c.is_ascii_alphanumeric() || SPECIAL_CHARS.contains(&c) {
|
||||
return scan_identifier(code, ix, tokens);
|
||||
} else if c == '&' {
|
||||
tokens.push(Token::Ampersand);
|
||||
} else if c == '=' {
|
||||
tokens.push(Token::Equal);
|
||||
} else if c == ';' {
|
||||
tokens.push(Token::Semicolon);
|
||||
} else {
|
||||
panic!("Unexpected char '{}' at index {}", c, ix);
|
||||
}
|
||||
|
||||
match c {
|
||||
'&' => tokens.push(Token::Ampersand),
|
||||
'=' => tokens.push(Token::Equal),
|
||||
';' => tokens.push(Token::Semicolon),
|
||||
_ => panic!("Unexpected char '{}' at index {}", c, ix),
|
||||
}
|
||||
ix += 1;
|
||||
scan(code, ix, tokens)
|
||||
|
||||
Reference in New Issue
Block a user