sexp-0.7: S-Expression parsing/printing made fun and easy

Safe HaskellNone

Language.Sexp.Parser

Synopsis

Documentation

data Sexp Source

A ByteString-based S-Expression. Conceptually, a Sexp is either an single atom represented by a ByteString, or a list of Sexp.

Constructors

List [Sexp] 
Atom ByteString 

sexpParser :: Parser SexpSource

A parser for S-Expressions. Ignoring whitespace, we follow the following EBNF:

SEXP ::= '(' ATOM* ')' | ATOM ATOM ::= '' ESCAPED_STRING* '' | [^ tn()]+ ESCAPED_STRING ::= ...

parse :: ByteString -> Either (String, ByteString) [Sexp]Source

Parse S-Expressions from a lazy ByteString. If the parse was successful, Right sexps is returned; otherwise, Left (errorMsg, leftover) is returned.

parseExn :: ByteString -> [Sexp]Source

A variant of parse that throws a ParseException if the parse fails.

parseMaybe :: ByteString -> Maybe [Sexp]Source

A variant of parse that returns Nothing if the parse fails.