BNF

  • {x} represents "zero or more of x".
  • [x] represents "zero or one of x".
  • [[x]] represents PCRE-like character classes in "x".
  • // represents a comment until the end of the line.

<BNF> ::= {<statement>};
 
<statement>  ::= {<whitespace>} [<time-specifier> {<whitespace>}] (<assignment> | <expression>) <eol>;
<assignment> ::= <identifier> {<whitespace>} "=" {<whitespace>} <expression>;
 
<time-specifier> ::= "[" {<whitespace>}
                          <expression> {<whitespace> "," {<whitespace>} <expression>}
                          {<whitespace>} "]";
 
<expression> ::= <sum>;
<sum>        ::= <product> [{<whitespace>} ("+" | "-") {<whitespace>} <product>];
<product>    ::= <factor> [{<whitespace>} ("*" | "/") {<whitespace>} <factor>];
<factor>     ::= ["-" {<whitespace>}] (<function-call> | <number> | <identifier> | "(" <expression> ")");
 
<function-call> ::= <identifier> {[<identifier> ":"] {<whitespace>} <factor>};
 
<comment>    ::= "//" {<not-eol>} <eol>;
 
<identifier> ::= (<alpha> | <underscore>) {<alpha> | <digit> | <underscore>};
<number>     ::= {<digit>} | {<digit>} "." <digit> {<digit>} | <digit> {<digit>} "." {<digit>};
<string>     ::= [["]] {<string-character>} [["]];
 
<string-character> ::= "\\" [[^]] | [[^"]];  // ^ is 'any character'; ^" is not-quote
 
<eol>        ::= [[\n]];
<not-eol>    ::= [[^\n]];
<whitespace> ::= [[ \n\r\t]];
<alpha>      ::= [[a-zA-Z]];        // Maybe expand?
<digit>      ::= [[0-9]];
<underscore> ::= [[_]];

Comments

Post new comment

By submitting this form, you accept the Mollom privacy policy.