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.
This commit is contained in:
I-Al-Istannen 2020-04-08 20:28:57 +02:00
parent dd71e3a84c
commit 12801c5627

View file

@ -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