sexp-grammar-1.2.3: Invertible parsers for S-expressions

Safe HaskellNone
LanguageHaskell2010

Language.Sexp

Contents

Synopsis

Parse and print

decode :: Text -> Either String Sexp Source #

Quickly decode a ByteString-formatted S-expression into Sexp structure

encode :: Sexp -> ByteString Source #

Quickly encode Sexp to non-indented ByteString

parseSexp :: FilePath -> Text -> Either String Sexp Source #

Parse a ByteString-formatted S-expression into Sexp structure. Takes file name for better error messages.

parseSexps :: FilePath -> Text -> Either String [Sexp] Source #

Parse a ByteString-formatted sequence of S-expressions into list of Sexp structures. Takes file name for better error messages.

parseSexp' :: Position -> Text -> Either String Sexp Source #

Parse a ByteString-formatted S-expression into Sexp structure. Takes file name for better error messages.

parseSexps' :: Position -> Text -> Either String [Sexp] Source #

Parse a ByteString-formatted sequence of S-expressions into list of Sexp structures. Takes file name for better error messages.

prettySexp :: Sexp -> Text Source #

Pretty-print a Sexp to a Text

prettySexps :: [Sexp] -> Text Source #

Pretty-print a list of Sexps as a sequence of S-expressions to a ByteString

Type

data Sexp Source #

Sexp ADT

Instances

Eq Sexp Source # 

Methods

(==) :: Sexp -> Sexp -> Bool #

(/=) :: Sexp -> Sexp -> Bool #

Ord Sexp Source # 

Methods

compare :: Sexp -> Sexp -> Ordering #

(<) :: Sexp -> Sexp -> Bool #

(<=) :: Sexp -> Sexp -> Bool #

(>) :: Sexp -> Sexp -> Bool #

(>=) :: Sexp -> Sexp -> Bool #

max :: Sexp -> Sexp -> Sexp #

min :: Sexp -> Sexp -> Sexp #

Show Sexp Source # 

Methods

showsPrec :: Int -> Sexp -> ShowS #

show :: Sexp -> String #

showList :: [Sexp] -> ShowS #

data Atom Source #

Sexp atom types

Instances

Eq Atom Source # 

Methods

(==) :: Atom -> Atom -> Bool #

(/=) :: Atom -> Atom -> Bool #

Ord Atom Source # 

Methods

compare :: Atom -> Atom -> Ordering #

(<) :: Atom -> Atom -> Bool #

(<=) :: Atom -> Atom -> Bool #

(>) :: Atom -> Atom -> Bool #

(>=) :: Atom -> Atom -> Bool #

max :: Atom -> Atom -> Atom #

min :: Atom -> Atom -> Atom #

Show Atom Source # 

Methods

showsPrec :: Int -> Atom -> ShowS #

show :: Atom -> String #

showList :: [Atom] -> ShowS #

newtype Kw Source #

Keyword newtype wrapper to distinguish keywords from symbols

Constructors

Kw 

Fields

Instances

Eq Kw Source # 

Methods

(==) :: Kw -> Kw -> Bool #

(/=) :: Kw -> Kw -> Bool #

Ord Kw Source # 

Methods

compare :: Kw -> Kw -> Ordering #

(<) :: Kw -> Kw -> Bool #

(<=) :: Kw -> Kw -> Bool #

(>) :: Kw -> Kw -> Bool #

(>=) :: Kw -> Kw -> Bool #

max :: Kw -> Kw -> Kw #

min :: Kw -> Kw -> Kw #

Show Kw Source # 

Methods

showsPrec :: Int -> Kw -> ShowS #

show :: Kw -> String #

showList :: [Kw] -> ShowS #

Position

getPos :: Sexp -> Position Source #

Get position of Sexp element