all repos — hex @ 0c3becebfd515a08ac8d4f054798590685b71d6c

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

Updated opcodes
Fabio Cevasco h3rald@h3rald.com
Mon, 23 Dec 2024 12:00:12 +0100
commit

0c3becebfd515a08ac8d4f054798590685b71d6c

parent

5ffde1ab0ec86e90ab9eeff345f8a32d34068e31

2 files changed, 61 insertions(+), 63 deletions(-)

jump to
M src/hex.hsrc/hex.h

@@ -162,66 +162,64 @@ // Native Symbols

HEX_OP_STORE = 0x10, HEX_OP_DEFINE = 0x11, HEX_OP_FREE = 0x12, + HEX_OP_SYMBOLS = 0x13, - HEX_OP_IF = 0x13, - HEX_OP_WHEN = 0x14, - HEX_OP_WHILE = 0x15, - HEX_OP_ERROR = 0x16, - HEX_OP_TRY = 0x17, + HEX_OP_IF = 0x14, + HEX_OP_WHEN = 0x15, + HEX_OP_WHILE = 0x16, + HEX_OP_ERROR = 0x17, + HEX_OP_TRY = 0x18, + HEX_OP_THROW = 0x19, - HEX_OP_DUP = 0x18, - HEX_OP_STACK = 0x19, - HEX_OP_CLEAR = 0x1a, - HEX_OP_POP = 0x1b, - HEX_OP_SWAP = 0x1c, - - HEX_OP_I = 0x1d, - HEX_OP_EVAL = 0x1e, - HEX_OP_QUOTE = 0x1f, - - HEX_OP_ADD = 0x20, - HEX_OP_SUB = 0x21, - HEX_OP_MUL = 0x22, - HEX_OP_DIV = 0x23, - HEX_OP_MOD = 0x24, + HEX_OP_DUP = 0x1a, + HEX_OP_STACK = 0x1b, + HEX_OP_POP = 0x1c, + HEX_OP_SWAP = 0x1d, - HEX_OP_BITAND = 0x25, - HEX_OP_BITOR = 0x26, - HEX_OP_BITXOR = 0x27, - HEX_OP_BITNOT = 0x28, - HEX_OP_SHL = 0x29, - HEX_OP_SHR = 0x2a, + HEX_OP_I = 0x1e, + HEX_OP_EVAL = 0x1f, + HEX_OP_QUOTE = 0x20, - HEX_OP_EQUAL = 0x2b, - HEX_OP_NOTEQUAL = 0x2c, - HEX_OP_GREATER = 0x2d, - HEX_OP_LESS = 0x2e, - HEX_OP_GREATEREQUAL = 0x2f, - HEX_OP_LESSEQUAL = 0x30, + HEX_OP_ADD = 0x21, + HEX_OP_SUB = 0x22, + HEX_OP_MUL = 0x23, + HEX_OP_DIV = 0x24, + HEX_OP_MOD = 0x25, - HEX_OP_AND = 0x31, - HEX_OP_OR = 0x32, - HEX_OP_NOT = 0x33, - HEX_OP_XOR = 0x34, + HEX_OP_BITAND = 0x26, + HEX_OP_BITOR = 0x27, + HEX_OP_BITXOR = 0x28, + HEX_OP_BITNOT = 0x29, + HEX_OP_SHL = 0x2a, + HEX_OP_SHR = 0x2b, - HEX_OP_INT = 0x35, - HEX_OP_STR = 0x36, - HEX_OP_DEC = 0x37, - HEX_OP_HEX = 0x38, - HEX_OP_ORD = 0x39, - HEX_OP_CHR = 0x3a, - HEX_OP_TYPE = 0x3b, + HEX_OP_EQUAL = 0x2c, + HEX_OP_NOTEQUAL = 0x2d, + HEX_OP_GREATER = 0x2e, + HEX_OP_LESS = 0x2f, + HEX_OP_GREATEREQUAL = 0x30, + HEX_OP_LESSEQUAL = 0x31, - HEX_OP_CAT = 0x3c, - HEX_OP_LEN = 0x3d, - HEX_OP_GET = 0x3e, - HEX_OP_INDEX = 0x3f, - HEX_OP_JOIN = 0x40, + HEX_OP_AND = 0x32, + HEX_OP_OR = 0x33, + HEX_OP_NOT = 0x34, + HEX_OP_XOR = 0x35, - HEX_OP_SPLIT = 0x41, - HEX_OP_REPLACE = 0x42, + HEX_OP_INT = 0x36, + HEX_OP_STR = 0x37, + HEX_OP_DEC = 0x38, + HEX_OP_HEX = 0x39, + HEX_OP_ORD = 0x3a, + HEX_OP_CHR = 0x3b, + HEX_OP_TYPE = 0x3c, - HEX_OP_EACH = 0x43, + HEX_OP_CAT = 0x3d, + HEX_OP_LEN = 0x3e, + HEX_OP_GET = 0x3f, + HEX_OP_INDEX = 0x40, + HEX_OP_JOIN = 0x41, + HEX_OP_SPLIT = 0x42, + HEX_OP_REPLACE = 0x43, HEX_OP_MAP = 0x44, HEX_OP_PUTS = 0x45,
M src/opcodes.csrc/opcodes.c

@@ -17,6 +17,10 @@ else if (strcmp(symbol, "#") == 0)

{ return HEX_OP_FREE; } + else if (strcmp(symbol, "symbols") == 0) + { + return HEX_OP_SYMBOLS; + } else if (strcmp(symbol, "if") == 0) { return HEX_OP_IF;

@@ -37,6 +41,10 @@ else if (strcmp(symbol, "try") == 0)

{ return HEX_OP_TRY; } + else if (strcmp(symbol, "throw") == 0) + { + return HEX_OP_THROW; + } else if (strcmp(symbol, "dup") == 0) { return HEX_OP_DUP;

@@ -44,10 +52,6 @@ }

else if (strcmp(symbol, "stack") == 0) { return HEX_OP_STACK; - } - else if (strcmp(symbol, "clear") == 0) - { - return HEX_OP_CLEAR; } else if (strcmp(symbol, "pop") == 0) {

@@ -209,10 +213,6 @@ else if (strcmp(symbol, "replace") == 0)

{ return HEX_OP_REPLACE; } - else if (strcmp(symbol, "each") == 0) - { - return HEX_OP_EACH; - } else if (strcmp(symbol, "map") == 0) { return HEX_OP_MAP;

@@ -274,6 +274,8 @@ case HEX_OP_DEFINE:

return "::"; case HEX_OP_FREE: return "#"; + case HEX_OP_SYMBOLS: + return "symbols"; case HEX_OP_IF: return "if"; case HEX_OP_WHEN:

@@ -284,12 +286,12 @@ case HEX_OP_ERROR:

return "error"; case HEX_OP_TRY: return "try"; + case HEX_OP_THROW: + return "throw"; case HEX_OP_DUP: return "dup"; case HEX_OP_STACK: return "stack"; - case HEX_OP_CLEAR: - return "clear"; case HEX_OP_POP: return "pop"; case HEX_OP_SWAP:

@@ -370,8 +372,6 @@ case HEX_OP_SPLIT:

return "split"; case HEX_OP_REPLACE: return "replace"; - case HEX_OP_EACH: - return "each"; case HEX_OP_MAP: return "map"; case HEX_OP_PUTS: