chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<h4>Color literal</h4>
|
||||
<br>
|
||||
<h5>Hexadecimal Colors</h5>
|
||||
<p>interprets color constants as hexadecimal if they are preceded by <code>#</code> and hexadecimal color is specified with:
|
||||
<code>#RRGGBB</code> or <code>#RRGGBBAA</code>, where the RR (red), GG (green) and BB (blue)and AA (alpha) hexadecimal integers specify the components of the color. All values must be between <code>00</code> and <code>FF</code>.<br/>For example, the <code>#0000FF</code> value is rendered as blue, because the blue component is set to its highest value (<code>FF</code>) and the others are set to <code>00</code>.<br/>There are 140 color names are predefined under the <a href="/docs/functions/color">color</a> scope.</p>
|
||||
@@ -0,0 +1,44 @@
|
||||
<h4>Comments</h4>
|
||||
<p>Comments can be used to explain <b>Shell</b> code, and to make it more readable. It can also be used to prevent execution <b>Shell</b> code. Comments can be singled-lined or multi-lined.</p>
|
||||
<div id="single-line">
|
||||
<h5>Single-line Comments</h5>
|
||||
<p>
|
||||
Single-line comments start with two forward slashes (<code>//</code>).<br>
|
||||
Any text between <code>//</code> and the end of the line is ignored (will not be executed).
|
||||
</p>
|
||||
<p>This example uses a single-line comment before a line of code:</p>
|
||||
<pre><code class="lang-shell">dynamic
|
||||
{
|
||||
// This is a comment
|
||||
item(title='Hello World!')
|
||||
|
||||
//item(title='Hello World!')
|
||||
}</code></pre>
|
||||
|
||||
<p>This example uses a single-line comment at the end of a line of code:</p>
|
||||
<pre><code class="lang-shell">dynamic
|
||||
{
|
||||
item(title='Hello World!') // This is a comment
|
||||
}</code></pre>
|
||||
</div>
|
||||
<br>
|
||||
<div id="multi-line">
|
||||
<h5>Multi-line Comments</h5>
|
||||
<p>
|
||||
Multi-line comments start with <code>/*</code> and ends with <code>*/</code>.<br>
|
||||
Any text between <code>/*</code> and <code>*/</code> will be ignored.
|
||||
</p>
|
||||
<pre><code class="lang-shell">dynamic
|
||||
{
|
||||
item(title='Hello,/* multiple-lines comment inside */ world')
|
||||
|
||||
/*
|
||||
item(title='test item 1')
|
||||
item(title='test item 2')
|
||||
*/
|
||||
}</code></pre>
|
||||
<p>
|
||||
Single or multi-line comments?<br>
|
||||
It is up to you which you want to use. Normally, we use <code>//</code> for short comments, and <code>/* */</code> for longer.
|
||||
</p>
|
||||
</div>
|
||||
@@ -0,0 +1,6 @@
|
||||
<h4>Identifier</h4>
|
||||
<br>
|
||||
<p>The identifier have unique titles described by fully qualified names that indicate a logical hierarchy.<br>The identifier that has no parameters. Parentheses are added when necessary to separate:</p>
|
||||
<p>There is a hierarchy of keywords in that some keywords are always followed by others.</p>
|
||||
<pre><code class="lang-shell">sel.path
|
||||
sel.path().ext</code></pre>
|
||||
@@ -0,0 +1,12 @@
|
||||
<h4>Expressions</h4>
|
||||
<br>
|
||||
<p><b>Shell</b> provides a variety of statements and expressions. Most of these will be familiar to developers who have programmed in Java script, C, C++, C#.</p>
|
||||
<p>Expressions gives you all the power of <b>Shell</b>, but is using a simplified syntax that's easier to learn if you're a beginner, and makes you more productive if you're an expert.</p>
|
||||
<p>To use expressions, you write them by using proper syntax. Syntax is the set of rules by which the words and symbols in an expression are correctly combined. Initially, expressions in <b>Shell</b> are a little bit hard to read. But with a good understanding of expression syntax and a little practice, it becomes much easier.</p>
|
||||
<ul>
|
||||
<li>Expressions is non-case sensitive</li>
|
||||
<li>Expressions (variables and functions) start with @</li>
|
||||
<li>blocks are enclosed in @( ... )</li>
|
||||
<li>Strings are enclosed with quotation marks or single quotation marks</li>
|
||||
</ul>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<h4>Numeric literals</h4>
|
||||
<br>
|
||||
<p>There are two types of numbers. Integer and floating point.</p>
|
||||
<h5>Integer literals</h5>
|
||||
<p>An integer is a numeric literal(associated with numbers) without any fractional or exponential part. There are two types of integer literals:</p>
|
||||
<ol>
|
||||
<li>Decimal literal (base 10)</li>
|
||||
<li>Hexadecimal literal (base 16)</li>
|
||||
</ol>
|
||||
<p><strong>1. Decimal-literal(base 10):</strong><br>A non-zero decimal digit followed by zero or more decimal digits(0, 1, 2, 3, 4, 5, 6, 7, 8, 9).</p>
|
||||
For example:<pre><code>Decimal: 0, -9, 22 etc</code></pre>
|
||||
<p><strong>2. Hexadecimal-literal(base 16):</strong><br>0x followed by one or more hexadecimal digits(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f).</p>
|
||||
For example:
|
||||
<pre><code>Hexadecimal: 0x7f, 0x2a, 0x521 etc</code></pre>
|
||||
<h5>Floating-point iterals</h5>
|
||||
|
||||
<p>Floating-point literals specify values that must have a fractional part. These values contain decimal points (.)</p>
|
||||
For example:
|
||||
<pre><code>-2.0<br>0.0000234</code></pre>
|
||||
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
<h4>Operators</h4>
|
||||
<br>
|
||||
<p>An operator is a symbol that tells to perform specific mathematical or logical manipulations. <b>Shell</b> is rich in built-in operators and provide the following types of operators</p>
|
||||
<p>This chapter will examine the arithmetic, relational, logical, bitwise, assignment and other operators one by one.</p>
|
||||
<h5 id="arithmetic">Arithmetic Operators</h5>
|
||||
<p>The five arithmetical operations supported</p>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="has-text-centered" width="10%">Operator</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">+</td>
|
||||
<td>Addition</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">-</td>
|
||||
<td>Subtraction</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">*</td>
|
||||
<td>Multiplication</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">/</td>
|
||||
<td>Division</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">%</td>
|
||||
<td>Modulo</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<h5 id="relational">Relational and comparison operators</h5>
|
||||
<p>Two expressions can be compared using relational and equality operators. For example, to know if two values are equal or if one is greater than the other.</p>
|
||||
<p>The result of such an operation is either true or false (i.e., a Boolean value).</p>
|
||||
<p>The relational operators are:</p>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="has-text-centered"width="10%">operator</th><th>description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">==</td><td>Equal to</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">!=</td><td>Not equal to</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered"><</td><td>Less than</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">></td><td>Greater than</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered"><=</td><td>Less than or equal to</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">>=</td><td>Greater than or equal to</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<h5 id="logical">Logical Operators (!, ||, &&)</h5>
|
||||
<p> The operator <code>!</code> is operator for the Boolean operation NOT. It has only one operand, to its right, and inverts it, producing false if its operand is true, and true if its operand is false. Basically, it returns the opposite Boolean value of evaluating its operand. For example:</p>
|
||||
<p> The logical operators <code>&&</code> and <code>||</code> are used when evaluating two expressions to obtain a single relational result. The operator <code>&&</code> corresponds to the Boolean logical operation AND, which yields true if both its operands are true, and false otherwise. The following panel shows the result of operator <code>&&</code> evaluating the expression <code>a && b</code>:</p>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="has-text-centered" width="10%">operator</th>
|
||||
<th>description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">&&</td>
|
||||
<td>Called Logical AND operator. If both the operands are non-zero, then condition becomes true.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">||</td>
|
||||
<td>Called Logical OR Operator. If any of the two operands is non-zero, then condition becomes true.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">!</td>
|
||||
<td>
|
||||
Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true, then Logical NOT operator will make false.
|
||||
<pre><code>!(5 == 5) <cite>// evaluates to false because the expression at its right (5 == 5) is true</cite>
|
||||
!(6 <= 4) <cite>// evaluates to true because (6 <= 4) would be false</cite>
|
||||
!<var>true</var> <cite>// evaluates to false</cite>
|
||||
!<var>false</var> <cite>// evaluates to true</cite></code></pre>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<h5 id="ternary">Conditional ternary operator</h5>
|
||||
<p>The conditional operator evaluates an expression, returning one value if that expression evaluates to true, and a different one if the expression evaluates as false. Its syntax is:</p>
|
||||
<pre><code>condition ? result1 : result2</code></pre>
|
||||
<p>If condition is true, the entire expression evaluates to result1, and otherwise to result2.</p>
|
||||
<pre><code>7==5 ? 4 : 3 <cite>// evaluates to 3, since 7 is not equal to 5.</cite>
|
||||
7==5+2 ? 4 : 3 <cite>// evaluates to 4, since 7 is equal to 5+2.</cite>
|
||||
5>3 ? a : b <cite>// evaluates to the value of a, since 5 is greater than 3.</cite>
|
||||
a>b ? a : b <cite>// evaluates to whichever is greater, a or b.</cite></code></pre>
|
||||
|
||||
<h5 id="bitwise">Bitwise Operators</h5>
|
||||
<p>Bitwise operators modify variables considering the bit patterns that represent the values they store.</p>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="has-text-centered" width="10%">Operator</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">&</td>
|
||||
</td><td>Bitwise AND</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">|</td>
|
||||
<td>Bitwise inclusive OR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">^</td>
|
||||
<td>Bitwise exclusive OR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">~</td>
|
||||
<td>Unary complement (bit inversion)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered"><<</td>
|
||||
<td>Shift bits left</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="has-text-centered">>></td>
|
||||
<td>Shift bits right</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h5 id="precedence">Precedence of operators</h5>
|
||||
<p> A single expression may have multiple operators. For example:</p>
|
||||
<pre><code>x = 5 + 7 % 2</code></pre>
|
||||
<p>the above expression always assigns 6 to variable x, because the <code>%</code> operator has a higher precedence than the <code>+</code> operator, and is always evaluated before. Parts of the expressions can be enclosed in parenthesis to override this precedence order, or to make explicitly clear the intended effect. Notice the difference:</p>
|
||||
<pre><code>x = 5 + (7 % 2) <cite>// x = 6 (same as without parenthesis)</cite>
|
||||
x = (5 + 7) % 2 <cite>// x = 0</cite></code></pre>
|
||||
<p>From greatest to smallest priority, Operators are evaluated in the following order:</p>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Level</th>
|
||||
<th>Precedence group</th>
|
||||
<th>Operator</th>
|
||||
<th>Description</th>
|
||||
<th>Grouping</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="4">1</td>
|
||||
<td rowspan="4">Postfix (unary)</td>
|
||||
<td><code>++ --</code></td>
|
||||
<td>postfix increment / decrement</td>
|
||||
<td rowspan="4">Left-to-right</td>
|
||||
</tr>
|
||||
<tr><td><code>()</code></td><td>functional forms</td></tr>
|
||||
<tr><td><code>[]</code></td><td>subscript</td></tr>
|
||||
<tr><td><code>.</code></td><td>member access</td>
|
||||
</tr>
|
||||
<tr><td rowspan="3">2</td><td rowspan="3">Prefix (unary)</td><td><code>++ --</code></td><td>prefix increment / decrement</td><td rowspan="3">Right-to-left</td></tr>
|
||||
<tr><td><code>~ !</code></td><td>bitwise NOT / logical NOT</td></tr>
|
||||
<tr><td><code>+ -</code></td><td>unary prefix</td></tr>
|
||||
<tr><td>4</td><td>Arithmetic: scaling</td><td><code>* / %</code></td><td>multiply, divide, modulo</td><td>Left-to-right</td></tr>
|
||||
<tr><td>5</td><td>Arithmetic: addition</td><td><code>+ -</code></td><td>addition, subtraction</td><td>Left-to-right</td></tr>
|
||||
<tr><td>6</td><td>Bitwise shift</td><td><code><< >></code></td><td>shift left, shift right</td><td>Left-to-right</td></tr>
|
||||
<tr><td>7</td><td>Relational</td><td><code>< > <= >=</code></td><td>comparison operators</td><td>Left-to-right</td></tr>
|
||||
<tr><td>8</td><td>Equality</td><td><code>== !=</code></td><td>equality / inequality</td><td>Left-to-right</td></tr>
|
||||
<tr><td>9</td><td>And</td><td><code>&</code></td><td>bitwise AND</td><td>Left-to-right</td></tr>
|
||||
<tr><td>10</td><td>Exclusive or</td><td><code>^</code></td><td>bitwise XOR</td><td>Left-to-right</td></tr>
|
||||
<tr><td>11</td><td>Inclusive or</td><td><code>|</code></td><td>bitwise OR</td><td>Left-to-right</td></tr>
|
||||
<tr><td>12</td><td>Conjunction</td><td><code>&&</code></td><td>logical AND</td><td>Left-to-right</td></tr>
|
||||
<tr><td>13</td><td>Disjunction</td><td><code>||</code></td><td>logical OR</td><td>Left-to-right</td></tr>
|
||||
<tr><td rowspan="2">15</td><td rowspan="2">Assignment-level expressions</td><td><code>=</code></td><td>assignment</td><td rowspan="2">Right-to-left</td></tr>
|
||||
<tr><td><code>?:</code></td><td>conditional operator</td></tr>
|
||||
<tr><td>16</td><td>Sequencing</td><td><code>,</code></td><td>comma separator</td><td>Left-to-right</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
When an expression has two operators with the same precedence level, grouping determines which one is evaluated first: either left-to-right or right-to-left.<br>
|
||||
Enclosing all sub-statements in parentheses (even those unnecessary because of their precedence) improves code readability.
|
||||
</p>
|
||||
@@ -0,0 +1,37 @@
|
||||
<h4>String literal</h4>
|
||||
<br>
|
||||
<p>string is zero or more characters written inside single or double quotes.</p>
|
||||
<p>You can use quotes inside a string, as long as they don't match the quotes surrounding the string:</p>
|
||||
<pre><code class="lang-shell">$var1 = "It's alright"
|
||||
$var2 = "He is called 'Johnny'"
|
||||
$var3 = 'He is called "Johnny"'</code></pre>
|
||||
<br>
|
||||
<h5>Single quotes</h5>
|
||||
<br>
|
||||
<p>single quotes allow you to use the syntax of expressions within them.<br/>The <code>@</code> sign must be placed before the expressions.</p>
|
||||
<pre><code class="lang-shell">item(title = 'windows dir path: @sys.dir')</code></pre>
|
||||
<br>
|
||||
<h5>Double quotes</h5>
|
||||
<br>
|
||||
<p>double quotes allow you to use the Escape Character inside them only.<br/>The backslash (<code>\</code>) escape character turns special characters into characters.<br/>The sequence <code>\" </code> inserts a double quote in a string:</p>
|
||||
<pre><code class="lang-shell">$var1 = "hello\"world"
|
||||
// result: hello"world</code></pre>
|
||||
<p>The complete set of escape sequences is as follows:</p>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr><td>\'</td><td>Single quote</td></tr>
|
||||
<tr><td>\"</td><td>Double quote</td></tr>
|
||||
<tr><td>\\</td><td>Backslash</td></tr>
|
||||
<tr><td>\0</td><td>Null</td></tr>
|
||||
<tr><td>\a</td><td>Alert</td></tr>
|
||||
<tr><td>\b</td><td>Backspace</td></tr>
|
||||
<tr><td>\f</td><td>Form Feed</td></tr>
|
||||
<tr><td>\n</td><td>New Line</td></tr>
|
||||
<tr><td>\r</td><td>Carriage Return</td></tr>
|
||||
<tr><td>\t</td><td>Horizontal Tab</td></tr>
|
||||
<tr><td>\v</td><td>Vertical Tab</td></tr>
|
||||
<tr><td>\uxxxx</td><td>Unicode escape sequence (UTF-16) \uHHHH (range: 0000 - FFFF)</td></tr>
|
||||
<tr><td>\xnnnn</td><td>Unicode escape sequence for character with hex value nnnn (variable length version of \uxxxx)</td></tr>
|
||||
<tr><td>\Uxxxxxxxx</td><td>Unicode escape sequence (UTF-32) \U00HHHHHH (range: 000000 - 10FFFF)</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -0,0 +1,33 @@
|
||||
<h4>Variables</h4>
|
||||
<br>
|
||||
<p>Variables are containers for storing data values.</p>
|
||||
<ul>
|
||||
<li>Global and local variables are optional.</li>
|
||||
<li>To declare more than one variable, use a space.</li>
|
||||
</ul>
|
||||
<p>The general rules for constructing names for variables (unique identifiers) are:</p>
|
||||
<ul>
|
||||
<li>Names can contain letters, digits and underscores (<code>_</code>).</li>
|
||||
<li>Names must begin with a letter.</li>
|
||||
<li>Names cannot contain whitespaces or special characters like !, #, %, etc.</li>
|
||||
<li>Reserved words (like keywords, such as null, true, false, etc.) cannot be used as names.</li>
|
||||
<li>Variables can be placed in globle variables, or in the dynamic body section of an menu, or in both.</li>
|
||||
</ul>
|
||||
<p>
|
||||
All variables must be identified with unique names.<br>
|
||||
These unique names are called identifiers.
|
||||
Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume).
|
||||
</p>
|
||||
<p><i>Note:</i> It is recommended to use descriptive names in order to create understandable and maintainable code</p>
|
||||
<h5 class="mt-5">Example</h5>
|
||||
<pre><code class="lang-shell">$hello_world = 'Hello World!'
|
||||
$test_add1 = 5 + 6
|
||||
|
||||
item(title = hello_world cmd = msg(hello_world))
|
||||
|
||||
menu(title = test_add1)
|
||||
{
|
||||
$test_sub1 = 11 - 5
|
||||
item(title = test_sub1)
|
||||
}</code></pre>
|
||||
|
||||
Reference in New Issue
Block a user