mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-08 05:35:22 +00:00
Merge pull request #4404 from harupy/merge-match-arms
Merge match arms in `StringParser.parse_formatted_value`
This commit is contained in:
commit
69c012b8c5
1 changed files with 3 additions and 18 deletions
|
@ -189,26 +189,11 @@ impl<'a> StringParser<'a> {
|
|||
match ch {
|
||||
// can be integrated better with the remaining code, but as a starting point ok
|
||||
// in general I would do here a tokenizing of the fstrings to omit this peeking.
|
||||
'!' if self.peek() == Some(&'=') => {
|
||||
expression.push_str("!=");
|
||||
'!' | '=' | '>' | '<' if self.peek() == Some(&'=') => {
|
||||
expression.push(ch);
|
||||
expression.push('=');
|
||||
self.next_char();
|
||||
}
|
||||
|
||||
'=' if self.peek() == Some(&'=') => {
|
||||
expression.push_str("==");
|
||||
self.next_char();
|
||||
}
|
||||
|
||||
'>' if self.peek() == Some(&'=') => {
|
||||
expression.push_str(">=");
|
||||
self.next_char();
|
||||
}
|
||||
|
||||
'<' if self.peek() == Some(&'=') => {
|
||||
expression.push_str("<=");
|
||||
self.next_char();
|
||||
}
|
||||
|
||||
'!' if delims.is_empty() && self.peek() != Some(&'=') => {
|
||||
if expression.trim().is_empty() {
|
||||
return Err(EmptyExpression.to_lexical_error(self.get_pos()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue