add subtract support and string concatenation

This commit is contained in:
William Bell
2025-08-15 05:41:26 +01:00
parent c3c7f1597e
commit 2d577594fc
12 changed files with 156 additions and 21 deletions

View File

@@ -8,18 +8,20 @@
#include <stddef.h>
size_t translate_operation(Translated *translated, ParsedOperation *operation,
ArErr *err) {
ArErr *err) {
set_registers(translated, 1);
uint64_t first;
switch (operation->operation) {
case TOKEN_PLUS:;
first = push_instruction_byte(translated, OP_LOAD_ADDITION_FUNCTION);
break;
default:
*err = create_err(operation->line, operation->column,
operation->length, translated->path, "Syntax Error",
"unknown operation");
return 0;
case TOKEN_PLUS:;
first = push_instruction_byte(translated, OP_LOAD_ADDITION_FUNCTION);
break;
case TOKEN_MINUS:
first = push_instruction_byte(translated, OP_LOAD_SUBTRACTION_FUNCTION);
break;
default:
*err = create_err(operation->line, operation->column, operation->length,
translated->path, "Syntax Error", "unknown operation");
return 0;
}
push_instruction_byte(translated, OP_INIT_CALL);
push_instruction_code(translated, operation->to_operate_on.size);