The EmailParser class provides parser help for RFC 822-like grammars. It properly is more like a lexer than a parser, but also not quite like a lexer.
EmailParser provides a cursor, and member functions to read many RFC 2822 productions at the cursor. Generally, each member returns the production read or an empty string.
Creates a new RFC 822 parser object to parse s.
Returns a single atom, stepping past white space and comments before and after it.
Returns the number of CFWS characters at the cursor, but does nothing else.
Moves pos() past all comments and surrounding white space, and returns the contents of the last comment.
Returns a null string if there was no comment.
Do RFC 2047 decoding of s, totally ignoring what the encoded-text in s contains.
Depending on circumstances, the encoded-text may contain different sets of characters. Moreover, not every 2047 encoder obeys the rules. This function checks nothing, it just decodes.
Returns a single domain and steps past it.
This isn't correct at the moment, but I think it will eventually be...
Note that our definition of domain differs from the RFC 822 one. We only accept three forms: Something that may be a DNS A record, something that may be an IPv4 address in '' and something that may be an IPv6 address, again in ''. Examples: 'lupinella.troll.no', '[126.96.36.199]' and '[IPv6:::ffff:188.8.131.52]'.
Returns a dot-atom, stepping past all relevant whitespace and comments.
Steps past a MIME encoded-word (as defined in RFC 2047) and returns its decoded unicode representation, or an empty string if the cursor does not point to a valid encoded-word. The caller is responsible for checking that the encoded-word is separated from neighbouring tokens by whitespace.
The characters permitted in the encoded-text are adjusted based on type, which may be Text (by default), Comment, or Phrase.
Steps past a sequence of adjacent encoded-words with whitespace in between and returns the decoded representation. t passed through to encodedWord().
Leading and trailing whitespace is trimmed, internal whitespace is kept as is.
Returns true if c belongs to the RFC 2822 'atext' production, and false in all other circumstances.
Returns true if this parser has been instructed to parse MIME strings by calling setMime(), and false otherwise.
Returns the last comment seen so far by this parser, or a null string if none has been seen yet.
Returns a single MIME token (as defined in RFC 2045 section 5), which is an atom minus [/?=] plus [.].
Returns a single MIME value (as defined in RFC 2045 section 5), which is an atom minus [/?=] plus [.] (i.e., a MIME token) or a quoted string.
Skips past whitespace, parses a decimal number and returns that number.
Steps past an RFC 822 phrase (a series of word/encoded-words) at the cursor and returns its unicode representation, which may be an empty string.
Sets this EmailParser object to parse MIME strings if m is true, and RFC 2822 strings if m is false. The only difference is the definition of specials.
Steps past an atom or a quoted-text, and returns that text.
Steps past the longest "*text" (a series of text/encoded-words) at the cursor and returns its unicode representation, which may be an empty string.
Returns true if this parser has not yet encountered any errors during parsing, and false otherwise.
This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.