Simplify Sieve Parser and added RFC5235

This commit is contained in:
djmaze 2021-01-14 23:42:46 +01:00
parent 22964f1fde
commit d9865e3a46
11 changed files with 308 additions and 92 deletions

View file

@ -23,9 +23,7 @@ class Conditional extends Command
toString()
{
return this.identifier
+ ('else' !== this.identifier ? ' ' + this.test : '')
+ ' ' + this.commands;
return this.identifier + ' ' + this.test + ' ' + this.commands;
}
/*
public function pushArguments(array $args): void
@ -36,6 +34,35 @@ class Conditional extends Command
*/
}
class If extends Conditional
{
constructor()
{
super('if');
}
}
class ElsIf extends Conditional
{
constructor()
{
super('elsif');
}
}
class Else extends Conditional
{
constructor()
{
super('else');
}
toString()
{
return this.identifier + ' ' + this.commands;
}
}
/**
* https://tools.ietf.org/html/rfc5228#section-3.2
*/
@ -83,13 +110,12 @@ class Stop extends Command
*/
class FileInto extends Command
{
// const REQUIRE = 'fileinto';
constructor()
{
super('fileinto');
// QuotedString / MultiLine
this._mailbox = new Grammar.QuotedString();
// this.require = 'fileinto';
}
toString()
@ -177,14 +203,17 @@ class Discard extends Command
Sieve.Commands = {
// Control commands
Conditional: Conditional,
Require: Require,
Stop: Stop,
if: If,
elsif: ElsIf,
else: Else,
conditional: Conditional,
require: Require,
stop: Stop,
// Action commands
Discard: Discard,
Fileinto: FileInto,
Keep: Keep,
Redirect: Redirect
discard: Discard,
fileinto: FileInto,
keep: Keep,
redirect: Redirect
};
})(this.Sieve);