From 01c04feea5cec35c6e357a5f4089cc1571270c0a Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Fri, 3 Jan 2025 05:43:50 +0100 Subject: [PATCH] Doc: bitwise operators in the main operator table and special assignment operators table --- doc/Expr.adoc | 50 +++++++++++++++++---- doc/Expr.html | 121 +++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 146 insertions(+), 25 deletions(-) diff --git a/doc/Expr.adoc b/doc/Expr.adoc index ae9e31e..dbe8f2c 100644 --- a/doc/Expr.adoc +++ b/doc/Expr.adoc @@ -737,7 +737,7 @@ The table below shows all supported operators by decreasing priorities. .Operators priorities [cols="^3,^2,^2,^5,^6"] |=== -| Priority | Operators | Position | Operation | Operands and results +| Priority | Operator | Position | Operation | Operands and results .2+|*ITEM*| [blue]`[`...`]` | _Postfix_ | _List item_| _list_ `[` _integer_ `]` -> _any_ | [blue]`[`...`]` | _Postfix_ | _Dict item_ | _dict_ `[` _any_ `]` -> _any_ @@ -751,6 +751,8 @@ The table below shows all supported operators by decreasing priorities. .3+|*SIGN*| [blue]`+`, [blue]`-` | _Prefix_ | _Change-sign_| (`+`\|`-`) _number_ -> _number_ | [blue]`#` | _Prefix_ | _Lenght-of_ | `#` _collection_ -> _integer_ | [blue]`#` | _Prefix_ | _Size-of_ | `#` _iterator_ -> _integer_ +.2+|*BIT SHIFT*| [blue]`<<` | _Infix_ | _Left-Shift_ | _integer_ `<<` _integer_ -> _integer_ +| [blue]`>>` | _Infix_ | _Right-Shift_ | _integer_ `>>` _iterator_ -> _integer_ .2+|*SELECT*| [blue]`? : ::` | _Multi-Infix_ | _Case-Selector_ | _any-expr_ `?` _case-list_ _case-expr_ `:` _case-list_ _case-expr_ ... `::` _default-expr_ -> _any_ | [blue]`? : ::` | _Multi-Infix_ | _Index-Selector_ | _int-expr_ `?` _case-expr_ `:` _case-expr_ ... `::` _default-expr_ -> _any_ .1+|*FRACT*| [blue]`:` | _Infix_ | _Fraction_ | _integer_ `:` _integer_ -> _fraction_ @@ -767,9 +769,9 @@ The table below shows all supported operators by decreasing priorities. | [blue]`+` | _Infix_ | _Dict-join_ | _dict_ `+` _dict_ -> _dict_ | [blue]`-` | _Infix_ | _Subtraction_ | _number_ `-` _number_ -> _number_ | [blue]`-` | _Infix_ | _List-difference_ | _list_ `-` _list_ -> _list_ -.1+|*BINARY NOT*| [blue]`~` | _Prefix_ | _Binary Not_ | `~` _number_ -> _number_ -.1+|*BINARY AND*| [blue]`&` | _Infix_ | _Binary And_ | _number_ `&` _number_ -> _number_ -.1+|*BINARY OR*| [blue]`\|` | _Infix_ | _Binary Or_ | _number_ `\|` _number_ -> _number_ +.1+|*BITWISE NOT*| [blue]`~` | _Prefix_ | _Binary Not_ | `~` _number_ -> _number_ +.1+|*BITWISE AND*| [blue]`&` | _Infix_ | _Binary And_ | _number_ `&` _number_ -> _number_ +.1+|*BITWISE OR*| [blue]`\|` | _Infix_ | _Binary Or_ | _number_ `\|` _number_ -> _number_ .8+|*RELATION*| [blue]`<` | _Infix_ | _Less_ | _comparable_ `<` _comparable_ -> _boolean_ | [blue]`\<=` | _Infix_ | _less-equal_ | _comparable_ `\<=` _comparable_ -> _boolean_ | [blue]`>` | _Infix_ | _Greater_ | _comparable_ `>` _comparable_ -> _boolean_ @@ -785,15 +787,47 @@ The table below shows all supported operators by decreasing priorities. | [blue]`\|\|` | _Infix_ | _Or_ | _boolean_ `\|\|` _boolean_ -> _boolean_ .2+|*INSERT*| [blue]`+>` | _Infix_ | _Prepend_ | _any_ `+>` _list_ -> _list_ | [blue]`<+` | _Infix_ | _Append_ | _list_ `<+` _any_ -> _list_ -.3+|*ASSIGN*| [blue]`=` | _Infix_ | _Assignment_ | _identifier_ `=` _any_ -> _any_ -| [blue]`>>` | _Infix_ | _Front-insert_ | _any_ `>>` _list_ -> _list_ -| [blue]`<<` | _Infix_ | _Back-insert_ | _list_ `<<` _any_ -> _list_ +.2+|*ASSIGN*| [blue]`=` | _Infix_ | _Assignment_ | _identifier_ `=` _any_ -> _any_ +4+| _See also the special assignment operators table below_ .1+|*BUT*| [blue]`but` | _Infix_ | _But_ | _any_ `but` _any_ -> _any_ .1+|*RANGE*| [blue]`:` | _Infix_ | _Index-range_ | _integer_ `:` _integer_ -> _integer-pair_ |=== //^1^ Experimental +.Special assignment perators +[cols="^2,^2,^4,^6"] +|=== +| Priority | Operator | Operation |Equivalent operation + +.9+|*ASSIGN*| [blue]`+=` | _Sum & Assign_ | _var_ `\+=` _expr_ + +short for + +_var_ `=` _value-of-var_ `+` _expr_ +| [blue]`-=` | _Subtract & Assign_ | _var_ `-=` _expr_ + +short for + +_var_ `=` _value-of-var_ `-` _expr_ +| [blue]`*=` | _Multiply & Assign_ | _var_ `\*=` _expr_ + +short for + +_var_ `=` _value-of-var_ `*` _expr_ +| [blue]`/=` | _Divide & Assign_ | _var_ `/=` _expr_ + +short for + +_var_ `=` _value-of-var_ `/` _expr_ +| [blue]`%=` | _Remainder & Assign_ | _var_ `%=` _expr_ + +short for + +_var_ `=` _value-of-var_ `%` _expr_ +| [blue]`&=` | _Bitwise and & Assign_ | _var_ `&=` _expr_ + +short for + +_var_ `=` _value-of-var_ `&` _expr_ +| [blue]`\|=` | _Bitwise or & Assign_ | _var_ `\|=` _expr_ + +short for + +_var_ `=` _value-of-var_ `\|` _expr_ +| [blue]`<\<=` | _Left shift & Assign_ | _var_ `<\<=` _expr_ + +short for + +_var_ `=` _value-of-var_ `<<` _expr_ +| [blue]`>>=` | _Right shift & Assign_ | _var_ `>>=` _expr_ + +short for + +_var_ `=` _value-of-var_ `>>` _expr_ +|=== == Functions Functions in _Expr_ are very similar to functions available in many programming languages. Currently, _Expr_ supports two types of function, _expr-functions_ and _go-functions_. @@ -844,7 +878,7 @@ _param-name_ = _identifier_ === _Golang_ function definition -Description of how to define Golan functions and how to bind them to _Expr_ are topics treated in another document that I'll write, one day, maybe. +Description of how to define Golang functions and how to bind them to _Expr_ are topics covered in another document that I'll write, one day, maybe. === Function calls To call a function, either Expr or Golang type, it is necessary to specify its name and, at least, its required parameters. diff --git a/doc/Expr.html b/doc/Expr.html index 102c3de..4ce12b9 100644 --- a/doc/Expr.html +++ b/doc/Expr.html @@ -1909,7 +1909,7 @@ These operators have a high priority, in particular higher than the operator Priority -Operators +Operator Position Operation Operands and results @@ -1988,6 +1988,19 @@ These operators have a high priority, in particular higher than the operator

