bnf.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 22 Feb 2016 12:46:36 +0200
changeset 1905 fba288d59662
child 1912 8b81a8f0f692
permissions -rw-r--r--
Include only local subsections into TOC. This prevent duplication of TOC when build single page HTML document. Also this make unnecessary CSS hack to hide document title as top level section.

.. -*- coding: utf-8; -*-
.. include:: HEADER.rst

=====
 BNF
=====

What is BNF?
============
.. contents::
   :local:

BNF is an acronym for "Backus Naur Form". John Backus and Peter Naur introduced
for the first time a formal notation to describe the syntax of a given language
(ALGOL 60 programming language).

See: :rfc:`2234`.

BNF syntax
==========

The meta-symbols of BNF are:

  ``::=``
    Meaning "is defined as".
  ``|``
    Meaning "or".
  ``<``,  ``>``
    Angle brackets used to surround category names (some times skipped).
  ``[``,  ``]``
    Optional items are enclosed in.
  ``{``,  ``}``
    Repetitive items (zero or more times) are enclosed in.
  ``"abc..."``
    Terminals are enclosed in to distinguish them from meta-symbols.

BNF in BNF
==========
::

  syntax     ::=  { rule }
  rule       ::=  identifier  "::="  expression
  expression ::=  term { "|" term }
  term       ::=  factor { factor }
  factor     ::=  identifier |
                  quoted_symbol |
                  "("  expression  ")" |
                  "["  expression  "]" |
                  "{"  expression  "}"
  identifier ::=  letter { letter | digit }
  quoted_symbol ::= """ { any_character } """