You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs-language/control-flow.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,8 @@ import TokenScriptCodeBlock from '@site/src/components/TokenScriptCodeBlock';
10
10
11
11
TokenScript executes statements sequentially within a single global scope. The interpreter maintains one `SymbolTable` (`src/interpreter/symbolTable.ts`), so variables declared in any block remain available globally unless reassigned later.
12
12
13
+
Each execution in schemas (types, functions) has it's own scope and cannot access the parents variables.
14
+
13
15
## Statement Evaluation
14
16
15
17
- Programs consist of a top-level list of statements. The interpreter walks the list and keeps the most recent non-null value as the block result.
@@ -97,5 +99,3 @@ return palette.length();
97
99
98
100
- Syntax errors (unexpected tokens, missing brackets) are raised during parsing with annotated source snippets.
99
101
- Runtime errors (type mismatches, invalid method calls, excessive loop iterations) raise `InterpreterError` with the line number of the offending token.
100
-
101
-
Continue to [Built-in Functions](functions.md) for available runtime helpers and math utilities.
|`min`| `min(...values: Number | NumberWithUnit)`| Returns the smallest numeric value (units allowed when compatible). |
16
-
|`max`| `max(...values: Number | NumberWithUnit)`| Returns the largest numeric value. |
17
-
|`sum`| `sum(...values: Number | NumberWithUnit)`| Adds values, converting units via `UnitManager` when available. |
15
+
|`min`|`min(...values: Number \| NumberWithUnit)`| Returns the smallest numeric value (units allowed when compatible). |
16
+
|`max`|`max(...values: Number \| NumberWithUnit)`| Returns the largest numeric value. |
17
+
|`sum`|`sum(...values: Number \| NumberWithUnit)`| Adds values, converting units via `UnitManager` when available. |
18
18
|`average`|`average(...values: Number)`| Arithmetic mean of numeric arguments. |
19
19
|`mod`|`mod(a: Number, b: Number)`| Modulo operation with safe handling for negatives. |
20
20
|`round`|`round(value: Number)`| Bankers rounding (0.5 rounds to nearest even). |
@@ -47,10 +47,3 @@ TokenScript exposes a standard library of functions supplied by the `FunctionsMa
47
47
48
48
- The `FunctionsManager` loads additional functions from JSON specifications (see `docs/extensions/functions.md`, to be authored).
49
49
- Spec-defined functions use the same validation pipeline and become available immediately after registration.
50
-
51
-
## Error Handling
52
-
53
-
- Functions validate argument counts and types. Violations produce descriptive error messages, e.g., `"log() base must be positive and not equal to 1."`
Copy file name to clipboardExpand all lines: docs-language/syntax.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -133,5 +133,3 @@ Parentheses `()` override precedence as expected.
133
133
## Error Reporting
134
134
135
135
The parser provides context-aware errors with line/column highlighting when encountering unexpected tokens, missing delimiters, or malformed type declarations. Runtime type mismatches and method resolution errors raise `InterpreterError` instances, reported with the source token metadata.
136
-
137
-
Proceed to [Types and Symbols](types.md) for a complete catalog of runtime types and their methods.
0 commit comments