Add more reserved keywords.
This commit is contained in:
parent
878ba0b794
commit
ce20248792
@ -3,8 +3,8 @@ Keywords List
|
||||
|
||||
{{#include ../links.md}}
|
||||
|
||||
| Keyword | Description | Not available under |
|
||||
| :-------------------: | ---------------------------------------- | :-----------------: |
|
||||
| Keyword | Description | Inactive under |
|
||||
| :-------------------: | ---------------------------------------- | :-------------: |
|
||||
| `true` | Boolean true literal | |
|
||||
| `false` | Boolean false literal | |
|
||||
| `let` | Variable declaration | |
|
||||
@ -32,3 +32,36 @@ Keywords List
|
||||
| `print` | Print value | |
|
||||
| `debug` | Print value in debug format | |
|
||||
| `eval` | Evaluate script | |
|
||||
|
||||
|
||||
Reserved Keywords
|
||||
-----------------
|
||||
|
||||
| Keyword | Potential usage |
|
||||
| --------- | --------------------- |
|
||||
| `var` | Variable declaration |
|
||||
| `static` | Variable declaration |
|
||||
| `do` | Looping |
|
||||
| `each` | Looping |
|
||||
| `then` | Conditional |
|
||||
| `goto` | Jump |
|
||||
| `switch` | Matching |
|
||||
| `match` | Matching |
|
||||
| `case` | Matching |
|
||||
| `public` | Function/field access |
|
||||
| `new` | Constructor |
|
||||
| `try` | Trap exception |
|
||||
| `catch` | Catch exception |
|
||||
| `use` | Import namespace |
|
||||
| `with` | Scope |
|
||||
| `module` | Module |
|
||||
| `package` | Package |
|
||||
| `spawn` | Threading |
|
||||
| `go` | Threading |
|
||||
| `await` | Async |
|
||||
| `async` | Async |
|
||||
| `yield` | Async |
|
||||
| `default` | Special value |
|
||||
| `void` | Special value |
|
||||
| `null` | Special value |
|
||||
| `nil` | Special value |
|
||||
|
@ -5,18 +5,21 @@ Keywords
|
||||
|
||||
The following are reserved keywords in Rhai:
|
||||
|
||||
| Keywords | Usage | Not available under feature |
|
||||
| ------------------------------------------------- | --------------------- | :-------------------------: |
|
||||
| `true`, `false` | Boolean constants | |
|
||||
| `let`, `const` | Variable declarations | |
|
||||
| `if`, `else` | Control flow | |
|
||||
| `while`, `loop`, `for`, `in`, `continue`, `break` | Looping | |
|
||||
| `fn`, `private` | Functions | [`no_function`] |
|
||||
| `return` | Return values | |
|
||||
| `throw` | throw exceptions | |
|
||||
| `import`, `export`, `as` | Modules | [`no_module`] |
|
||||
| `Fn`, `call` | Function pointers | |
|
||||
| `type_of`, `print`, `debug`, `eval` | Special functions | |
|
||||
| Active keywords | Reserved keywords | Usage | Inactive under feature |
|
||||
| ------------------------------------------------- | ---------------------------------------- | --------------------- | :--------------------: |
|
||||
| `true`, `false` | | Boolean constants | |
|
||||
| `let`, `const` | `var`, `static` | Variable declarations | |
|
||||
| `if`, `else` | `then`, `goto` | Control flow | |
|
||||
| | `switch`, `match`, `case` | Matching | |
|
||||
| `while`, `loop`, `for`, `in`, `continue`, `break` | `do`, `each` | Looping | |
|
||||
| `fn`, `private` | `public`, `new` | Functions | [`no_function`] |
|
||||
| `return` | | Return values | |
|
||||
| `throw` | `try`, `catch` | Throw exceptions | |
|
||||
| `import`, `export`, `as` | `use`, `with`, `module`, `package` | Modules/packages | [`no_module`] |
|
||||
| `Fn`, `call`, `curry` | | Function pointers | |
|
||||
| | `spawn`, `go`, `async`, `await`, `yield` | Threading/async | |
|
||||
| `type_of`, `print`, `debug`, `eval` | | Special functions | |
|
||||
| | `default`, `void`, `null`, `nil` | Special values | |
|
||||
|
||||
Keywords cannot become the name of a [function] or [variable], even when they are disabled.
|
||||
|
||||
Keywords cannot be the name of a [function] or [variable], unless the relevant feature is enabled.
|
||||
For example, `fn` is a valid variable name under [`no_function`].
|
||||
|
@ -492,9 +492,13 @@ impl Token {
|
||||
#[cfg(feature = "no_module")]
|
||||
"import" | "export" | "as" => Reserved(syntax.into()),
|
||||
|
||||
"===" | "!==" | "->" | "<-" | "=>" | ":=" | "::<" | "(*" | "*)" | "#" => {
|
||||
"===" | "!==" | "->" | "<-" | "=>" | ":=" | "::<" | "(*" | "*)" | "#" | "public"
|
||||
| "new" | "use" | "module" | "package" | "var" | "static" | "with" | "do" | "each"
|
||||
| "then" | "goto" | "switch" | "match" | "case" | "try" | "catch" | "default"
|
||||
| "void" | "null" | "nil" | "spawn" | "go" | "async" | "await" | "yield" => {
|
||||
Reserved(syntax.into())
|
||||
}
|
||||
|
||||
KEYWORD_PRINT | KEYWORD_DEBUG | KEYWORD_TYPE_OF | KEYWORD_EVAL | KEYWORD_FN_PTR
|
||||
| KEYWORD_FN_PTR_CALL | KEYWORD_FN_PTR_CURRY | KEYWORD_THIS => Reserved(syntax.into()),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user