Scan a 'word', which is an identifier-like sequence of characters beginning with '_' or an alphabetic char, followed by zero or more alphanumeric or '_' characters.
(&mut self)
| 313 | // Scan a 'word', which is an identifier-like sequence of characters beginning with '_' or an |
| 314 | // alphabetic char, followed by zero or more alphanumeric or '_' characters. |
| 315 | fn scan_word(&mut self) -> Result<LocatedToken<'a>, LocatedError> { |
| 316 | let begin = self.pos; |
| 317 | let loc = self.loc(); |
| 318 | |
| 319 | assert!(self.lookahead == Some('_') || self.lookahead.unwrap().is_ascii_alphabetic()); |
| 320 | loop { |
| 321 | match self.next_ch() { |
| 322 | Some('_') | Some('0'..='9') | Some('a'..='z') | Some('A'..='Z') => {} |
| 323 | _ => break, |
| 324 | } |
| 325 | } |
| 326 | let text = &self.source[begin..self.pos]; |
| 327 | |
| 328 | // Look for numbered well-known entities like block15, v45, ... |
| 329 | token( |
| 330 | split_entity_name(text) |
| 331 | .and_then(|(prefix, number)| { |
| 332 | Self::numbered_entity(prefix, number) |
| 333 | .or_else(|| Self::value_type(text, prefix, number)) |
| 334 | }) |
| 335 | .unwrap_or_else(|| match text { |
| 336 | "cold" => Token::Cold, |
| 337 | _ => Token::Identifier(text), |
| 338 | }), |
| 339 | loc, |
| 340 | ) |
| 341 | } |
| 342 | |
| 343 | // If prefix is a well-known entity prefix and suffix is a valid entity number, return the |
| 344 | // decoded token. |
no test coverage detected