...
This commit is contained in:
		
							
								
								
									
										77
									
								
								rhai_engine/rhaibook/appendix/keywords.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								rhai_engine/rhaibook/appendix/keywords.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,77 @@
 | 
			
		||||
Keywords List
 | 
			
		||||
=============
 | 
			
		||||
 | 
			
		||||
{{#include ../links.md}}
 | 
			
		||||
 | 
			
		||||
|        Keyword        | Description                                                             |         Inactive under          | Is function? |
 | 
			
		||||
| :-------------------: | ----------------------------------------------------------------------- | :-----------------------------: | :----------: |
 | 
			
		||||
|        `true`         | boolean true literal                                                    |                                 |    **no**    |
 | 
			
		||||
|        `false`        | boolean false literal                                                   |                                 |    **no**    |
 | 
			
		||||
|         `let`         | [variable] declaration                                                  |                                 |    **no**    |
 | 
			
		||||
|        `const`        | [constant] declaration                                                  |                                 |    **no**    |
 | 
			
		||||
|         `if`          | [`if`] statement                                                        |                                 |    **no**    |
 | 
			
		||||
|        `else`         | `else` block of [`if`] statement                                        |                                 |    **no**    |
 | 
			
		||||
|       `switch`        | [matching][`switch`]                                                    |                                 |    **no**    |
 | 
			
		||||
|         `do`          | [looping][`do`]                                                         |                                 |    **no**    |
 | 
			
		||||
|        `while`        | <ol><li>[`while`] loop</li><li>condition for [`do`] loop</li></ol>      |                                 |    **no**    |
 | 
			
		||||
|        `until`        | [`do`] loop                                                             |                                 |    **no**    |
 | 
			
		||||
|        `loop`         | infinite [`loop`]                                                       |                                 |    **no**    |
 | 
			
		||||
|         `for`         | [`for`] loop                                                            |                                 |    **no**    |
 | 
			
		||||
|         `in`          | <ol><li>[containment][`in`] test</li><li>part of [`for`] loop</li></ol> |                                 |    **no**    |
 | 
			
		||||
|         `!in`         | negated [containment][`in`] test                                        |                                 |    **no**    |
 | 
			
		||||
|      `continue`       | continue a loop at the next iteration                                   |                                 |    **no**    |
 | 
			
		||||
|        `break`        | break out of loop iteration                                             |                                 |    **no**    |
 | 
			
		||||
|       `return`        | [return][`return`] value                                                |                                 |    **no**    |
 | 
			
		||||
|        `throw`        | throw [exception]                                                       |                                 |    **no**    |
 | 
			
		||||
|         `try`         | [trap][`try`] [exception]                                               |                                 |    **no**    |
 | 
			
		||||
|        `catch`        | [catch][`catch`] [exception]                                            |                                 |    **no**    |
 | 
			
		||||
|       `import`        | [import][`import`] [module]                                             |          [`no_module`]          |    **no**    |
 | 
			
		||||
|       `export`        | [export][`export`] [variable]                                           |          [`no_module`]          |    **no**    |
 | 
			
		||||
|         `as`          | alias for [variable] [export][`export`]                                 |          [`no_module`]          |    **no**    |
 | 
			
		||||
|       `global`        | automatic [global][`global`] [module]                                   | [`no_module`], [`no_function`]  |    **no**    |
 | 
			
		||||
|       `private`       | mark [function] [private][`private`]                                    |         [`no_function`]         |    **no**    |
 | 
			
		||||
| `fn` (lower-case `f`) | [function] definition                                                   |         [`no_function`]         |    **no**    |
 | 
			
		||||
|  `Fn` (capital `F`)   | create a [function pointer]                                             |                                 |     yes      |
 | 
			
		||||
|        `call`         | call a [function pointer]                                               |                                 |     yes      |
 | 
			
		||||
|        `curry`        | curry a [function pointer]                                              |                                 |     yes      |
 | 
			
		||||
|      `is_shared`      | is a [variable] shared?                                                 | [`no_function`], [`no_closure`] |     yes      |
 | 
			
		||||
|      `is_def_fn`      | is [function] defined?                                                  |         [`no_function`]         |     yes      |
 | 
			
		||||
|     `is_def_var`      | is [variable] defined?                                                  |                                 |     yes      |
 | 
			
		||||
|        `this`         | reference to base object for method call                                |         [`no_function`]         |    **no**    |
 | 
			
		||||
|       `type_of`       | get type name of value                                                  |                                 |     yes      |
 | 
			
		||||
|        `print`        | print value                                                             |                                 |     yes      |
 | 
			
		||||
|        `debug`        | print value in debug format                                             |                                 |     yes      |
 | 
			
		||||
|        `eval`         | evaluate script                                                         |                                 |     yes      |
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Reserved Keywords
 | 
			
		||||
-----------------
 | 
			
		||||
 | 
			
		||||
|   Keyword   | Potential usage       |
 | 
			
		||||
| :---------: | --------------------- |
 | 
			
		||||
|    `var`    | variable declaration  |
 | 
			
		||||
|  `static`   | variable declaration  |
 | 
			
		||||
|  `shared`   | share value           |
 | 
			
		||||
|   `goto`    | control flow          |
 | 
			
		||||
|   `match`   | matching              |
 | 
			
		||||
|   `case`    | matching              |
 | 
			
		||||
|  `public`   | function/field access |
 | 
			
		||||
| `protected` | function/field access |
 | 
			
		||||
|    `new`    | constructor           |
 | 
			
		||||
|    `use`    | import namespace      |
 | 
			
		||||
|   `with`    | scope                 |
 | 
			
		||||
|    `is`     | type check            |
 | 
			
		||||
|  `module`   | module                |
 | 
			
		||||
|  `package`  | package               |
 | 
			
		||||
|   `super`   | base class/module     |
 | 
			
		||||
|  `thread`   | threading             |
 | 
			
		||||
|   `spawn`   | threading             |
 | 
			
		||||
|    `go`     | threading             |
 | 
			
		||||
|   `await`   | async                 |
 | 
			
		||||
|   `async`   | async                 |
 | 
			
		||||
|   `sync`    | async                 |
 | 
			
		||||
|   `yield`   | async                 |
 | 
			
		||||
|  `default`  | special value         |
 | 
			
		||||
|   `void`    | special value         |
 | 
			
		||||
|   `null`    | special value         |
 | 
			
		||||
|    `nil`    | special value         |
 | 
			
		||||
							
								
								
									
										20
									
								
								rhai_engine/rhaibook/appendix/literals.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								rhai_engine/rhaibook/appendix/literals.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
Literals Syntax
 | 
			
		||||
===============
 | 
			
		||||
 | 
			
		||||
{{#include ../links.md}}
 | 
			
		||||
 | 
			
		||||
|                                    Type                                    | Literal syntax                                                                                                          |
 | 
			
		||||
| :------------------------------------------------------------------------: | ----------------------------------------------------------------------------------------------------------------------- |
 | 
			
		||||
|                                   `INT`                                    | decimal: `42`, `-123`, `0`<br/>hex: `0x????..`<br/>binary: `0b????..`<br/>octal: `0o????..`                             |
 | 
			
		||||
| `FLOAT`,<br/>[`Decimal`][rust_decimal] (requires [`no_float`]+[`decimal`]) | `42.0`, `-123.456`, `123.`, `123.456e-10`                                                                               |
 | 
			
		||||
|                        [Ranges] in [`switch`] cases                        | `-10..10` (exclusive), `0..=50` (inclusive)                                                                             |
 | 
			
		||||
|                              Normal [string]                               | `"... \x?? \u???? \U???????? ..."`                                                                                      |
 | 
			
		||||
|                         [String] with continuation                         | `"this is the first line\`<br/>`second line\`<br/>`the third line"`                                                     |
 | 
			
		||||
|                        Multi-line literal [string]                         | `` `this is the first line``<br/>``second line``</br>``the last line` ``                                                |
 | 
			
		||||
|               Multi-line literal [string] with interpolation               | `` `this is the first field: ${obj.field1}``<br/>``second field: {obj.field2}``</br>``the last field: ${obj.field3}` `` |
 | 
			
		||||
|                                [Character]                                 | single: `'?'`<br/>ASCII hex: `'\x??'`<br/>Unicode: `'\u????'`, `'\U????????'`                                           |
 | 
			
		||||
|                                 [`Array`]                                  | `[ ???, ???, ??? ]`                                                                                                     |
 | 
			
		||||
|                                [Object map]                                | `#{ a: ???, b: ???, c: ???, "def": ??? }`                                                                               |
 | 
			
		||||
|                                Boolean true                                | `true`                                                                                                                  |
 | 
			
		||||
|                               Boolean false                                | `false`                                                                                                                 |
 | 
			
		||||
|                     `Nothing`/`null`/`nil`/`void`/Unit                     | `()`                                                                                                                    |
 | 
			
		||||
							
								
								
									
										86
									
								
								rhai_engine/rhaibook/appendix/operators.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								rhai_engine/rhaibook/appendix/operators.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,86 @@
 | 
			
		||||
Operators and Symbols
 | 
			
		||||
=====================
 | 
			
		||||
 | 
			
		||||
{{#include ../links.md}}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Operators
 | 
			
		||||
---------
 | 
			
		||||
 | 
			
		||||
|                                           Operator                                           | Description                            |  Binary?   | Binding direction |
 | 
			
		||||
| :------------------------------------------------------------------------------------------: | -------------------------------------- | :--------: | :---------------: |
 | 
			
		||||
|                                             `+`                                              | add                                    |    yes     |       left        |
 | 
			
		||||
|                                             `-`                                              | 1) subtract<br/>2) negative (prefix)   | yes<br/>no |  left<br/>right   |
 | 
			
		||||
|                                             `*`                                              | multiply                               |    yes     |       left        |
 | 
			
		||||
|                                             `/`                                              | divide                                 |    yes     |       left        |
 | 
			
		||||
|                                             `%`                                              | modulo                                 |    yes     |       left        |
 | 
			
		||||
|                                             `**`                                             | power/exponentiation                   |    yes     |       right       |
 | 
			
		||||
|                                             `>>`                                             | right bit-shift                        |    yes     |       left        |
 | 
			
		||||
|                                             `<<`                                             | left bit-shift                         |    yes     |       left        |
 | 
			
		||||
|                                             `&`                                              | 1) bit-wise _AND_<br/>2) boolean _AND_ |    yes     |       left        |
 | 
			
		||||
|                                       <code>\|</code>                                        | 1) bit-wise _OR_<br/>2) boolean _OR_   |    yes     |       left        |
 | 
			
		||||
