diff options
author | Ben Bridle <ben@derelict.engineering> | 2025-03-23 11:06:35 +1300 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2025-03-23 11:06:48 +1300 |
commit | c7b3f1509d36928b8f9d470cc55ad547f6482e95 (patch) | |
tree | 461781dc414acbe86b855564f00a38b3a531829e | |
parent | 96055e6a0a7a9d267e1c9e7d0391d176763dc908 (diff) | |
download | bedrock-asm-c7b3f1509d36928b8f9d470cc55ad547f6482e95.zip |
Simplify syntactic catch-all branch
A cascading if-else structure is more readable than a set of nested
match expressions.
-rw-r--r-- | src/stages/syntactic.rs | 12 |
1 files changed, 6 insertions, 6 deletions
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<Vec<Tracked<Syntac }, c => { let token = format!("{c}{}", t.eat_token()); - match token.parse::<Value>() { - Ok(value) => SyntacticToken::RawValue(value), - Err(_) => match token.parse::<Instruction>() { - Ok(instruction) => SyntacticToken::Instruction(instruction), - Err(_) => SyntacticToken::Invocation(token), - } + if let Ok(value) = token.parse::<Value>() { + SyntacticToken::RawValue(value) + } else if let Ok(instruction) = token.parse::<Instruction>() { + SyntacticToken::Instruction(instruction) + } else { + SyntacticToken::Invocation(token) } } }; |