Improve treatment of disabled symbols and custom symbols.

This commit is contained in:
Stephen Chung
2020-07-17 14:50:23 +08:00
parent d119e13b79
commit 3ae7cf4018
9 changed files with 110 additions and 77 deletions

View File

@@ -68,11 +68,13 @@ These symbol types can be used:
### The First Symbol Must be a Keyword
There is no specific limit on the combination and sequencing of each symbol type,
except the _first_ symbol which must be a [custom keyword].
except the _first_ symbol which must be a custom keyword that follows the naming rules
of [variables].
It _cannot_ be a [built-in keyword]({{rootUrl}}/appendix/keywords.md).
The first symbol also cannot be a reserved [keyword], unless that keyword
has been [disabled][disable keywords and operators].
However, it _may_ be a built-in keyword that has been [disabled][disable keywords and operators].
In other words, any valid identifier that is not an active [keyword] will work fine.
### The First Symbol Must be Unique

View File

@@ -20,8 +20,7 @@ engine
// The following all return parse errors.
engine.compile("let x = if true { 42 } else { 0 };")?;
// ^ missing ';' after statement end
// ^ 'if' is parsed as a variable name
// ^ 'if' is rejected as a reserved keyword
engine.compile("let x = 40 + 2; x += 1;")?;
// ^ '+=' is not recognized as an operator