.. _grammar:

Definition file grammar
///////////////////////

+-----------------------------------+-----------------------------------+
| **Token**                         |    **Meaning**                    |
+===================================+===================================+
|    ‘*’                            |    Zero or more                   |
+-----------------------------------+-----------------------------------+
|    ‘!’                            |    Zero or one                    |
+-----------------------------------+-----------------------------------+
|    ‘+’                            |    One or more                    |
+-----------------------------------+-----------------------------------+
|    ‘>>’                           | Sequence/concatenation            |
+-----------------------------------+-----------------------------------+
|    ‘|’                            |    alternate                      |
+-----------------------------------+-----------------------------------+
|    ‘-‘                            |    not                            |
+-----------------------------------+-----------------------------------+

.. productionlist::
    defs: *( `nextline` | `extern` ) >> +`suite` >> EOL
    extern: "extern" >> ( `absolutepath`  >> !( ":" >> `identifier` ) 
          : >> +`nextline`
    suite: "suite" >> `suiteName` >> *( `variable` | `inlimit` | 
         :  `defstatus`  | `limit` | `late` | `clock` | `repeat` | 
         :  `autocancel` | `zombie` ) >> *( `family` | `task` ) >> `endsuite`
    family: "family" >> `familyName` >> !`leaf_ecf` >> *(`task` | `family`) 
          : >> `endfamily`
    task: "task"  >> `taskName`  >> `leaf_ecf`  >> !endtask
    leaf_ecf: *( `variable` | `trigger` | `time` | `today` |
            :   `date` | `day` | `defstatus` | `complete` | `inlimit` |
            :   `label` | `event` | `late` | `limit` | `meter` | `repeat` |
            :   `cron` | `autocancel` | `zombie`
            : )
            : | `aviso`
            : | `mirror`
    clock: "clock" >> ( "real"| "hybrid" ) >> 
         : ( ( `clock_date` >> !(`hh_mm` | int ) ) | (`hh_mm` | int )) 
         : >> +`nextline`
    trigger: "trigger"  >> `expression` >> +`nextline`
    complete: "complete" >> `expression` >> +`nextline`
    variable: "edit" >> `identifier` >> `varvalue` >> +`nextline`
    label: "label" >> `identifier` >> `quotedstring`  >> +`nextline`
    aviso: "aviso" >>
         :   *( "--name" >> `identifier`
         :     | "--listener" >> "'" >> `jsonstring` >> "'"
         :     | "--url" >> ( `varvalue` | `string` )
         :     | "--polling" >> (`varvalue` | +(integer))
         :     | "--schema" >> ( `varvalue` | `string` )
         :     | "--auth" >> ( `varvalue` | `string` )
         :   )
    mirror: "mirror" >>
          :   *( "--name" >> `identifier`
          :     | "--remote_path" >> `string`
          :     | "--remote_host" >> ( `varvalue` | `string` )
          :     | "--remote_port" >> ( `varvalue` | `string` )
          :     | "--polling" >> (`varvalue` | +(integer))
          :     | "--auth" >> ( `varvalue` | `string` )
          :     | --ssl
          :   )
    time: "time" >> !'+ >> (`timeseries` | `two_int_p` >> 
        : “:” `two_int_p`) >> +`nextline`
    today: "today" >> !'+ >> (`timeseries` | `two_int_p` >> 
         : “:” `two_int_p` ) >> +`nextline`
    day: "day" >> (“monday” | “tuesday” | “wednesday” | 
       : “thursday” | “friday” | “saturday” | “sunday”) 
       : + `nextline`
    date: "date"  >> !’+’ >> (  `two_int_p` | ‘*’  )  >> "." >> 
        : ( `two_int_p` | ‘*’) >> "." >> (`two_int_p` | ‘*’)
    autocancel: "autocancel"  >> !’+’ >> 
              : (( `two_int_p` >> ‘:’ >> `two_int_p`) |
              : unsigned integer) >> +`nextline`
    limit: "limit" >> ( `identifier` >> unsigned int ) >> +`nextline`
    inlimit: "inlimit" >>( (`nodePath` >> ":“ >>
           : `identifier`) | `identifier` )) >> ! unsigned int >> +`nextline`
    event: `eventcontent2` | `eventcontent1`;
    eventcontent1: "event”  >> ( `eventnumber`  |  `eventname`  ) >> +`nextline`
    eventcontent2: "event”  >> ( `eventnumber`  >> `eventname`  ) >> +`nextline`
    meter: "meter" >> `identifier` >> ( int >> int >> !unsigned int)
         : >> +`nextline`
    defstatus: "defstatus" >> `dstate`  >> +`nextline`
    endsuite: "endsuite" >> *`nextline`
    endfamily: "endfamily" >> +`nextline`
    endtask: "endtask" >> +`nextline`
    zombie: "zombie" >> `zombie_type` >> ":" >> 
          : !(`client_side_action` | `server_side_action`)
          : >> ":" >> *`child` >> ":" >> !`zombie_life_time`
    zombie_type: "user" | "ecf" | "path"
    child: "init" | "event" | "meter" | "label" | "wait" |
         : "abort" | "complete"
    client_side_action: "fob" | "fail" | "block"
    server_side_action: "adopt" | "delete" | "kill"
    zombie_life_time: unsigned integer  ( default:  user(300), ecf(3600), 
                    : path(900)  )
    late: "late" >> `late_option` >> !`late_option`  >>
        : !`late_option` >> +`nextline`
    late_option: "-c" >> `hh_mm` | ("-s" >> `hh_mm` ) | "-a" >> `hh_mm`
    repeat: "repeat" >> `repeat_type` >> +`nextline`
    repeat_type: `repeat_datetime` | `repeat_date` |
               : `repeat_day` | `repeat_month` | `repeat_year` |
               : `repeat_integer` | `repeat_enumerated` | `repeat_string` | 
               : `repeat_datelist`
    repeat_day: "day" >> unsigned integer >> !`ymd`
    repeat_integer: "integer" >> `identifier` >> integer >> " " >> 
                  : integer >> " " >> integer
    repeat_enumerated: "enumerated" >> `identifier` >> +`identifier`
    repeat_string: "string" >> `identifier` >> +`identifier`
    repeat_date: "date" >> `identifier` >> `ymd` >> `ymd` >> integer
    repeat_datetime: "datetime" >> `identifier` >>
                   : `instant` >> `instant` >> `duration`
    repeat_datelist: "datelist" >> `identifier` >> +( `ymd` )
    varvalue: `tickquotedstring` | `quotedstring` | `identifier`
    suiteName: `node_name` >> +`nextline`
    familyName: `node_name` >> +`nextline`
    taskName: `node_name` >> +`nextline`
    nodestate: "complete” | "unknown” | "queued" | "aborted" | 
             : “active”
    dstate: "complete” | "unknown” | "queued" | "aborted" | 
          : “active” | “suspended”
    eventnumber: unsigned integer
    eventname: `identifier`
    hh_mm: !'+' >> `two_int_p` >> ":" >> `two_int_p`
    clock_date: (  `two_int_p` | ‘*’  )  >> "." >> 
              : (  `two_int_p` | ‘*’  ) >> "." >> (`two_int_p` | ‘*’)
    cron: "cron" >> ((‘-w >> +int) | (‘-d’ >> +int) | 
        : (‘-m’ >> +int)) >> `timeseries` >> +`nextline`
    node_name: (alpha_numeric | ‘_’ )  
             : >> *(alpha_numeric | ‘_’ | ‘.’ )
    comment: ’#’ >> printable chars > `newline`
    nextline: `newline` | `comment`
    timeseries: `two_int_p` >> “:” >> `two_int_p` >>  `two_int_p` >>
              : “:” >> `two_int_p` >> `two_int_p` >> “:” >> `two_int_p`
    quotedstring: ’”‘ >> *(printable chars) >> ‘”’
    tickquotedstring: ’'’ >> *(print_p - `nextline`) ]
    absolutepath: !’/’ >> `identifier` >> *( ‘/’ >> `identifier` )
    dotdotpath: ".."  >> +( ‘/’ >> `identifier` )
    dotpath: ‘.’  >> +( ‘/’  >> `identifier` )
    identifier: (alpha_numeric | ‘_’)  >> *(alpha_numeric | ‘_’)
    nodePath: `absolutepath` | `dotdotpath` | `dotpath`
    expression: `printable_chars` >> !’\’ >> `nextline`
    int_p: integer
    two_int_p: 2 digit integer
    theYear: 4 digit integer
    ymd: 8 digit integer
    instant: `theYear` >> `two_int_p` >> `two_int_p` >>
           : "T" >> `two_int_p` >> `two_int_p` >> `two_int_p`
    duration: `int_p` >> ":" >> `two_int_p` >> ":" >> `two_int_p`
    newline: \n
    string: `printable_chars` >> *(`printable_chars`)
    jsonstring : __ as per JSON format specification __
    printable_chars : "a-zA-Z"
