EBNF has a special syntax for Kleene closure - any expression in braces can be repeated zero or more times:

syntax= syntax rule, {syntax rule};

Exceptions can be defined using minus sign. For example the following excerption form EBNF standard defines any symbol except single quotation mark:

first terminal character= terminal character - first quote symbol;

Full RBNF description can be found in ISO/IEC 14977 standard.

EBNF standard extensions

A few extensions to EBNF standard are implemented in the calculator above. As a special sequence you can use a regular expression or hexadecimal symbol code. E.g., for line feed you may use the following rule, defined by two hexadecimal symbols:

lineend= ?0xd?,?0xa?;

E.g. the following regular expression-based rule can be used for non printable symbols matching:

sp=?/\s+/?;

Grammar analysis

The calculator performs simple grammar analysis. It detects the following errors and unacceptable conditions:

Grammar syntax errors

Root rule missing

Single root rule check

Left recursion

Back-track free parsing condition

Scanning and parsing combined together

In classic compiler theory there is scanning step which produces tokens from the input stream. During scanning, all unnecessary symbols e.g. unprintable ones and comments get separated from tokens, which is used further on parsing step. Commonly scanners are based on regular expressions. This calculator does scanning and parsing in the same way using single grammar. Commonly, if you define a single grammar for scanning and parsing, the grammar become very complex. To simplify the grammar we allow to split whole grammar in multiple parts each of which has its own root rule. Remove rules input box defines the rules to be removed during preliminary parsing (scanning) steps. To see an example grammar with two parsing steps and tokens to be removed on preliminary parsing step click the following link: