summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorReneSac <reneduani@yahoo.com.br>2015-04-11 17:22:09 -0300
committerReneSac <reneduani@yahoo.com.br>2015-04-11 17:22:09 -0300
commit06617bbb76d4b9ecc0c40072ca472c4b3428514a (patch)
tree37cc4177714717d243657777c8ee69961995d1fd
parent34997292f48d40e8ed49d84c999b6d32afa3b044 (diff)
downloadNim-06617bbb76d4b9ecc0c40072ca472c4b3428514a.tar.gz
Minor fixes for arrow like change patch
Don't use ^ operator yet for compatibility with older compilers.
Moved arrow like explanation, and fix precedence description on the text in the manual.
Fixed typo in news.
-rw-r--r--compiler/parser.nim4
-rw-r--r--doc/manual/syntax.txt7
-rw-r--r--web/news.txt2
3 files changed, 7 insertions, 6 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim
index 2d363638f..5aeb83495 100644
--- a/compiler/parser.nim
+++ b/compiler/parser.nim
@@ -212,8 +212,8 @@ proc getPrecedence(tok: TToken, strongSpaces: bool): int =
     let relevantChar = tok.ident.s[0]
 
     # arrow like?
-    if L > 1 and tok.ident.s[^1] == '>' and tok.ident.s[^2] in {'-', '~', '='}:
-      return considerStrongSpaces(1)
+    if L > 1 and tok.ident.s[L-1] == '>' and
+      tok.ident.s[L-2] in {'-', '~', '='}: return considerStrongSpaces(1)
 
     template considerAsgn(value: expr) =
       result = if tok.ident.s[L-1] == '=': 1 else: value
diff --git a/doc/manual/syntax.txt b/doc/manual/syntax.txt
index f6fe0652d..24644bce2 100644
--- a/doc/manual/syntax.txt
+++ b/doc/manual/syntax.txt
@@ -15,8 +15,6 @@ Associativity
 Binary operators whose first character is ``^`` are right-associative, all
 other binary operators are left-associative.
 
-Operators ending in either ``->``, ``~>`` or ``=>`` are called
-`arrow like`:idx:.
 
 
 Precedence
@@ -33,9 +31,12 @@ as ``(@x).abc`` whereas ``$x.abc`` is parsed as ``$(x.abc)``.
 For binary operators that are not keywords the precedence is determined by the
 following rules:
 
+Operators ending in either ``->``, ``~>`` or ``=>`` are called
+`arrow like`:idx:, and have the lowest precedence of all operators.
+
 If the operator ends with ``=`` and its first character is none of 
 ``<``, ``>``, ``!``, ``=``, ``~``, ``?``, it is an *assignment operator* which
-has the lowest precedence.
+has the second lowest precedence.
 
 Otherwise precedence is determined by the first character.
 
diff --git a/web/news.txt b/web/news.txt
index b5b897c1a..6b109aa1c 100644
--- a/web/news.txt
+++ b/web/news.txt
@@ -34,7 +34,7 @@ News
     should be used instead.
   - ``nim idetools`` has been replaced by a separate tool `nimsuggest`_.
   - *arrow like* operators are not right associative anymore.
-  - *arrow like* operators are now required end with either ``->``, ``~>`` or
+  - *arrow like* operators are now required to end with either ``->``, ``~>`` or
     ``=>``, not just ``>``. Examples of operators still considered arrow like:
     ``->``, ``==>``, ``+=>``. On the other hand, the following operators are now
     considered regular operators again: ``|>``, ``-+>``, etc.