From f8ae1e1eb516456f5040653e9a806051193b423a Mon Sep 17 00:00:00 2001 From: sbosse Date: Mon, 16 Mar 2026 11:40:13 +0100 Subject: [PATCH] Mon 16 Mar 11:39:34 CET 2026 --- doc/data.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 doc/data.md diff --git a/doc/data.md b/doc/data.md new file mode 100644 index 0000000..dac959e --- /dev/null +++ b/doc/data.md @@ -0,0 +1,27 @@ +## Data and Expression + +There are constants (provided by the host application), global and local variables, scalar variables (data type `number_t`), numeric arrays (element data type `number_t`), and strings (element data type `int8_t`). Global variables are stored on the heap, wheras local variables are stored on the data stack. + +Scalar and string global variables can be explicitly defined and allocated using the `var` statement or by assigning a value. Not allocated variables may not be used in expressions. Array variables must be defined by using the `var` statements as well as local variables by using the `var*` statement. + +Expressions with infix notation are compiled into stack operations with post-fix operations, preserving operator bindings. + +| Statement | Description | +|:--|:--| +| `var a,b(20),c$,d$(10)` | Definition and allocation of scalar (a), array (b), string (c), and string with length (d) variables. | +| `var* a,b,c` | Definition of local variables (on stack) | +| `const a=n,b=n,c=n` | Definition of constant values (on heap, but read-only, only numbers or characters *n* can be assigned) | +| `x=ε` | Assignment of value to variable *x* (with allocation if not already defined) | + +### Operators + +| Operators | Description | +|:--|:--| +| `+ - * / mod` | Arithmetic infix operations | +| `< > <= >=` | Relational infix operations | +| `and or not` | Logical and Boolean infix and prefix operations | +| `$var `| Address of variable (postive: heap: neagtive: data stack) | +| `var$` | String variable | +| `x(i)` | Array selector (first index is 1) | + +