on 5e2000e help sign in
25 lines 705 B history raw
1module Language.JSON.String.Parser
3import Language.JSON.String.Tokens
4import Text.Lexer
5import Text.Parser
7%access private
8%default total
10stringChar : Grammar JSONStringToken True Char
11stringChar = match JSTChar
12 <|> match JSTSimpleEscape
13 <|> match JSTUnicodeEscape
15quotedString : Grammar JSONStringToken True String
16quotedString = let q = match JSTQuote in
17 do chars <- between q q (many stringChar)
18 eof
19 pure $ pack chars
21export
22parseString : List JSONStringToken -> Maybe String
23parseString toks = case parse quotedString toks of
24 Right (str, []) => Just str
25 _ => Nothing