From 40f30e0bbbcef2a48e786fa71b080d886f80e677 Mon Sep 17 00:00:00 2001 From: xolatile Date: Fri, 5 Apr 2024 06:27:35 -0400 Subject: [PATCH] Variable system, debugging and core error system... --- heyo.x | 4 ++-- xiranda.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/heyo.x b/heyo.x index 306c793..ab5a6ff 100644 --- a/heyo.x +++ b/heyo.x @@ -1,8 +1,8 @@ type integer = 4; type character = 1; -text: character [] = "Heyo world!"; -size: integer = 12; +text: character = "Heyo world!"; +size: integer = 12; main (): system (1, 1, #text, size); diff --git a/xiranda.c b/xiranda.c index 28ccbdf..42edd26 100644 --- a/xiranda.c +++ b/xiranda.c @@ -29,7 +29,6 @@ static int function_argument_type [9] [6] = { { 0 } }; */ #include #include - /* static char * register_list [] = { "rax","rdi","rsi","rdx","r10","r8","r9" @@ -42,11 +41,13 @@ static void add_coin (int data, int size, char * text) { ++coin_code; } -static void kill (char * text) { +static void kill (char * text, int offset) { terminal_colour (colour_red, effect_bold); echo (text); terminal_cancel (); - exit (log_failure); + echo (coin_text [offset]); + echo ("\n"); + /*exit (log_failure);*/ } int main (void) { @@ -80,7 +81,7 @@ int main (void) { } else { terminal_colour (colour_red, effect_bold); if (character_compare_array (buffer [offset], " \t\n") == false) { - kill ("Illegal character...\n"); + kill ("Illegal character: ", offset); } } out (& buffer [offset], length); @@ -100,14 +101,56 @@ int main (void) { ++offset; if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == ';')) { ++type_code; - } else kill ("Expected semicolon symbol...\n"); - } else kill ("Expected number...\n"); - } else kill ("Expected equal symbol...\n"); - } else kill ("Expected marker...\n"); + } else kill ("Expected semicolon symbol: ", offset); + } else kill ("Expected number: ", offset); + } else kill ("Expected equal symbol: ", offset); + } 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);