|                                             `^`                                              | 1) bit-wise _XOR_<br/>2) boolean _XOR_ |    yes     |       left        |
 | 
			
		||||
| `=`, `+=`, `-=`, `*=`, `/=`,<br/>`**=`, `%=`, `<<=`, `>>=`, `&=`,<br/><code>\|=</code>, `^=` | assignments                            |    yes     |        n/a        |
 | 
			
		||||
|                                             `==`                                             | equals to                              |    yes     |       left        |
 | 
			
		||||
|                                             `!=`                                             | not equals to                          |    yes     |       left        |
 | 
			
		||||
|                                             `>`                                              | greater than                           |    yes     |       left        |
 | 
			
		||||
|                                             `>=`                                             | greater than or equals to              |    yes     |       left        |
 | 
			
		||||
|                                             `<`                                              | less than                              |    yes     |       left        |
 | 
			
		||||
|                                             `<=`                                             | less than or equals to                 |    yes     |       left        |
 | 
			
		||||
|                                             `&&`                                             | boolean _AND_ (short-circuits)         |    yes     |       left        |
 | 
			
		||||
|                                      <code>\|\|</code>                                       | boolean _OR_ (short-circuits)          |    yes     |       left        |
 | 
			
		||||
|                                             `??`                                             | null-coalesce (short-circuits)         |    yes     |       left        |
 | 
			
		||||
