Not perfect but it can parse the rainloop script to a tree and back to string

This commit is contained in:
djmaze 2021-01-14 12:45:51 +01:00
parent b2e77f3f67
commit 2786d0d959
5 changed files with 155 additions and 113 deletions

View file

@ -24,7 +24,10 @@ class Conditional
{
return this.identifier
+ ('else' !== this.identifier ? ' ' + this.test : '')
+ " {\r\n\t" + this.commands.join(";\r\n\t") + "\r\n}";
+ (this.commands.length
? ' {\r\n\t' + Sieve.arrayToString(this.commands, ';\r\n\t') + ';\r\n}'
: ';'
);
}
/*
public function pushArguments(array $args): void
@ -38,7 +41,7 @@ class Conditional
/**
* https://tools.ietf.org/html/rfc5228#section-3.2
*/
class Requires /* extends Array*/
class Require /* extends Array*/
{
constructor()
{
@ -47,7 +50,7 @@ class Requires /* extends Array*/
toString()
{
return 'require ' + this.capabilities;
return 'require ' + this.capabilities.toString();
}
pushArguments(args)
@ -86,7 +89,7 @@ class FileInto
toString()
{
return 'fileinto ' + this.mailbox;
return 'fileinto ' + this._mailbox;
}
get mailbox()
@ -159,11 +162,11 @@ class Discard
Sieve.Commands = {
// Control commands
Conditional: Conditional,
Requires: Requires,
Require: Require,
Stop: Stop,
// Action commands
Discard: Discard,
FileInto: FileInto,
Fileinto: FileInto,
Keep: Keep,
Redirect: Redirect
};