# iteratorinteger

+

BIT SHIFT

+

<<

+

Infix

+

Left-Shift

+

integer << integerinteger

+ + +

>>

+

Infix

+

Right-Shift

+

integer >> iteratorinteger

+ +

SELECT

? : ::

Multi-Infix

@@ -2088,21 +2101,21 @@ These operators have a high priority, in particular higher than the operator

list - listlist

-

BINARY NOT

+

BITWISE NOT

~

Prefix

Binary Not

~ numbernumber

-

BINARY AND

+

BITWISE AND

&

Infix

Binary And

number & numbernumber

-

BINARY OR

+

BITWISE OR

|

Infix

Binary Or

@@ -2204,23 +2217,14 @@ These operators have a high priority, in particular higher than the operator

list <+ anylist

-

ASSIGN

+

ASSIGN

=

Infix

Assignment

identifier = anyany

-

>>

-

Infix

-

Front-insert

-

any >> listlist

- - -

<<

-

Infix

-

Back-insert

-

list << anylist

+

See also the special assignment operators table below

BUT

@@ -2238,6 +2242,89 @@ These operators have a high priority, in particular higher than the operator + + ++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 9. Special assignment perators
PriorityOperatorOperationEquivalent operation

ASSIGN

+=

Sum & Assign

var += expr
+short for
+var = value-of-var + expr

-=

Subtract & Assign

var -= expr
+short for
+var = value-of-var - expr

*=

Multiply & Assign

var *= expr
+short for
+var = value-of-var * expr

/=

Divide & Assign

var /= expr
+short for
+var = value-of-var / expr

%=

Remainder & Assign

var %= expr
+short for
+var = value-of-var % expr

&=

Bitwise and & Assign

var &= expr
+short for
+var = value-of-var & expr

|=

Bitwise or & Assign

var |= expr
+short for
+var = value-of-var | expr

<<=

Left shift & Assign

var <<= expr
+short for
+var = value-of-var << expr

>>=

Right shift & Assign

var >>= expr
+short for
+var = value-of-var >> expr

@@ -2309,7 +2396,7 @@ These operators have a high priority, in particular higher than the operator

6.2. Golang function definition

-

Description of how to define Golan functions and how to bind them to Expr are topics treated in another document that I’ll write, one day, maybe.

+

Description of how to define Golang functions and how to bind them to Expr are topics covered in another document that I’ll write, one day, maybe.

@@ -2488,7 +2575,7 @@ g(@p):any{}`