From d8dc2939b4694234102631a65f1019ff6f7ed774 Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Sat, 6 Jun 2026 06:51:17 +0200 Subject: [PATCH] Expr.adoc: typos --- doc/Expr.adoc | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/doc/Expr.adoc b/doc/Expr.adoc index 2e4ba8b..7c952a5 100644 --- a/doc/Expr.adoc +++ b/doc/Expr.adoc @@ -47,18 +47,18 @@ _Expr_ is a GO package that can analyze, interpret and calculate expressions. Expressions are texts containing sequences of operations represented by a syntax very similar to that of most programming languages. _Expr_ package provides these macro functions: * *_Scanner_* -- Its input is a text. It scans expression text characters to produce a flow of logical symbol and related attributes, aka tokens. -* *_Parser_* -- Parser input is the token flow coming from the scanner. It analyses the token flow verifyng if it complies with the _Expr_ syntax. If that is the case, the Parser generates the Abstract Syntax Tree (AST). This is tree data structure that represents the components of an expressions and how they are related one each other. +* *_Parser_* -- Parser input is the token flow coming from the scanner. It analyses the token flow verifying if it complies with the _Expr_ syntax. If that is the case, the Parser generates the Abstract Syntax Tree (AST). This is tree data structure that represents the components of an expression and how they are related to each other. * *_Calculator_*. Its input is the AST. It computes the parsed expression contained in the AST and returns the result or an error. image::expression-diagram.png[] ==== Variables -_Expr_ supports variables. The result of an expression can be stored in a variable and reused in other espressions by simply specifying the name of the variable as an operand. +_Expr_ supports variables. The result of an expression can be stored in a variable and reused in other expressions by simply specifying the name of the variable as an operand. ==== Multi-expression An input text valid for _Expr_ can contain more than an expression. Expressions are separated by [blue]`;` (semicolon). When an input contains two or more expressions it is called _multi-expression_. -_Expr_ parses and computes each expression of a multi-espression, from the left to the right. If all expressions are computed without errors, it only returns the value of the last, the right most. +_Expr_ parses and computes each expression of a multi-expression, from the left to the right. If all expressions are computed without errors, it only returns the value of the last, the right most. The result of each expression of a multi-expression is stored in an automatic variable named _last_. In this way, each expression can refer to the result of the previous one without the need to assign that value to a new dedicated variable. @@ -76,7 +76,7 @@ Imported functions are registered in the _global context_. When an expression fi ===== Inspecting contexts _Expr_ provides the operator [blue]_$$_ that returns the current context. This can be used to inspect the content of the context, for example to check the value of a variable or to see which functions are currently linked to the context. This operator is primarily intended for debugging purposes. -An interactive tool could like `ecli` (see <<_ecli_test_tool>>) can be used to inspect contexts interactively. +An interactive tool like `ecli` (see <<_ecli_test_tool>>) can be used to inspect contexts interactively. .Example: inspecting contexts @@ -105,7 +105,7 @@ An interactive tool could like `ecli` (see <<_ecli_test_tool>>) can be used to i In order to inspect the global context issue the [blue]`$$ global` operation. //// .Example: list all functions whose name starts with "str" -`>>>` [blue]`builtin "string` [gray]__// most function in the builtin module *string* have names starting with "str".__ + +`>>>` [blue]`builtin "string` [gray]__// most functions in the builtin module *string* have names starting with "str".__ + [green]`1` :dollar: $ @@ -129,7 +129,7 @@ In order to inspect the global context issue the [blue]`$$ global` operation. === `ecli` Expression Calculator Interactive Tool Before we begin to describe the syntax of _Expr_, it is worth introducing _ecli_, former _dev-expr_, because it will be used to show many examples of expressions. -`ecli` is a simple program that can be used to evaluate expressions interactively. As its name suggests, it was created for testing purpose. In fact, in additon to the automatic verification test suite based on the Go test framework, `ecli` provided an important aid for quickly testing of new features during their development. +`ecli` is a simple program that can be used to evaluate expressions interactively. As its name suggests, it was created for testing purpose. In fact, in addition to the automatic verification test suite based on the Go test framework, `ecli` provided an important aid for quickly testing of new features during their development. `ecli` can work as a _REPL_, _**R**ead-**E**xecute-**P**rint-**L**oop_, or it can process expression acquired from files or standard input. @@ -257,7 +257,7 @@ Value range: *-9223372036854775808* to *9223372036854775807* ^(1)^ The sum operator [blue]`+` also supports adding an integer number to a string. In this case, the number is converted to a string and prependend or appended to the string, e.g. `"x" + 48` results in `"x48"`. [[note_string_repl]] -^(2)^ The product operator also supports multiplying a string by an integer. In this case, the number represents homw may times the string has to be repeated in the result, e.g. `"foo" * 3` returnsn `"foofoofoo"`. +^(2)^ The product operator also supports multiplying a string by an integer. In this case, the number represents how many times the string has to be repeated in the result, e.g. `"foo" * 3` returns `"foofoofoo"`. [[note_float_division]] ^(3)^ See also the _float division_ [blue]`./` below. @@ -396,7 +396,7 @@ Some arithmetic operators also apply to strings. | [blue]`*` | _repeat_ | Make _n_ copy of a string | [blue]`"one" * 2` -> _"oneone"_ |=== -The charanters in a string can be accessed using the square `[]` operator. +The characters in a string can be accessed using the square `[]` operator. .Item access syntax ==== @@ -419,7 +419,7 @@ The charanters in a string can be accessed using the square `[]` operator. [green]`"d"` `>>>` [blue]`#s` [gray]_// number of chars_ + -[gren]`4` +[green]`4` `>>>` [blue]`#"abc"` [gray]_// number of chars_ + [green]`3` @@ -476,7 +476,7 @@ Currently, boolean operations are evaluated using _short cut evaluation_. This m ---- 2 > (a=1) or (a=8) > 0; a // <1> ---- -<1> This multi-expression returns _1_ because in the first expression the left value of [blue]`or` is _true_ and, as a conseguence, its right value is not computed. Therefore the _a_ variable only receives the integer _1_. +<1> This multi-expression returns _1_ because in the first expression the left value of [blue]`or` is _true_ and, as a consequence, its right value is not computed. Therefore the _a_ variable only receives the integer _1_. TIP: `ecli` provides the _ctrl()_ function that allows to change this behaviour. @@ -724,7 +724,7 @@ The value of each sub-expression is stored in the automatic variable _last_. [green]`2` `>>>` [blue]`x=2*3 but x-1` + -[green]`5`. +[green]`5` [blue]`but` behavior is very similar to [blue]`;`. The only difference is that [blue]`;` is not a true operator and can't be used inside parenthesis [blue]`(` and [blue]`)`. @@ -804,7 +804,7 @@ The triple special case of the selector operator is very useful, but it only wor ==== === Variable default value [blue]`??`, [blue]`?=`, and [blue]`?!` -The left operand of the first two operators, [blue]`??` and [blue]`?=`, must be a variable. The right operatand can be any expression. They return the value of the variable if this is defined; otherwise they return the value of the right expression. +The left operand of the first two operators, [blue]`??` and [blue]`?=`, must be a variable. The right operand can be any expression. They return the value of the variable if this is defined; otherwise they return the value of the right expression. IMPORTANT: If the left variable is defined, the right expression is not evaluated at all. @@ -812,7 +812,7 @@ The [blue]`??` operator do not change the status of the left variable. The [blue]`?=` assigns the calculated value of the right expression to the variable on the left side. -The third one, [blue]`?!`, is the alternate operator. If the variable on the left size is not defined, it returns [blue]_nil_. Otherwise it returns the result of the expressione on the right side. +The third one, [blue]`?!`, is the alternate operator. If the variable on the left side is not defined, it returns [blue]_nil_. Otherwise it returns the result of the expression on the right side. IMPORTANT: If the variable [blue]`?!` is NOT defined, the expression is not evaluated at all. @@ -914,7 +914,7 @@ The table below shows all supported operators by decreasing priorities. //^1^ Experimental -.Special assignment perators +.Special assignment operators [cols="^2,^2,^4,^6"] |=== | Priority | Operator | Operation |Equivalent operation @@ -997,7 +997,7 @@ _param-name_ = _identifier_ === _Golang_ function definition -Description of how to define Golang functions and how to bind them to _Expr_ are topics covered in another documents 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 other documents. === Function calls To call a function, either Expr or Golang type, it is necessary to specify its name and, at least, its required parameters. @@ -1263,7 +1263,7 @@ Returns _true_ if the value type of __ is string, false otherwise. ===== bool() Syntax: `bool() -> bool` + -Returns a _boolean_ value consisent with the value of the expression. +Returns a _boolean_ value consistent with the value of the expression. .Examples `>>>` [blue]`bool(1)` + @@ -1851,7 +1851,7 @@ Named operators are operators that are identified by a name instead of a symbol. .Available named operators * *_.next_*: same as [blue]`{plusplus}`. -* *_.current_*: same as [blue]`{star}`. +* *_.current_*: same as [blue]`{star}.` * *_.reset_*: resets the state of the iterator to the initial state. * *_.count_*: returns the number of elements in the iterator already visited. * *_.index_*: returns the index of the current element in the iterator. Before the first use of the [blue]`{plusplus}` operator, it returns the error [red]_-1_.