hsemail-ns-1.7.7: Internet Message Parsers

Copyright(c) 2013 Peter Simons
LicenseBSD3
Maintainerphlummox2@gmail.com
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell98

Text.ParserCombinators.Parsec.Rfc2234NS

Contents

Description

This module provides parsers for the grammar defined in RFC2234, "Augmented BNF for Syntax Specifications: ABNF", http://www.faqs.org/rfcs/rfc2234.html. The terminal called char in the RFC is called character here to avoid conflicts with Parsec's char function.

Addendum for Nonstandard Version:

This module deviates from the RFC currently in

  • Allowing for non-standard line endings.

These allowances are subject to change, and should not be used when parsing incoming messages, only for parsing messages that have been stored on disk. The goal of these nonstandard parsers is to provide a higher probability of parsing common headers (rather than only those explicitly defined in the RFC) as well as allowing for potential oddities / changes that may occur during storage of an email message. These parsers have be rebranded so as not to conflict with the standard parsers available from the excellent hsemail package, upon which this package depends. For patches to this package only (namely 'hsemail-ns'), patches should be sent to phlummox2@gmail.com, for patches to the proper parsers, you can send them to the original maintainer.

Synopsis

Parser Combinators

caseChar :: Char -> CharParser st Char Source #

Case-insensitive variant of Parsec's char function.

caseString :: String -> CharParser st () Source #

Case-insensitive variant of Parsec's string function.

manyN :: Int -> GenParser a b c -> GenParser a b [c] Source #

Match a parser at least n times.

manyNtoM :: Int -> Int -> GenParser a b c -> GenParser a b [c] Source #

Match a parser at least n times, but no more than m times.

parsec2read :: Parser a -> String -> [(a, String)] Source #

Helper function to generate Parser-based instances for the Read class.

Primitive Parsers

alpha :: CharParser st Char Source #

Match any character of the alphabet.

bit :: CharParser st Char Source #

Match either "1" or "0".

character :: CharParser st Char Source #

Match any 7-bit US-ASCII character except for NUL (ASCII value 0, that is).

cr :: CharParser st Char Source #

Match the carriage return character \r.

lf :: CharParser st Char Source #

Match returns the linefeed character \n.

crlf :: CharParser st String Source #

Match the Internet newline \r\n.

crlfNS :: CharParser st String Source #

Non-standard newline - matches any of crlf, lfcr, cr, lf (in that order)

ctl :: CharParser st Char Source #

Match any US-ASCII control character. That is any character with a decimal value in the range of [0..31,127].

dquote :: CharParser st Char Source #

Match the double quote character """.

hexdig :: CharParser st Char Source #

Match any character that is valid in a hexadecimal number; ['0'..'9'] and ['A'..'F','a'..'f'] that is.

htab :: CharParser st Char Source #

Match the tab ("\t") character.

lwsp :: CharParser st String Source #

Match "linear white-space". That is any number of consecutive wsp, optionally followed by a crlf and (at least) one more wsp.

octet :: CharParser st Char Source #

Match any character.

sp :: CharParser st Char Source #

Match the space.

vchar :: CharParser st Char Source #

Match any printable ASCII character. (The "v" stands for "visible".) That is any character in the decimal range of [33..126].

wsp :: CharParser st Char Source #

Match either sp or htab.

Useful additions

quoted_pair :: CharParser st String Source #

Match a "quoted pair". Any characters (excluding CR and LF) may be quoted.

quoted_string :: CharParser st String Source #

Match a quoted string. The specials "\" and """ must be escaped inside a quoted string; CR and LF are not allowed at all.