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
|
whitespace = do
|
||||||
pnote "Whitespace character"
|
pnote "Whitespace character"
|
||||||
result <-
|
result <-
|
||||||
parseChar (\x => any (== x) $ the (List _) [' ', '\n', '\r', '\t']) id
|
parseChar (\x => any (== x) $ the (List _) [' ', '\n', '\r', '\t'])
|
||||||
case result of
|
case result of
|
||||||
GotChar char => pure char
|
GotChar char => pure char
|
||||||
GotError err => throwParseError "Expected whitespace, got: \{show err}"
|
GotError err => throwParseError "Expected whitespace, got: \{show err}"
|
||||||
|
@ -221,9 +221,12 @@ string = do
|
||||||
-- TODO: Handle control characters properly
|
-- TODO: Handle control characters properly
|
||||||
stringCharacter : Parser Char
|
stringCharacter : Parser Char
|
||||||
stringCharacter = do
|
stringCharacter = do
|
||||||
e1 <- parseError "Expected non-quote, got quote"
|
result <- parseChar (not . (== '"'))
|
||||||
e2 <- parseError "End of input"
|
case result of
|
||||||
parseCharE (not . (== '"')) (\_ => e1) e2
|
GotChar char => pure char
|
||||||
|
GotError err =>
|
||||||
|
throwParseError "Expected string character, got \{show err}"
|
||||||
|
EndOfInput => throwParseError "Unexpected end of input"
|
||||||
```
|
```
|
||||||
|
|
||||||
```idris
|
```idris
|
||||||
|
|
Loading…
Add table
Reference in a new issue