@ is a sigil-like operator
This commit is contained in:
parent
3628731064
commit
959e370ae9
9 changed files with 119 additions and 157 deletions
|
|
@ -388,19 +388,38 @@ indentation tokens is already described in the `Lexical Analysis`_ section.
|
|||
|
||||
Nimrod allows user-definable operators.
|
||||
Binary operators have 10 different levels of precedence.
|
||||
All binary operators are left-associative, except binary operators starting
|
||||
with (or only consisting of) ``^``.
|
||||
|
||||
Relevant character
|
||||
------------------
|
||||
|
||||
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.
|
||||
|
||||
This rule allows to escape operator symbols with ``\`` and keeps the operator's
|
||||
precedence and associativity; this is useful for meta programming.
|
||||
|
||||
|
||||
Associativity
|
||||
-------------
|
||||
|
||||
All binary operators are left-associative, except binary operators whose
|
||||
relevant char is ``^``.
|
||||
|
||||
Precedence
|
||||
----------
|
||||
|
||||
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.
|
||||
has the lowest precedence.
|
||||
|
||||
If the operator's relevant character is ``@`` it is a `sigil-like`:idx:
|
||||
operator which binds stronger than a ``primarySuffix``: ``@x.abc`` is parsed
|
||||
as ``(@x).abc`` whereas ``$x.abc`` is parsed as ``$(x.abc)``.
|
||||
|
||||
|
||||
Otherwise precedence is determined by the relevant character.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue