mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-26 21:34:55 +00:00
Update compiler/parser/src/soft_keywords.rs
Co-authored-by: Jim Fasarakis-Hilliard <d.f.hilliard@gmail.com>
This commit is contained in:
parent
e093d2bee6
commit
f39ffef370
1 changed files with 4 additions and 10 deletions
|
@ -58,25 +58,19 @@ where
|
||||||
if !self.start_of_line {
|
if !self.start_of_line {
|
||||||
next = Some(Ok((*start, soft_to_name(tok), *end)));
|
next = Some(Ok((*start, soft_to_name(tok), *end)));
|
||||||
} else {
|
} else {
|
||||||
let mut par_count = 0;
|
let mut nesting = 0;
|
||||||
let mut sqb_count = 0;
|
|
||||||
let mut brace_count = 0;
|
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
let mut seen_colon = false;
|
let mut seen_colon = false;
|
||||||
while let Some(Ok((_, tok, _))) = self.underlying.peek() {
|
while let Some(Ok((_, tok, _))) = self.underlying.peek() {
|
||||||
match tok {
|
match tok {
|
||||||
Tok::Newline => break,
|
Tok::Newline => break,
|
||||||
Tok::Colon if par_count == 0 && sqb_count == 0 && brace_count == 0 => {
|
Tok::Colon if nesting == 0 => {
|
||||||
if !first {
|
if !first {
|
||||||
seen_colon = true;
|
seen_colon = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Tok::Lpar => par_count += 1,
|
Tok::Lpar | Tok::Lsqb | Tok::Lbrace => nesting += 1,
|
||||||
Tok::Rpar => par_count -= 1,
|
Tok::Rpar | Tok::Rsqb | Tok::Rbrace => nesting -= 1,
|
||||||
Tok::Lsqb => sqb_count += 1,
|
|
||||||
Tok::Rsqb => sqb_count -= 1,
|
|
||||||
Tok::Lbrace => brace_count += 1,
|
|
||||||
Tok::Rbrace => brace_count -= 1,
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue