(&mut self)
| 44 | } |
| 45 | |
| 46 | fn tokenize_characters(&mut self) -> Result<Vec<Token>, Box<Diagnostic>> { |
| 47 | let mut tokens: Vec<Token> = Vec::new(); |
| 48 | let len = self.content_len; |
| 49 | |
| 50 | while self.has_next() { |
| 51 | self.column_start = self.column_end; |
| 52 | self.line_start = self.line_end; |
| 53 | |
| 54 | let char = self.content[self.index]; |
| 55 | |
| 56 | // Symbol |
| 57 | if char.is_alphabetic() { |
| 58 | tokens.push(self.consume_identifier()); |
| 59 | continue; |
| 60 | } |
| 61 | |
| 62 | // @> or Global Variable Symbol |
| 63 | if char == '@' { |
| 64 | // @> |
| 65 | if self.is_next_char('>') { |
| 66 | self.index += 2; |
| 67 | let location = self.current_source_location(); |
| 68 | tokens.push(Token::new(TokenKind::AtRightArrow, location)); |
| 69 | continue; |
| 70 | } |
| 71 | |
| 72 | tokens.push(self.consume_global_variable_name()?); |
| 73 | continue; |
| 74 | } |
| 75 | |
| 76 | // Number |
| 77 | if char.is_numeric() { |
| 78 | if char == '0' && self.index + 1 < len { |
| 79 | match self.content[self.index + 1] { |
| 80 | // bindigits |
| 81 | 'b' | 'B' => { |
| 82 | self.index += 2; |
| 83 | self.column_start += 2; |
| 84 | tokens.push(self.consume_binary_number()?); |
| 85 | continue; |
| 86 | } |
| 87 | // hexdigits |
| 88 | 'x' | 'X' => { |
| 89 | self.index += 2; |
| 90 | self.column_start += 2; |
| 91 | tokens.push(self.consume_hex_number()?); |
| 92 | continue; |
| 93 | } |
| 94 | // octdigits |
| 95 | 'o' | 'O' => { |
| 96 | self.index += 2; |
| 97 | self.column_start += 2; |
| 98 | tokens.push(self.consume_octal_number()?); |
| 99 | continue; |
| 100 | } |
| 101 | _ => { |
| 102 | tokens.push(self.consume_number()?); |
| 103 | continue; |
no test coverage detected