Codec.Sexpr.Parser
Description
All present parsers work on Strings, one character at a time. The canonical encoding is clearly susceptible to efficient parsing as a Lazy ByteString.
This package also includes the Read instance for Sexprs.
From Rivest's documentation:
<sexpr> :: <string> | <list>
<string> :: <display>? <simple-string> ;
<simple-string> :: <raw> | <token> | <base-64> | <hexadecimal> |
<quoted-string> ;
<display> :: "[" <simple-string> "]" ;
<raw> :: <decimal> ":" <bytes> ;
<decimal> :: <decimal-digit>+ ;
-- decimal numbers should have no unnecessary leading zeros
<bytes> -- any string of bytes, of the indicated length
<token> :: <tokenchar>+ ;
<base-64> :: <decimal>? "|" ( <base-64-char> | <whitespace> )* "|" ;
<hexadecimal> :: "#" ( <hex-digit> | <white-space> )* "#" ;
<quoted-string> :: <decimal>? <quoted-string-body>
<quoted-string-body> :: "\"" <bytes> "\""
<list> :: "(" ( <sexp> | <whitespace> )* ")" ;
<whitespace> :: <whitespace-char>* ;
<token-char> :: <alpha> | <decimal-digit> | <simple-punc> ;
<alpha> :: <upper-case> | <lower-case> | <digit> ;
<lower-case> :: "a" | ... | "z" ;
<upper-case> :: "A" | ... | "Z" ;
<decimal-digit> :: "0" | ... | "9" ;
<hex-digit> :: <decimal-digit> | "A" | ... | "F" | "a" | ... | "f" ;
<simple-punc> :: "-" | "." | "/" | "_" | ":" | "*" | "+" | "=" ;
<whitespace-char> :: " " | "\t" | "\r" | "\n" ;
<base-64-char> :: <alpha> | <decimal-digit> | "+" | "/" | "=" ;
<null> :: "" ;
- readSexprString :: String -> Sexpr String
- readCanonicalSexprString :: String -> Sexpr String
- readSexpr :: Read a => String -> Sexpr a
- sexpr :: Bool -> ReadP (Sexpr String)
- canonicalSexpr :: ReadP (Sexpr String)
- advancedSexpr :: ReadP (Sexpr String)
- internalSexpr :: Bool -> ReadP (Sexpr String)
- basicTransport :: Bool -> ReadP (Sexpr String)
- b64char :: ReadP Char
- b64char' :: ReadP Char
- hexchar :: ReadP Char
- hexchar' :: ReadP Char
- listR :: Bool -> ReadP (Sexpr String)
- atomR :: Bool -> ReadP (Sexpr String)
- simpleString :: Bool -> ReadP String
- quotedString :: ReadP String
- hexAtom :: ReadP String
- hexDecode :: String -> String
- b64Atom :: ReadP String
- token :: ReadP String
- raw :: ReadP String
- decimal :: ReadP Int
Documentation
canonicalSexpr :: ReadP (Sexpr String)Source
For some applications it is wise to accept only very carefully specified input. This is useful when you know you are receiving exactly a Canonical S-Expression. It will read only a Canonical S-expression (and optional terminating NUL), but not the Basic or Advanced encodings.
simpleString :: Bool -> ReadP StringSource