Merge branch 'devel' of github.com:Araq/Nimrod into devel

This commit is contained in:
Zahary Karadjov 2014-03-09 14:02:16 +02:00
commit 5820093e58
12 changed files with 202 additions and 82 deletions

View file

@ -480,8 +480,8 @@ precedence and associativity; this is useful for meta programming.
Associativity
-------------
All binary operators are left-associative, except binary operators whose
relevant char is ``^``.
Binary operators whose relevant character is ``^`` are right-associative, all
other binary operators are left-associative.
Precedence
----------
@ -508,7 +508,7 @@ Precedence level Operators Relevant char
7 ``+ -`` ``+ ~ |`` OP7
6 ``&`` ``&`` OP6
5 ``..`` ``.`` OP5
4 ``== <= < >= > != in not_in is isnot not of`` ``= < > !`` OP4
4 ``== <= < >= > != in notin is isnot not of`` ``= < > !`` OP4
3 ``and`` OP3
2 ``or xor`` OP2
1 ``@ : ?`` OP1
@ -516,6 +516,46 @@ Precedence level Operators Relevant char
================ =============================================== ================== ===============
Strong spaces
-------------
The number of spaces preceeding a non-keyword operator affects precedence
if the experimental parser directive ``#!strongSpaces`` is used. Indentation
is not used to determine the number of spaces. If 2 or more operators have the
same number of preceeding spaces the precedence table applies, so ``1 + 3 * 4``
is still parsed as ``1 + (3 * 4)``, but ``1+3 * 4`` is parsed as ``(1+3) * 4``:
.. code-block:: nimrod
#! strongSpaces
if foo+4 * 4 == 8 and b&c | 9 ++
bar:
echo ""
# is parsed as
if ((foo+4)*4 == 8) and (((b&c) | 9) ++ bar): echo ""
Furthermore whether an operator is used a prefix operator is affected by the
number of spaces:
.. code-block:: nimrod
#! strongSpaces
echo $foo
# is parsed as
echo($foo)
This also affects whether ``[]``, ``{}``, ``()`` are parsed as constructors
or as accessors:
.. code-block:: nimrod
#! strongSpaces
echo (1,2)
# is parsed as
echo((1,2))
Grammar
-------
The grammar's start symbol is ``module``.
.. include:: grammar.txt