json: Refactor string parser
This commit is contained in:
parent
91e1d2c9b1
commit
4fb5707b25
1 changed files with 9 additions and 7 deletions
|
@ -209,13 +209,15 @@ array = do
|
||||||
|
|
||||||
```idris
|
```idris
|
||||||
string = do
|
string = do
|
||||||
_ <- parseExactChar '"'
|
str <- parseString $ delimited '"' '"' (many stringCharacter)
|
||||||
|
pure $ VString str
|
||||||
|
where
|
||||||
-- TODO: Handle control characters properly
|
-- TODO: Handle control characters properly
|
||||||
|
stringCharacter : Parser Char
|
||||||
|
stringCharacter = do
|
||||||
e1 <- parseError "Expected non-quote, got quote"
|
e1 <- parseError "Expected non-quote, got quote"
|
||||||
e2 <- parseError "End of input"
|
e2 <- parseError "End of input"
|
||||||
contents <- parseString . many $ parseCharE (not . (== '"')) (\_ => e1) e2
|
parseCharE (not . (== '"')) (\_ => e1) e2
|
||||||
_ <- parseExactChar '"'
|
|
||||||
pure $ VString contents
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```idris
|
```idris
|
||||||
|
|
Loading…
Add table
Reference in a new issue