Doc: Fixed a lot of typos
This commit is contained in:
+49
-45
@@ -657,7 +657,7 @@ pre.rouge .ss {
|
||||
<p>Function contexts are created by cloning the calling context. More details on this topic are given later in this document.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><em>Expr</em> creates and keeps a inner <em>global context</em> where it stores imported functions, either from builtin or plugin modules. To perform calculations, the calling program must provide its own context; this is the <em>main context</em>. All calculations take place in this context. As mentioned eralier, when a function is called, a new context is created by cloning the calling context. The createt context can be called <em>function context</em>.</p>
|
||||
<p><em>Expr</em> creates and keeps a inner <em>global context</em> where it stores imported functions, either from builtin or plugin modules. To perform calculations, the calling program must provide its own context; this is the <em>main context</em>. All calculations take place in this context. As mentioned eralier, when a function is called, a new context is created by cloning the calling context. The created context can be called <em>function context</em>.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Imported functions are registerd in the <em>global context</em>. When an expression first calls an imported function, that function is linked to the current context; this can be the <em>main context</em> or a <em>function context</em>.</p>
|
||||
@@ -1109,7 +1109,7 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="paragraph">
|
||||
<p>The items of strings can be accessed using the square <code>[]</code> operator.</p>
|
||||
<p>The charanters in a string can be accessed using the square <code>[]</code> operator.</p>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="title">Example 4. Item access syntax</div>
|
||||
@@ -1137,11 +1137,11 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
<code class="green">"b"</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue">s.[-1]</code> <em class="gray">// char at position -1, the rightmost one</em><br>
|
||||
<p><code>>>></code> <code class="blue">s[-1]</code> <em class="gray">// char at position -1, the rightmost one</em><br>
|
||||
<code class="green">"d"</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue">\#s</code> <em class="gray">// number of chars</em><br>
|
||||
<p><code>>>></code> <code class="blue">#s</code> <em class="gray">// number of chars</em><br>
|
||||
<code class="gren">4</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
@@ -1208,14 +1208,14 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Greater</em></p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">True if the left value is greater than the right one</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">5 > 2</code> → <em>true</em><br>
|
||||
<code class="blue">"a" < "b"</code> → <em>false</em></p></td>
|
||||
<code class="blue">"a" > "b"</code> → <em>false</em></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">>=</code></p></td>
|
||||
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Greater or Equal</em></p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">True if the left value is greater than or equal to the right one</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">5 >= 2</code> → <em>true</em><br>
|
||||
<code class="blue">"b" <= "b"</code> → <em>true</em></p></td>
|
||||
<code class="blue">"b" >= "b"</code> → <em>true</em></p></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -1256,7 +1256,7 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
<tr>
|
||||
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">OR</code> / <code class="blue">||</code></p></td>
|
||||
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Or</em></p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">True if at least one of the left and right values integers true</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">True if at least one of the left and right values integers is true</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">false or true</code> → <em>true</em><br>
|
||||
<code class="blue">"a" == "b" OR (2 == 1)</code> → <em>false</em></p></td>
|
||||
</tr>
|
||||
@@ -1314,7 +1314,7 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
<div class="paragraph">
|
||||
<p><strong><em>list</em></strong> = <em>empty-list</em> | <em>non-empty-list</em><br>
|
||||
<em>empty-list</em> = "<strong>[]</strong>"<br>
|
||||
<em>non-empty-list</em> = "<strong>[</strong>" <em>any-value</em> {"<strong>,</strong>" _any-value} "<strong>]</strong>"<br></p>
|
||||
<em>non-empty-list</em> = "<strong>[</strong>" <em>any-value</em> {"<strong>,</strong>" <em>any-value</em>} "<strong>]</strong>"<br></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1416,27 +1416,27 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<div class="title">Items of list</div>
|
||||
<p><code>>>></code> <code class="blue">[1,2,3].1</code><br>
|
||||
<p><code>>>></code> <code class="blue">[1,2,3][1]</code><br>
|
||||
<code class="green">2</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue">list=[1,2,3]; list.1</code><br>
|
||||
<p><code>>>></code> <code class="blue">list=[1,2,3]; list[1]</code><br>
|
||||
<code class="green">2</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue">["one","two","three"].1</code><br>
|
||||
<p><code>>>></code> <code class="blue">["one","two","three"][1]</code><br>
|
||||
<code class="green">two</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue">list=["one","two","three"]; list.(2-1)</code><br>
|
||||
<p><code>>>></code> <code class="blue">list=["one","two","three"]; list[2-1]</code><br>
|
||||
<code class="green">two</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue">list.(-1)</code><br>
|
||||
<p><code>>>></code> <code class="blue">list[-1]</code><br>
|
||||
<code class="green">three</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue">list.(10)</code><br>
|
||||
<p><code>>>></code> <code class="blue">list[10]</code><br>
|
||||
<code class="red">Eval Error: [1:9] index 10 out of bounds</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
@@ -1466,7 +1466,7 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
<div class="paragraph">
|
||||
<p><strong><em>dict</em></strong> = <em>empty-dict</em> | <em>non-empty-dict</em><br>
|
||||
<em>empty-dict</em> = "<strong>{}</strong>"<br>
|
||||
<em>non-empty-dict</em> = "<strong>{</strong>" <em>key-scalar</em> "<strong>:</strong>" <em>any-value</em> {"<strong>,</strong>" <em>key-scalar</em> "<strong>:</strong>" _any-value} "<strong>}</strong>"<br></p>
|
||||
<em>non-empty-dict</em> = "<strong>{</strong>" <em>key-scalar</em> "<strong>:</strong>" <em>any-value</em> {"<strong>,</strong>" <em>key-scalar</em> "<strong>:</strong>" <em>any-value</em>} "<strong>}</strong>"<br></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1575,7 +1575,7 @@ The assign operator <code class="blue">=</code> returns the value assigned to th
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue">a_b=1+2</code><br>
|
||||
<code class="green">1+2</code></p>
|
||||
<code class="green">3</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue">a_b</code><br>
|
||||
@@ -1590,8 +1590,8 @@ The assign operator <code class="blue">=</code> returns the value assigned to th
|
||||
<code class="green">2</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue"><em>a=2</code><br>
|
||||
<code class="red">Parse Error: [1:2] unexpected token "</em>"</code></p>
|
||||
<p><code>>>></code> <code class="blue">_a=2</code><br>
|
||||
<code class="red">Parse Error: [1:2] unexpected token "_"</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue">1=2</code><br>
|
||||
@@ -1608,7 +1608,7 @@ The assign operator <code class="blue">=</code> returns the value assigned to th
|
||||
<p>The semicolon operator <code class="blue">;</code> is an infixed pseudo-operator. It evaluates the left expression first and then the right expression. The value of the latter is the final result.</p>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="title">Example 12. Mult-expression syntax</div>
|
||||
<div class="title">Example 12. Multi-expression syntax</div>
|
||||
<div class="content">
|
||||
<div class="paragraph">
|
||||
<p><strong><em>multi-expression</em></strong> = <em>expression</em> {"<strong>;</strong>" <em>expression</em> }</p>
|
||||
@@ -1616,7 +1616,7 @@ The assign operator <code class="blue">=</code> returns the value assigned to th
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>An expression that contains <code class="blue">;</code> is called a <em>multi-expression</em> and each component expressione is called a <em>sub-expression</em>.</p>
|
||||
<p>An expression that contains <code class="blue">;</code> is called a <em>multi-expression</em> and each component expression is called a <em>sub-expression</em>.</p>
|
||||
</div>
|
||||
<div class="admonitionblock important">
|
||||
<table>
|
||||
@@ -1648,7 +1648,7 @@ Technically <code class="blue">;</code> is not treated as a real operator. It ac
|
||||
<code class="green">6</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>The value of each sub-expression is stored in the automatica variable <em>last</em>.</p>
|
||||
<p>The value of each sub-expression is stored in the automatic variable <em>last</em>.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<div class="title">Example</div>
|
||||
@@ -1663,9 +1663,11 @@ Technically <code class="blue">;</code> is not treated as a real operator. It ac
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<div class="title">Examples</div>
|
||||
<p><code class="blue">5 but 2</code><br>
|
||||
<code class="green">2</code><br>
|
||||
<code class="blue">x=2*3 but x-1</code><br>
|
||||
<p><code>>>></code> <code class="blue">5 but 2</code><br>
|
||||
<code class="green">2</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue">x=2*3 but x-1</code><br>
|
||||
<code class="green">5</code>.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
@@ -1678,21 +1680,27 @@ Technically <code class="blue">;</code> is not treated as a real operator. It ac
|
||||
<p>The assignment operator <code class="blue">=</code> is used to define variables or to change their value in the evaluation context (see <em>ExprContext</em>).</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>The value on the left side of <code class="blue">=</code> must be an identifier. The value on the right side can be any expression and it becomes the result of the assignment operation.</p>
|
||||
<p>The value on the left side of <code class="blue">=</code> must be a variable identifier or an expression that evalutes to a variable. The value on the right side can be any expression and it becomes the result of the assignment operation.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<div class="title">Example</div>
|
||||
<p><code>>>></code> <code class="blue">a=15+1</code>
|
||||
<div class="title">Examples</div>
|
||||
<p><code>>>></code> <code class="blue">a=15+1</code><br>
|
||||
<code class="green">16</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue">L=[1,2,3]; L[1]=5; L</code><br>
|
||||
<code class="green">[1, 5, 3]</code></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_selector_operator"><a class="anchor" href="#_selector_operator"></a><a class="link" href="#_selector_operator">4.4. Selector operator <code class="blue">? : ::</code></a></h3>
|
||||
<div class="paragraph">
|
||||
<p>The <em>selector operator</em> is very similar to the <em>switch/case/default</em> statement available in many programming languages.</p>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="title">Example 13. Selector literal Syntax</div>
|
||||
<div class="content">
|
||||
<div class="paragraph">
|
||||
<div class="title">Selector literal Syntax</div>
|
||||
<p><em>selector-operator</em> = <em>select-expression</em> "<strong>?</strong>" <em>selector-case</em> { "<strong>:</strong>" <em>selector-case</em> } ["<strong>::</strong>" <em>default-multi-expression</em>]<br>
|
||||
<em>selector-case</em> = [<em>match-list</em>] <em>case-value</em><br>
|
||||
<em>match-list</em> = "<strong>[</strong>" <em>item</em> {"<strong>,</strong>" <em>items</em>} "<strong>]</strong>"<br>
|
||||
@@ -1701,6 +1709,8 @@ Technically <code class="blue">;</code> is not treated as a real operator. It ac
|
||||
<em>multi-expression</em> = <em>expression</em> { "<strong>;</strong>" <em>expression</em> }<br>
|
||||
<em>default-multi-expression</em> = <em>multi-expression</em></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>In other words, the selector operator evaluates the <em>select-expression</em> on the left-hand side of the <code class="blue">?</code> symbol; it then compares the result obtained with the values listed in the <em>match-list</em>'s, from left to right. If the comparision finds a match with a value in a <em>match-list</em>, the associated <em>case-multi-expression</em> is evaluted, and its result will be the final result of the selection operation.</p>
|
||||
</div>
|
||||
@@ -1765,8 +1775,8 @@ If the left variable is defined, the right expression is not evaluated at all.
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<div class="title">Examples</div>
|
||||
<p><code>>>></code> <code class="blue">var ?? (1+2)’<br>
|
||||
[green]`3</code></p>
|
||||
<p><code>>>></code> <code class="blue">var ?? (1+2)</code><br>
|
||||
<code class="green">3</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue">var</code><br>
|
||||
@@ -1777,7 +1787,7 @@ If the left variable is defined, the right expression is not evaluated at all.
|
||||
<code class="green">3</code></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>>>></code> <code class="blue">var</code>
|
||||
<p><code>>>></code> <code class="blue">var</code><br>
|
||||
<code class="green">3</code></p>
|
||||
</div>
|
||||
<div class="admonitionblock note">
|
||||
@@ -2106,7 +2116,7 @@ These operators have a high priority, in particular higher than the operator <co
|
||||
<h2 id="_functions"><a class="anchor" href="#_functions"></a><a class="link" href="#_functions">6. Functions</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>Functions in <em>Expr</em> are very similar to functions available in many programming languages. Actually, <em>Expr</em> supports two types of function, <em>expr-functions</em> and <em>go-functions</em>.</p>
|
||||
<p>Functions in <em>Expr</em> are very similar to functions available in many programming languages. Currently, <em>Expr</em> supports two types of function, <em>expr-functions</em> and <em>go-functions</em>.</p>
|
||||
</div>
|
||||
<div class="ulist">
|
||||
<ul>
|
||||
@@ -2114,7 +2124,7 @@ These operators have a high priority, in particular higher than the operator <co
|
||||
<p><em>expr-functions</em> are defined using <em>Expr</em>'s syntax. They can be passed as arguments to other functions and can be returned from functions. Moreover, they bind themselves to the defining context, thus becoming closures.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><em>go-functions</em> are regular Golang functions callable from <em>Expr</em> expressions. They are defined in Golang source files called <em>modules</em> and compiled within the <em>Expr</em> package. To make Golang functions available in <em>Expr</em> contextes, it is required to <em>import</em> the module in which they are defined.</p>
|
||||
<p><em>go-functions</em> are regular Golang functions callable from <em>Expr</em> expressions. They are defined in Golang source files called <em>modules</em> and compiled within the <em>Expr</em> package. To make Golang functions available in <em>Expr</em> contextes, it is required to activate the builtin module or to load the plugin module in which they are defined.</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -2123,20 +2133,14 @@ These operators have a high priority, in particular higher than the operator <co
|
||||
<div class="paragraph">
|
||||
<p>A function is identified and referenced by its name. It can have zero or more parameter. <em>Expr</em> functions also support optional parameters.</p>
|
||||
</div>
|
||||
<div class="olist arabic">
|
||||
<ol class="arabic">
|
||||
<li>
|
||||
<p>Expr’s function definition syntax</p>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="title">Example 14. Expr’s function definition syntax</div>
|
||||
<div class="content">
|
||||
<div class="paragraph">
|
||||
<p><strong><em>function-definition</em></strong> = <em>identifier</em> "<strong>=</strong>" "<strong>func(</strong>" [<em>param-list</em>] "<strong>)</strong>" "<strong>{</strong>" <em>multi-expression</em> "<strong>}</strong>"
|
||||
<em>param_list</em> = <em>required-param-list</em> [ "<strong>,</strong>" <em>optional-param-list</em> ]
|
||||
<em>required-param-list</em> = <em>identifier</em> { "<strong>,</strong>" <em>identifier</em> }
|
||||
<em>optional-param-list</em> = <em>optional-parm</em> { "<strong>,</strong>" <em>optional-param</em> }
|
||||
<p><strong><em>function-definition</em></strong> = <em>identifier</em> "<strong>=</strong>" "<strong>func(</strong>" [<em>param-list</em>] "<strong>)</strong>" "<strong>{</strong>" <em>multi-expression</em> "<strong>}</strong>"<br>
|
||||
<em>param_list</em> = <em>required-param-list</em> [ "<strong>,</strong>" <em>optional-param-list</em> ]<br>
|
||||
<em>required-param-list</em> = <em>identifier</em> { "<strong>,</strong>" <em>identifier</em> }<br>
|
||||
<em>optional-param-list</em> = <em>optional-parm</em> { "<strong>,</strong>" <em>optional-param</em> }<br>
|
||||
<em>optional-param</em> = <em>identifier</em> "<strong>=</strong>" <em>any-expr</em></p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2200,7 +2204,7 @@ These operators have a high priority, in particular higher than the operator <co
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Last updated 2024-06-21 09:06:12 +0200
|
||||
Last updated 2024-09-12 06:56:30 +0200
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user