summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-11-09 01:42:05 +0100
committerAraq <rumpf_a@web.de>2011-11-09 01:42:05 +0100
commit68be801f63dc41e79f96ef2516350cc8538c5d7e (patch)
tree79e30a2a6024daff3602099ac403bdc68eb8d385 /doc
parent8c03d96c6aaa9607d3cba4e1dab401b6e0a85890 (diff)
downloadNim-68be801f63dc41e79f96ef2516350cc8538c5d7e.tar.gz
operator precedence changed: assignment like operators are supported; escaping of operators with \ is supported
Diffstat (limited to 'doc')
-rwxr-xr-xdoc/grammar.txt5
-rwxr-xr-xdoc/manual.txt25
2 files changed, 22 insertions, 8 deletions
diff --git a/doc/grammar.txt b/doc/grammar.txt
index 458c85833..5f7b851fa 100755
--- a/doc/grammar.txt
+++ b/doc/grammar.txt
@@ -1,7 +1,7 @@
 module ::= ([COMMENT] [SAD] stmt)*
 
 comma ::= ',' [COMMENT] [IND]
-operator ::= OP1 | OP2 | OP3 | OP4 | OP5 | OP6 | OP7 | OP8 | OP9
+operator ::=  OP0 | OP1 | OP2 | OP3 | OP4 | OP5 | OP6 | OP7 | OP8 | OP9
            | 'or' | 'xor' | 'and'
            | 'is' | 'isnot' | 'in' | 'notin' | 'of'
            | 'div' | 'mod' | 'shl' | 'shr' | 'not' | '..'
@@ -11,7 +11,8 @@ prefixOperator ::= operator
 optInd ::= [COMMENT] [IND]
 optPar ::= [IND] | [SAD]
 
-lowestExpr ::= orExpr (OP1 optInd orExpr)*
+lowestExpr ::= assignExpr (OP0 optInd assignExpr)*
+assignExpr ::= orExpr (OP1 optInd orExpr)*
 orExpr ::= andExpr (OP2 optInd andExpr)*
 andExpr ::= cmpExpr (OP3 optInd cmpExpr)*
 cmpExpr ::= sliceExpr (OP4 optInd sliceExpr)*
diff --git a/doc/manual.txt b/doc/manual.txt
index 44bd99352..6d8286dd7 100755
--- a/doc/manual.txt
+++ b/doc/manual.txt
@@ -387,13 +387,25 @@ This section lists Nimrod's standard syntax in ENBF. How the parser receives
 indentation tokens is already described in the `Lexical Analysis`_ section.

 

 Nimrod allows user-definable operators.

-Binary operators have 9 different levels of precedence. For user-defined

-operators, the precedence depends on the first character the operator consists

-of. All binary operators are left-associative, except binary operators starting

-with (or only consisting of) ``^``.

+Binary operators have 10 different levels of precedence. 

+All binary operators are left-associative, except binary operators starting

+with (or only consisting of) ``^``. 

+

+For operators that are not keywords the precedence is determined by the

+following rules: 

+

+An operator symbol's *relevant character* is its first

+character unless the first character is ``\`` and its length is greater than 1

+then it is the second character.

+

+If the operator ends with ``=`` and its relevant character is none of 

+``<``, ``>``, ``!``, ``=``, ``~``, ``?``, it is an *assignment operator* which

+has the lowest precedence.

+

+Otherwise precedence is determined by the relevant character.

 

 ================  ===============================================  ==================  ===============

-Precedence level    Operators                                      First characters    Terminal symbol

+Precedence level    Operators                                      Relevant character  Terminal symbol

 ================  ===============================================  ==================  ===============

   9 (highest)                                                      ``$  ^``            OP9

   8               ``*    /    div   mod   shl  shr  %``            ``* % \  /``        OP8

@@ -403,7 +415,8 @@ Precedence level    Operators                                      First charact
   4               ``==  <= < >= > !=  in not_in is isnot not of``  ``= <  > !``        OP4

   3               ``and``                                                              OP3

   2               ``or xor``                                                           OP2

-  1 (lowest)                                                       ``@  : ?``          OP1

+  1                                                                ``@  : ?``          OP1

+  0 (lowest)      *assignment operator* (like ``+=``, ``*=``)                          OP0

 ================  ===============================================  ==================  ===============