Removed coin types for symbols...

This commit is contained in:
Ognjen Milan Robovic 2024-04-03 16:02:43 -04:00
parent da08d3543a
commit 5d81beb8d2

View File

@ -2,10 +2,7 @@
enum {
coin_type, coin_loop, coin_if, coin_else, coin_case, coin_return, coin_import, coin_system,
coin_function, coin_variable, coin_constant, coin_data_type, coin_string, coin_number, coin_marker, coin_label,
coin_add, coin_subtract, coin_multiply, coin_divide, coin_modulus, coin_equal, coin_above, coin_below,
coin_open, coin_close, coin_next, coin_stop, coin_branch, coin_and, coin_or, coin_not,
coin_range, coin_enrange, coin_derange, coin_machine
coin_function, coin_variable, coin_constant, coin_data_type, coin_string, coin_number, coin_marker, coin_symbol
};
static int coin_code = 0;
@ -113,31 +110,8 @@ int main (void) {
--offset;
} else if (character_compare_array (buffer [offset], ",.;:=<>#&|!+*-/%()[]") == true) {
char s [2] = "";
int kind = 0;
s [0] = buffer [offset];
switch (buffer [offset]) {
case '+': kind = coin_add; break;
case '-': kind = coin_subtract; break;
case '*': kind = coin_multiply; break;
case '/': kind = coin_divide; break;
case '%': kind = coin_modulus; break;
case '=': kind = coin_equal; break;
case '>': kind = coin_above; break;
case '<': kind = coin_below; break;
case '(': kind = coin_open; break;
case ')': kind = coin_close; break;
case ',': kind = coin_next; break;
case ';': kind = coin_stop; break;
case ':': kind = coin_branch; break;
case '&': kind = coin_and; break;
case '|': kind = coin_or; break;
case '!': kind = coin_not; break;
case '.': kind = coin_range; break;
case '[': kind = coin_enrange; break;
case ']': kind = coin_derange; break;
case '#': kind = coin_machine; break;
}
add_coin (kind, (int) buffer [offset], s);
add_coin (coin_symbol, (int) buffer [offset], s);
} else {
if (character_is_blank (buffer [offset]) == false) {
echo ("\033[1;31mCharacter set exception point: Segmentation\033[0m\n");
@ -146,7 +120,7 @@ int main (void) {
}
}
}
/*
for (length = 0; length < coin_code; ++length) {
switch (coin_enum [length]) {
case coin_string: printf ("\033[1;32m%s\033[0m ", coin_text [length]); break;
@ -160,11 +134,12 @@ int main (void) {
case coin_loop:
case coin_import:
case coin_system:
case coin_return: printf ("\033[1;33m%s\033[0m ", coin_text [length]); break;
default: printf ("\033[1;31m%s\033[0m ", coin_text [length]); break;
case coin_return: printf ("\033[1;33m%s\033[0m ", coin_text [length]); break;
case coin_symbol: printf ("\033[1;35m%s\033[0m ", coin_text [length]); break;
default: printf ("\033[1;31m%s\033[0m ", coin_text [length]); break;
}
}
*/
printf ("\n");
printf ("format ELF64 executable 3\n\n");
@ -173,31 +148,30 @@ int main (void) {
printf ("main:\n\n");
for (length = 0; length < coin_code; ++length) {
if ((coin_enum [length] == coin_return) && (coin_enum [length + 1] == coin_stop)) {
if ((coin_enum [length] == coin_return) && (coin_data [length + 1] == ';')) {
printf ("; return;\nxor rax, rax\nret\n\n");
length += 1;
} else if ((coin_enum [length] == coin_return) && (coin_enum [length + 1] == coin_number) && (coin_enum [length + 2] == coin_stop)) {
} else if ((coin_enum [length] == coin_return) && (coin_enum [length + 1] == coin_number) && (coin_data [length + 2] == ';')) {
printf ("; return {number};\nmov rax, %s\nret\n\n", coin_text [length + 1]);
length += 2;
} else if ((coin_enum [length] == coin_system) && (coin_enum [length + 1] == coin_open)) {
} else if ((coin_enum [length] == coin_system) && (coin_data [length + 1] == '(')) {
int use = 0;
/*int fit = 0;*/
printf ("; system ({...});\n");
length += 2;
while (coin_enum [length] != coin_close) {
while (coin_data [length] != ')') {
switch (coin_enum [length]) {
case coin_machine: length += 1; printf ("mov %s, %s\n", register_list [use], coin_text [length]); use++; break;
case coin_number: printf ("mov %s, %s\n", register_list [use], coin_text [length]); use++; break;
case coin_marker: printf ("mov %s, [%s]\n", register_list [use], coin_text [length]); use++; break;
case coin_symbol: if (coin_data [length] == '#') {length += 1; printf ("mov %s, %s\n", register_list [use], coin_text [length]); use++; } break;
case coin_number: printf ("mov %s, %s\n", register_list [use], coin_text [length]); use++; break;
case coin_marker: printf ("mov %s, [%s]\n", register_list [use], coin_text [length]); use++; break;
default: break;
}
length += 1;
if (coin_enum [length] == coin_next)
if (coin_data [length] == ',')
length += 1;
}
if (coin_enum [length] == coin_close)
length += 1;
if (coin_enum [length] != coin_stop)
length += 1;
if (coin_data [length] != ';')
echo ("EXPECTED STOP ';'\n");
printf ("syscall\n\n");
}