From c7b3f1509d36928b8f9d470cc55ad547f6482e95 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Sun, 23 Mar 2025 11:06:35 +1300 Subject: Simplify syntactic catch-all branch A cascading if-else structure is more readable than a set of nested match expressions. --- src/stages/syntactic.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/stages/syntactic.rs b/src/stages/syntactic.rs index c680700..960a4ed 100644 --- a/src/stages/syntactic.rs +++ b/src/stages/syntactic.rs @@ -119,12 +119,12 @@ fn parse_syntactic_from_tokeniser(mut t: Tokeniser) -> Result { let token = format!("{c}{}", t.eat_token()); - match token.parse::() { - Ok(value) => SyntacticToken::RawValue(value), - Err(_) => match token.parse::() { - Ok(instruction) => SyntacticToken::Instruction(instruction), - Err(_) => SyntacticToken::Invocation(token), - } + if let Ok(value) = token.parse::() { + SyntacticToken::RawValue(value) + } else if let Ok(instruction) = token.parse::() { + SyntacticToken::Instruction(instruction) + } else { + SyntacticToken::Invocation(token) } } }; -- cgit v1.2.3-70-g09d2