mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-19 02:55:50 +00:00
Merge match arms in parse_formatted_value
This commit is contained in:
parent
bf715ab1ca
commit
83ebf39ecc
1 changed files with 3 additions and 18 deletions
|
@ -189,26 +189,11 @@ impl<'a> StringParser<'a> {
|
||||||
match ch {
|
match ch {
|
||||||
// can be integrated better with the remaining code, but as a starting point ok
|
// 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.
|
// in general I would do here a tokenizing of the fstrings to omit this peeking.
|
||||||
'!' if self.peek() == Some(&'=') => {
|
'!' | '=' | '>' | '<' if self.peek() == Some(&'=') => {
|
||||||
expression.push_str("!=");
|
expression.push(ch);
|
||||||
|
expression.push('=');
|
||||||
self.next_char();
|
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 delims.is_empty() && self.peek() != Some(&'=') => {
|
||||||
if expression.trim().is_empty() {
|
if expression.trim().is_empty() {
|
||||||
return Err(EmptyExpression.to_lexical_error(self.get_pos()));
|
return Err(EmptyExpression.to_lexical_error(self.get_pos()));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue