json: parse char result
This commit is contained in:
parent
40251a1455
commit
08a2f263bb
1 changed files with 7 additions and 4 deletions
|
@ -110,7 +110,7 @@ whitespace : Parser Char
|
|||
whitespace = do
|
||||
pnote "Whitespace character"
|
||||
result <-
|
||||
parseChar (\x => any (== x) $ the (List _) [' ', '\n', '\r', '\t']) id
|
||||
parseChar (\x => any (== x) $ the (List _) [' ', '\n', '\r', '\t'])
|
||||
case result of
|
||||
GotChar char => pure char
|
||||
GotError err => throwParseError "Expected whitespace, got: \{show err}"
|
||||
|
@ -221,9 +221,12 @@ string = do
|
|||
-- TODO: Handle control characters properly
|
||||
stringCharacter : Parser Char
|
||||
stringCharacter = do
|
||||
e1 <- parseError "Expected non-quote, got quote"
|
||||
e2 <- parseError "End of input"
|
||||
parseCharE (not . (== '"')) (\_ => e1) e2
|
||||
result <- parseChar (not . (== '"'))
|
||||
case result of
|
||||
GotChar char => pure char
|
||||
GotError err =>
|
||||
throwParseError "Expected string character, got \{show err}"
|
||||
EndOfInput => throwParseError "Unexpected end of input"
|
||||
```
|
||||
|
||||
```idris
|
||||
|
|
Loading…
Add table
Reference in a new issue