Add shared and sync to reserved keywords.

This commit is contained in:
Stephen Chung 2020-07-28 10:25:26 +08:00
parent 057f6435a4
commit f05cd1fdf3
3 changed files with 19 additions and 17 deletions

View File

@ -59,8 +59,10 @@ Reserved Keywords
| `package` | Package |
| `spawn` | Threading |
| `go` | Threading |
| `shared` | Threading |
| `await` | Async |
| `async` | Async |
| `sync` | Async |
| `yield` | Async |
| `default` | Special value |
| `void` | Special value |

View File

@ -6,7 +6,7 @@ Keywords
The following are reserved keywords in Rhai:
| Active keywords | Reserved keywords | Usage | Inactive under feature |
| ------------------------------------------------- | ---------------------------------------- | --------------------- | :--------------------: |
| ------------------------------------------------- | ---------------------------------------------------------- | --------------------- | :--------------------: |
| `true`, `false` | | Boolean constants | |
| `let`, `const` | `var`, `static` | Variable declarations | |
| `if`, `else` | `then`, `goto`, `exit` | Control flow | |
@ -17,7 +17,7 @@ The following are reserved keywords in Rhai:
| `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 | |
| | `spawn`, `go`, `shared`, `sync`, `async`, `await`, `yield` | Threading/async | |
| `type_of`, `print`, `debug`, `eval` | | Special functions | |
| | `default`, `void`, `null`, `nil` | Special values | |

View File

@ -495,8 +495,8 @@ impl Token {
"===" | "!==" | "->" | "<-" | "=>" | ":=" | "::<" | "(*" | "*)" | "#" | "public"
| "new" | "use" | "module" | "package" | "var" | "static" | "with" | "do" | "each"
| "then" | "goto" | "exit" | "switch" | "match" | "case" | "try" | "catch"
| "default" | "void" | "null" | "nil" | "spawn" | "go" | "async" | "await"
| "yield" => Reserved(syntax.into()),
| "default" | "void" | "null" | "nil" | "spawn" | "go" | "shared" | "sync"
| "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()),