|                                             `!`                                              | boolean _NOT_                          |   **no**   |       right       |
 | 
			
		||||
|                                  `[` ... `]`, `?[` ... `]`                                   | indexing                               |    yes     |       left        |
 | 
			
		||||
|                                          `.`, `?.`                                           | 1) property access<br/>2) method call  |    yes     |       left        |
 | 
			
		||||
|                                             `..`                                             | exclusive range                        |    yes     |       left        |
 | 
			
		||||
|                                            `..=`                                             | inclusive range                        |    yes     |       left        |
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Symbols and Patterns
 | 
			
		||||
--------------------
 | 
			
		||||
 | 
			
		||||
|               Symbol                | Name                               | Description                           |
 | 
			
		||||
| :---------------------------------: | ---------------------------------- | ------------------------------------- |
 | 
			
		||||
|                 `_`                 | underscore                         | default `switch` case                 |
 | 
			
		||||
|                 `;`                 | semicolon                          | statement separator                   |
 | 
			
		||||
|                 `,`                 | comma                              | list separator                        |
 | 
			
		||||
|                 `:`                 | colon                              | [object map] property value separator |
 | 
			
		||||
|                `::`                 | path                               | module path separator                 |
 | 
			
		||||
|            `#{` ... `}`             | hash map                           | [object map] literal                  |
 | 
			
		||||
