Variable system, debugging and core error system...

This commit is contained in:
Ognjen Milan Robovic 2024-04-05 06:27:35 -04:00
parent 88b19f1ca4
commit 40f30e0bbb
2 changed files with 54 additions and 11 deletions

2
heyo.x
View File

@ -1,7 +1,7 @@
type integer = 4; type integer = 4;
type character = 1; type character = 1;
text: character [] = "Heyo world!"; text: character = "Heyo world!";
size: integer = 12; size: integer = 12;
main (): main ():

View File

@ -29,7 +29,6 @@ static int function_argument_type [9] [6] = { { 0 } };
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
/* /*
static char * register_list [] = { static char * register_list [] = {
"rax","rdi","rsi","rdx","r10","r8","r9" "rax","rdi","rsi","rdx","r10","r8","r9"
@ -42,11 +41,13 @@ static void add_coin (int data, int size, char * text) {
++coin_code; ++coin_code;
} }
static void kill (char * text) { static void kill (char * text, int offset) {
terminal_colour (colour_red, effect_bold); terminal_colour (colour_red, effect_bold);
echo (text); echo (text);
terminal_cancel (); terminal_cancel ();
exit (log_failure); echo (coin_text [offset]);
echo ("\n");
/*exit (log_failure);*/
} }
int main (void) { int main (void) {
@ -80,7 +81,7 @@ int main (void) {
} else { } else {
terminal_colour (colour_red, effect_bold); terminal_colour (colour_red, effect_bold);
if (character_compare_array (buffer [offset], " \t\n") == false) { if (character_compare_array (buffer [offset], " \t\n") == false) {
kill ("Illegal character...\n"); kill ("Illegal character: ", offset);
} }
} }
out (& buffer [offset], length); out (& buffer [offset], length);
@ -100,14 +101,56 @@ int main (void) {
++offset; ++offset;
if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == ';')) { if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == ';')) {
++type_code; ++type_code;
} else kill ("Expected semicolon symbol...\n"); } else kill ("Expected semicolon symbol: ", offset);
} else kill ("Expected number...\n"); } else kill ("Expected number: ", offset);
} else kill ("Expected equal symbol...\n"); } else kill ("Expected equal symbol: ", offset);
} else kill ("Expected marker...\n"); } else kill ("Expected marker: ", offset);
} else if (coin_data [offset] == coin_marker) {
++offset;
if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == ':')) {
string_copy (variable_name [variable_code], coin_text [offset - 1]);
++offset;
if (coin_data [offset] == coin_marker) {
int j;
for (j = 0; j < type_code; ++j) {
if (string_compare (coin_text [offset], type_name [j]) == true) {
variable_type [variable_code] = j;
break;
}
}
if (j == type_code) {
kill ("Unknown type: ", offset);
}
++offset;
if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == '=')) {
++offset;
if (coin_data [offset] == coin_number) {
variable_data [variable_code] = atoi (coin_text [offset]);
++offset;
if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == ';')) {
++variable_code;
} else kill ("Expected semicolon symbol: ", offset);
} else if (coin_data [offset] == coin_string) {
variable_data [variable_code] = 33;
++offset;
if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == ';')) {
++variable_code;
} else kill ("Expected semicolon symbol: ", offset);
} else if (coin_data [offset] == coin_marker) {
variable_data [variable_code] = 66;
++offset;
if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == ';')) {
++variable_code;
} else kill ("Expected semicolon symbol: ", offset);
} else kill ("Expected marker, number or string: ", offset);
} else kill ("Expected equal symbol: ", offset);
} else kill ("Expected type: ", offset);
} else kill ("Expected colon symbol: ", offset);
} }
} }
/**/for (i = 0; i < type_code; ++i) printf ("-type- %s : %i\n", type_name [i], type_size [i]); /**/for (i = 0; i < type_code; ++i) printf ("-type- %s = %i;\n", type_name [i], type_size [i]);
/**/for (i = 0; i < variable_code; ++i) printf ("-variable- %s : %s = %i;\n", variable_name [i], type_name [variable_type [i]], variable_data [i]);
buffer = deallocate (buffer); buffer = deallocate (buffer);