Backus-Naur Form (BNF) grammars
EpochX uses BNF grammars in its grammatical evolution and context-free grammar GP representations. BNF grammars are a form of context-free grammar that can be used to define syntax rules for a language.

There are a number of subtle variations of BNF around, Grammars in EpochX do not use most of the extensions that are described as EBNF.

  • The '|' character is used to separate production choices.
  • Strings can be escaped by surrounding them in quotes '"'.
  • Characters that should be escaped to be treated as a literal include the bar '|', greater than '>' and less than '<' characters.
  • Non-terminals should be surround by '<' and '>' characters, whether they're used on the LHS or RHS of a rule.
  • Terminals (literals) do not need to be surrounded by quotes unless they're being escaped.

Example EpochX compatible BNF grammar rule:

<ifstatement> ::= if ( $a "<" 4 ) { <statement> }

Where the non-terminals are underlined.