snappymail/dev/Sieve/Extensions/rfc5229.js

72 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-03-09 19:33:31 +08:00
/**
* https://tools.ietf.org/html/rfc5229
*/
import {
ActionCommand,
2022-03-09 19:33:31 +08:00
GrammarQuotedString,
GrammarStringList,
TestCommand
2022-03-09 19:33:31 +08:00
} from 'Sieve/Grammar';
export class SetCommand extends ActionCommand
2022-03-09 19:33:31 +08:00
{
constructor()
{
super();
this.modifiers = [];
this._name = new GrammarQuotedString;
this._value = new GrammarQuotedString;
}
get require() { return 'variables'; }
toString()
{
return 'set'
+ ' ' + this.modifiers.join(' ')
+ ' ' + this._name
+ ' ' + this._value;
}
get name() { return this._name.value; }
set name(str) { this._name.value = str; }
get value() { return this._value.value; }
set value(str) { this._value.value = str; }
pushArguments(args)
{
[':lower', ':upper', ':lowerfirst', ':upperfirst', ':quotewildcard', ':length'].forEach(modifier => {
args.includes(modifier) && this.modifiers.push(modifier);
});
2022-03-15 16:58:04 +08:00
this._value = args.pop();
this._name = args.pop();
2022-03-09 19:33:31 +08:00
}
}
export class StringTest extends TestCommand
2022-03-09 19:33:31 +08:00
{
constructor()
{
super();
this.source = new GrammarStringList;
this.key_list = new GrammarStringList;
}
toString()
{
return 'string'
+ ' ' + this.match_type
+ (this.comparator ? ' :comparator ' + this.comparator : '')
2022-03-16 21:21:23 +08:00
+ ' ' + this.source
+ ' ' + this.key_list;
2022-03-09 19:33:31 +08:00
}
pushArguments(args)
{
2022-03-15 16:58:04 +08:00
this.key_list = args.pop();
this.source = args.pop();
2022-03-09 19:33:31 +08:00
}
}