mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-27 13:54:55 +00:00
Don't call is_emoji_presentation for each invocation of consume_normal
This commit is contained in:
parent
aa0290bbfc
commit
838990ae15
1 changed files with 24 additions and 24 deletions
|
@ -689,21 +689,9 @@ where
|
||||||
fn consume_normal(&mut self) -> Result<(), LexicalError> {
|
fn consume_normal(&mut self) -> Result<(), LexicalError> {
|
||||||
// Check if we have some character:
|
// Check if we have some character:
|
||||||
if let Some(c) = self.window[0] {
|
if let Some(c) = self.window[0] {
|
||||||
// First check identifier:
|
|
||||||
if self.is_identifier_start(c) {
|
if self.is_identifier_start(c) {
|
||||||
let identifier = self.lex_identifier()?;
|
let identifier = self.lex_identifier()?;
|
||||||
self.emit(identifier);
|
self.emit(identifier);
|
||||||
} else if is_emoji_presentation(c) {
|
|
||||||
let tok_start = self.get_pos();
|
|
||||||
self.next_char();
|
|
||||||
let tok_end = self.get_pos();
|
|
||||||
self.emit((
|
|
||||||
tok_start,
|
|
||||||
Tok::Name {
|
|
||||||
name: c.to_string(),
|
|
||||||
},
|
|
||||||
tok_end,
|
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
self.consume_character(c)?;
|
self.consume_character(c)?;
|
||||||
}
|
}
|
||||||
|
@ -1112,13 +1100,25 @@ where
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
|
if is_emoji_presentation(c) {
|
||||||
|
let tok_start = self.get_pos();
|
||||||
|
self.next_char();
|
||||||
|
let tok_end = self.get_pos();
|
||||||
|
self.emit((
|
||||||
|
tok_start,
|
||||||
|
Tok::Name {
|
||||||
|
name: c.to_string(),
|
||||||
|
},
|
||||||
|
tok_end,
|
||||||
|
));
|
||||||
|
} else {
|
||||||
let c = self.next_char();
|
let c = self.next_char();
|
||||||
return Err(LexicalError {
|
return Err(LexicalError {
|
||||||
error: LexicalErrorType::UnrecognizedToken { tok: c.unwrap() },
|
error: LexicalErrorType::UnrecognizedToken { tok: c.unwrap() },
|
||||||
location: self.get_pos(),
|
location: self.get_pos(),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} // Ignore all the rest..
|
} // Ignore all the rest..
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue