all repos — hex @ 708be30dd0d3c45188185702e711dafb04284a60

A tiny, minimalist, slightly-esoteric concatenative programming lannguage.

Updating sizes.
h3rald h3rald@h3rald.com
Fri, 20 Dec 2024 07:24:16 +0100
commit

708be30dd0d3c45188185702e711dafb04284a60

parent

05bad6cfd97bd00df9a62ac18682ffea672310fd

4 files changed, 13 insertions(+), 5 deletions(-)

jump to
M releases/0.2.0.htmlreleases/0.2.0.html

@@ -5,11 +5,13 @@ <ul>

<li>Implemented a virtual machine with a bytecode compiler and interpreter.</li> <li>{{sym-read}}, {{sym-write}}, {{sym-append}} now support reading and writing from/to binary files as well.</li> <li>{{sym-!}} can now evaluate a quotation of integers as hex bytecode.</li> + <li>Increased maximum stack size to 256 items.</li> </ul> <h4>Fixes</h4> <ul> <li>Ensured that {{sym-dec}} is able to print negative integers in decimal format.</li> + <li>Ensured that symbol identifiers cannot be longer than 256 characters.</li> </ul> <h4>Chores</h4>
M src/hex.hsrc/hex.h

@@ -23,11 +23,11 @@ // Constants

#define HEX_VERSION "0.1.0" #define HEX_STDIN_BUFFER_SIZE 256 #define HEX_REGISTRY_SIZE 1024 -#define HEX_STACK_SIZE 128 +#define HEX_STACK_SIZE 256 #define HEX_STACK_TRACE_SIZE 16 #define HEX_NATIVE_SYMBOLS 64 -#define HEX_MAX_SYMBOL_LENGTH 255 -#define HEX_MAX_USER_SYMBOLS 65535 +#define HEX_MAX_SYMBOL_LENGTH 256 +#define HEX_MAX_USER_SYMBOLS (HEX_REGISTRY_SIZE - HEX_NATIVE_SYMBOLS) // Type Definitions typedef enum hex_item_type_t
M src/registry.csrc/registry.c

@@ -20,6 +20,11 @@ {

hex_error(ctx, "Invalid symbol: %s", symbol); return 0; } + /*if (strlen(symbol) > HEX_MAX_SYMBOL_LENGTH) + { + hex_error(ctx, "Symbol name too long: %s", symbol); + return 0; + }*/ for (size_t j = 1; j < strlen(symbol); j++) { if (!isalnum(symbol[j]) && symbol[j] != '_' && symbol[j] != '-')
M web/contents/spec.htmlweb/contents/spec.html

@@ -247,7 +247,7 @@ <p>The stack is a fundamental data structure in hex that holds values and controls the flow of execution. hex is a

stack-based language, meaning that all operations are performed on a stack of values. The order according to which items are added (pushed) to or removed (popped) from the stack is <abbr title="Last In, First Out">LIFO</abbr>.</p> - <p>In the canonical implementation, the hex stack can contain up to 128 items. If you try to push more items on the + <p>In the canonical implementation, the hex stack can contain up to 256 items. If you try to push more items on the stack, a stack overflow error will be raised and the program will terminate. While this may seem a relatively low number, it is important to note that typically there will not be more than 5-10 items on the stack at any time, because typically symbols are used to frequently pop them out of the stacks.</p>

@@ -300,7 +300,8 @@ provided natively.</p>

<p>It is important to note that the registry is a global store, meaning that symbols are not lexically scoped and can be accessed from anywhere in the program. This design choice was made to keep the language simple and straightforward.</p> - <p>In the canonical hex implementation, the registry can hold up to 1024 symbols.</p> + <p>In the canonical hex implementation, the registry can hold up to 1024 symbols (960 of which can be user-defined + symbols).</p> <h3 id="native-symbols">Native Symbol Reference<a href="#top"></a></h3> <p>hex provides a set of 64 ($0x40$$) native symbols that are built-in and pre-defined in the registry. The following section provides details on each of these symbols, including a signature illustrating how each symbol