From 12801c56275f7fd01b882081ad9bbd72afe983fc Mon Sep 17 00:00:00 2001 From: I-Al-Istannen Date: Wed, 8 Apr 2020 20:28:57 +0200 Subject: [PATCH] Fix optional argument parsing As `optional` does not backtrack, the parser would get stuck in its ways if it could parse spaces after an instruction without any argument: ``` NOT ; Comment ``` An explicit try was added to backtrack and not fail the parse. --- src/Mima/Asm/Phase1/Parse.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mima/Asm/Phase1/Parse.hs b/src/Mima/Asm/Phase1/Parse.hs index 58acca2..b24572f 100644 --- a/src/Mima/Asm/Phase1/Parse.hs +++ b/src/Mima/Asm/Phase1/Parse.hs @@ -114,7 +114,7 @@ instruction = small <|> large stop <- getOffset pure $ LargeInstruction (Span start stop) lo sv optionalAwareArgument (LargeOpcode _ code) - | Vm.argumentIsOptional code = optional (inlineSpace1 *> smallValue "argument") + | Vm.argumentIsOptional code = optional $ try (inlineSpace1 *> smallValue "argument") | otherwise = Just <$> (inlineSpace1 *> smallValue "argument") singleDirective