Class SieveParser.

Inherits AbnfParser

The SieveParser class does all the ABNF-related work for sieve scripts. The SieveProduction class and its subclasses do the other part of parsing: The Sieve ABNF grammar doesn't guarantee that "if" has a test as argument, etc.

SieveParser::SieveParser( const EString & s )

Constructs a Sieve parser for s. Doesn't actually do anything; the caller must call commands() or other functions to parse the script.

Reimplements AbnfParser::AbnfParser().

SieveArgument * SieveParser::argument()

Parses, constructs and returns a SieveArgument object. Never returns 0.

argument = string-list / number / tag

SieveArgumentList * SieveParser::arguments()

arguments = *argument [test / test-list]

This is tricky. The first difficult bit. This class takes either a list of SieveArgument objects, or a SieveTest, or a list of SieveTest objects. We implement both the arguments and tests productions in this function.

List<SieveProduction> * SieveParser::bad( SieveProduction * toplevel )

Returns a list of the SieveProduction objects that have been parsed by this object, have errors and have toplevel as their ultimate SieveProduction::parent().

The list may be empty (hopefully that is the common case) but the returned pointer is never null.

SieveBlock * SieveParser::block()

block = "{" *command "}"

void SieveParser::bracketComment()

Parses/skips a bracket comment: bracket-comment = "/" "*" *not-star 1*STAR *(not-star-slash *not-star 1*STAR) "/"

No "*" "/" allowed inside a comment. (No * is allowed unless it is the last character, or unless it is followed by a character that isn't a slash.)

SieveCommand * SieveParser::command()

command = identifier arguments ( ";" / block )

List<SieveCommand> * SieveParser::commands()

commands = *command

start = commands

Never returns a null pointer.

void SieveParser::comment()

Parses/skips a comment: comment = bracket-comment / hash-comment.

EString SieveParser::comparator()

COMPARATOR = ":comparator" string

Returns just the string, not ":comparator" or the whitespace.

EStringList * SieveParser::extensionsNeeded() const

Returns a list of the strings specified to rememberNeededExtension(), freed of duplication. The return value is never a null pointer.

void SieveParser::hashComment()

Parses/skips a hash-cmment: hash-comment = "#" *octet-not-crlf CRLF

EString SieveParser::identifier()

identifier = (ALPHA / "_") *(ALPHA / DIGIT / "_")

Records an error if no identifier is present.

UString SieveParser::multiLine()

multi-line = "text:" *(SP / HTAB) (hash-comment / CRLF) *(multiline-literal / multiline-dotstuff) "." CRLF

multiline-literal = [octet-not-period *octet-not-crlf] CRLF

multiline-dotstuff = "." 1*octet-not-crlf CRLF

Returns an empty string if the cursor doesn't point at a multi-line string.

uint SieveParser::number()

number = 1*DIGIT [ QUANTIFIER ]

QUANTIFIER = "K" / "M" / "G"

Returns 0 and calls setError() in case of error.

Reimplements AbnfParser::number().

UString SieveParser::quotedString()

quoted-string = DQUOTE quoted-text DQUOTE

quoted-text = *(quoted-safe / quoted-special / quoted-other)

quoted-other = "\" octet-not-qspecial

quoted-safe = CRLF / octet-not-qspecial

quoted-special = "\" ( DQUOTE / "\" )

void SieveParser::rememberBadProduction( SieveProduction * p )

Adds p to the list of bad sieve productions generated by this parser. Provided as a public function because a sieve production may discover its badness long after SieveParser has done its job.

void SieveParser::rememberNeededExtension( const EString & extension )

Adds extension to the list of extensions needed by the generated productions. The SieveProduction subclasses call this, ie. using SieveParser as a common storage object.

UString SieveParser::string()

string = quoted-string / multi-line

UStringList * SieveParser::stringList()

string-list = "[" string *("," string) "]" / string

If there is only a single string, the brackets are optional.

Never returns a null pointer.

EString SieveParser::tag()

tag = ":" identifier

SieveTest * SieveParser::test()

test = identifier arguments

void SieveParser::whitespace()

Parses and skips whatever whitespace is at pos().

This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.