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:
parent
dd71e3a84c
commit
12801c5627
1 changed files with 1 additions and 1 deletions
|
|
@ -114,7 +114,7 @@ instruction = small <|> large
|
||||||
stop <- getOffset
|
stop <- getOffset
|
||||||
pure $ LargeInstruction (Span start stop) lo sv
|
pure $ LargeInstruction (Span start stop) lo sv
|
||||||
optionalAwareArgument (LargeOpcode _ code)
|
optionalAwareArgument (LargeOpcode _ code)
|
||||||
| Vm.argumentIsOptional code = optional (inlineSpace1 *> smallValue <?> "argument")
|
| Vm.argumentIsOptional code = optional $ try (inlineSpace1 *> smallValue <?> "argument")
|
||||||
| otherwise = Just <$> (inlineSpace1 *> smallValue <?> "argument")
|
| otherwise = Just <$> (inlineSpace1 *> smallValue <?> "argument")
|
||||||
|
|
||||||
singleDirective
|
singleDirective
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue