Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 1.49 KB

File metadata and controls

46 lines (34 loc) · 1.49 KB

DSL Specification

Grammar

The grammar is written in EBNF

To not waste space in the grammar, we define some of the productions with words:

  • string: A string as defined by RFC8259(JSON RFC). Except we don't support multiline strings.
  • alpha_lower: Any lowercase ASCII alphabetic character (a-z)
  • digit: A digit (0-9)
config        = { definition } ;
definition    = rule | folder ;

rule          = 'rule', identifier, '{', { rule_pair }, '}' ;
rule_pair     = 'matcher', ':', matcher
              | 'action',  ':', action ;

matcher       = and_matcher ;
and_matcher   = 'and', match_list | or_matcher ;
or_matcher    = 'or',  match_list | not_matcher ;
not_matcher   = 'not', msg_matcher | msg_matcher ;
msg_matcher   = 'subject', string_matcher
              | 'from',    string_matcher
              | 'to',      string_matcher
              | 'body',    string_matcher
              | '(', matcher, ')' ;

string_matcher
              = 'contains',  string
              | 'startswith', string
              | 'equals',     string
              | 'regex',      string ;

match_list    = '[', { matcher }, ']' ;

action        = 'delete' | 'moveto' '[' identifier ']' ;

folder        = 'folder', identifier, '{', { folder_pair }, '}' ;
folder_pair   = 'name', ':', string ;

identifier    = alpha-lower, { identifier1 } ;
identifier1  = alpha-lower | digit | '_' ;