From 77e827acd5a32dc83382b3e0fe04ef2e151bfd35 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 20 Feb 2023 13:20:26 -0500 Subject: [PATCH] Update compiler/parser/src/soft_keywords.rs Co-authored-by: Jim Fasarakis-Hilliard --- parser/src/soft_keywords.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/parser/src/soft_keywords.rs b/parser/src/soft_keywords.rs index d5eaa29..a425625 100644 --- a/parser/src/soft_keywords.rs +++ b/parser/src/soft_keywords.rs @@ -58,25 +58,19 @@ where if !self.start_of_line { next = Some(Ok((*start, soft_to_name(tok), *end))); } else { - let mut par_count = 0; - let mut sqb_count = 0; - let mut brace_count = 0; + let mut nesting = 0; let mut first = true; let mut seen_colon = false; while let Some(Ok((_, tok, _))) = self.underlying.peek() { match tok { Tok::Newline => break, - Tok::Colon if par_count == 0 && sqb_count == 0 && brace_count == 0 => { + Tok::Colon if nesting == 0 => { if !first { seen_colon = true; } } - Tok::Lpar => par_count += 1, - Tok::Rpar => par_count -= 1, - Tok::Lsqb => sqb_count += 1, - Tok::Rsqb => sqb_count -= 1, - Tok::Lbrace => brace_count += 1, - Tok::Rbrace => brace_count -= 1, + Tok::Lpar | Tok::Lsqb | Tok::Lbrace => nesting += 1, + Tok::Rpar | Tok::Rsqb | Tok::Rbrace => nesting -= 1, _ => {} } first = false;