summary refs log tree commit diff stats
path: root/doc/manual.txt
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2014-03-09 14:02:16 +0200
committerZahary Karadjov <zahary@gmail.com>2014-03-09 14:02:16 +0200
commit5820093e58bd975d5d0de7be2df6af3a84418fb5 (patch)
tree205531868276b3369ae46542f39dae437e56d8fe /doc/manual.txt
parent4b09a897583a38bea144e86b8b99b1347b525280 (diff)
parent7704cdc90ec187ef22f259f0e0f89ceeb5c13431 (diff)
downloadNim-5820093e58bd975d5d0de7be2df6af3a84418fb5.tar.gz
Merge branch 'devel' of github.com:Araq/Nimrod into devel
Diffstat (limited to 'doc/manual.txt')
-rw-r--r--doc/manual.txt46
1 files changed, 43 insertions, 3 deletions
diff --git a/doc/manual.txt b/doc/manual.txt
index 04050a99e..748d41d4b 100644
--- a/doc/manual.txt
+++ b/doc/manual.txt
@@ -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