summary refs log blame commit diff stats
path: root/doc/manual/about.txt
blob: 13307279b48763a295e050cc3340c7d41d218a90 (plain) (tree)




































                                                                             
About this document
===================

**Note**: This document is a draft! Several of Nim's features need more
precise wording. This manual will evolve into a proper specification some
day.

This document describes the lexis, the syntax, and the semantics of Nim.

The language constructs are explained using an extended BNF, in
which ``(a)*`` means 0 or more ``a``'s, ``a+`` means 1 or more ``a``'s, and
``(a)?`` means an optional *a*. Parentheses may be used to group elements.

``&`` is the lookahead operator; ``&a`` means that an ``a`` is expected but
not consumed. It will be consumed in the following rule.

The ``|``, ``/`` symbols are used to mark alternatives and have the lowest 
precedence. ``/`` is the ordered choice that requires the parser to try the 
alternatives in the given order. ``/`` is often used to ensure the grammar
is not ambiguous. 

Non-terminals start with a lowercase letter, abstract terminal symbols are in
UPPERCASE. Verbatim terminal symbols (including keywords) are quoted
with ``'``. An example::

  ifStmt = 'if' expr ':' stmts ('elif' expr ':' stmts)* ('else' stmts)?
  
The binary ``^*`` operator is used as a shorthand for 0 or more occurances
separated by its second argument; likewise ``^+`` means 1 or more 
occurances: ``a ^+ b`` is short for ``a (b a)*`` 
and ``a ^* b`` is short for ``(a (b a)*)?``. Example::

  arrayConstructor = '[' expr ^* ',' ']'

Other parts of Nim - like scoping rules or runtime semantics are only
described in an informal manner for now.