|             `"` ... `"`             | double quote                       | [string]                              |
 | 
			
		||||
|         `` ` `` ... `` ` ``         | back-tick                          | multi-line literal [string]           |
 | 
			
		||||
|             `'` ... `'`             | single quote                       | [character]                           |
 | 
			
		||||
|                 `\`                 | 1) escape<br/>2) line continuation | escape character literal              |
 | 
			
		||||
|                `()`                 | unit                               | null value                            |
 | 
			
		||||
|             `(` ... `)`             | parentheses                        | expression grouping                   |
 | 
			
		||||
|             `{` ... `}`             | braces                             | block statement                       |
 | 
			
		||||
| <code>\|</code> ... <code>\|</code> | pipes                              | closure                               |
 | 
			
		||||
|             `[` ... `]`             | brackets                           | [array] literal                       |
 | 
			
		||||
|                 `!`                 | bang                               | function call in calling scope        |
 | 
			
		||||
|                `=>`                 | double arrow                       | `switch` expression case separator    |
 | 
			
		||||
|                `//`                 | comment                            | line comment                          |
 | 
			
		||||
|                `///`                | doc-comment                        | line [doc-comment]                    |
 | 
			
		||||
|                `//!`                | module doc                         | [module documentation][comments]      |
 | 
			
		||||
|            `/*` ... `*/`            | comment                            | block comment                         |
 | 
			
		||||
|           `/**` ... `*/`            | doc-comment                        | block [doc-comment]                   |
 | 
			
		||||
|            `(*` ... `*)`            | comment                            | _reserved_                            |
 | 
			
		||||
|                `#!`                 | shebang                            | _reserved_                            |
 | 
			
		||||
|                `++`                 | increment                          | _reserved_                            |
 | 
			
		||||
|                `--`                 | decrement                          | _reserved_                            |
 | 
			
		||||
|                `...`                | rest                               | _reserved_                            |
 | 
			
		||||
|                 `~`                 | tilde                              | _reserved_                            |
 | 
			
		||||
|                `!.`                 |                                    | _reserved_                            |
 | 
			
		||||
|                 `?`                 | question                           | _reserved_                            |
 | 
			
		||||
|                 `#`                 | hash                               | _reserved_                            |
 | 
			
		||||
|                 `@`                 | at                                 | _reserved_                            |
 | 
			
		||||
|                 `$`                 | dollar                             | _reserved_                            |
 | 
			
		||||
|                `->`                 | arrow                              | _reserved_                            |
 | 
			
		||||
|                `<-`                 | left arrow                         | _reserved_                            |
 | 
			
		||||
|          <code><\|</code>           | left triangle                      | _reserved_                            |
 | 
			
		||||
|          <code>\|></code>           | right triangle                     | _reserved_                            |
 | 
			
		||||
|                `===`                | strict equals to                   | _reserved_                            |
 | 
			
		||||
|                `!==`                | strict not equals to               | _reserved_                            |
 | 
			
		||||
|                `:=`                 | assignment                         | _reserved_                            |
 | 
			
		||||
|                `:;`                 | typo to `::`                       | _reserved_                            |
 | 
			
		||||
|            `::<` ... `>`            | turbofish                          | _reserved_                            |
 | 
			
		||||
		Reference in New Issue
	
	Block a user