#include #include static int coin_code = 0; static int type_code = 0; static int variable_code = 0; static int constant_code = 0; static int function_code = 0; static int coin_data [240] = { 0 }; static int coin_size [240] = { 0 }; static char coin_text [240] [40] = { "" }; static char type_name [27] [40] = { "" }; static int type_size [27] = { 0 }; static char variable_name [27] [40] = { "" }; static int variable_type [27] = { 0 }; static int variable_data [27] = { 0 }; static char constant_name [30] [40] = { "" }; static int constant_type [30] = { 0 }; static int constant_data [30] = { 0 }; static char function_name [9] [40] = { "" }; static int function_type [9] = { 0 }; static char function_argument_name [9] [6] [40] = { { "" } }; static int function_argument_type [9] [6] = { { 0 } }; #include #include /* static char * register_list [] = { "rax","rdi","rsi","rdx","r10","r8","r9" }; */ static void add_coin (int data, int size, char * text) { coin_data [coin_code] = data; coin_size [coin_code] = size; string_copy_limit (coin_text [coin_code], text, size); ++coin_code; } static void kill (char * text, int offset) { int i; terminal_colour (colour_red, effect_bold); echo (text); terminal_cancel (); echo (coin_text [offset]); echo ("\n"); for (i = 0; i < offset + 3; ++i) { if (i == offset) { terminal_colour (colour_red, effect_bold); echo (coin_text [i]); echo (" "); terminal_cancel (); } else { echo (coin_text [i]); echo (" "); } } echo ("\n"); } int main (void) { char * buffer = null; int offset = 0; int length = 0; int select = 0; /**/int i; int coin_string = syntax_define (false, false, "\"", "\"", '\\', colour_red, effect_normal); int coin_type = syntax_define (false, true, "одреди", " \t\n", '\0', colour_yellow, effect_normal); int coin_loop = syntax_define (false, true, "понови", " \t\n(:", '\0', colour_yellow, effect_normal); int coin_if = syntax_define (false, true, "ако", " \t\n(", '\0', colour_yellow, effect_normal); int coin_else = syntax_define (false, true, "иначе", " \t\n:", '\0', colour_yellow, effect_normal); int coin_case = syntax_define (false, true, "погоди", " \t\n(", '\0', colour_yellow, effect_normal); int coin_return = syntax_define (false, true, "врати", " \t\n(;", '\0', colour_yellow, effect_normal); int coin_import = syntax_define (false, true, "учитај", " \t\n", '\0', colour_yellow, effect_normal); int coin_system = syntax_define (false, true, "изврши", " \t\n(", '\0', colour_yellow, effect_normal); int coin_number = syntax_define (true, true, "0123456789", " \t\n,.;:()[]#", '\0', colour_blue, effect_normal); int coin_marker = syntax_define (true, true, "абвгдђежзијклљмнљопрстћуфхцчџш_", " \t\n,.;:()[]#", '\0', colour_white, effect_normal); int coin_symbol = syntax_define (true, false, ",.;:=#[]()+-*/%&|!", "", '\0', colour_cyan, effect_normal); buffer = record (); for (offset = 0; buffer [offset] != '\0'; offset += length) { select = syntax_select (& buffer [offset], & length); if (select < syntax_count) { terminal_colour (syntax_colour [select], syntax_effect [select]); add_coin (select, length, & buffer [offset]); } else { terminal_colour (colour_red, effect_bold); if (character_compare_array (buffer [offset], " \t\n") == false) { kill ("Illegal character: ", offset); } } out (& buffer [offset], length); terminal_cancel (); } for (offset = 0; offset < coin_code; ++offset) { if (coin_data [offset] == coin_type) { ++offset; if (coin_data [offset] == coin_marker) { string_copy (type_name [type_code], coin_text [offset]); ++offset; if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == '=')) { ++offset; if (coin_data [offset] == coin_number) { type_size [type_code] = atoi (coin_text [offset]); ++offset; if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == ';')) { ++type_code; } else kill ("Expected semicolon symbol: ", offset); } else kill ("Expected number: ", offset); } else if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == '(')) { int counter = 0; type_size [type_code] = 4; for (++offset; offset < coin_code; ++offset) { if (coin_data [offset] == coin_marker) { string_copy (constant_name [constant_code], coin_text [offset]); constant_type [constant_code] = type_code; ++offset; if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == ')')) { constant_data [constant_code] = counter; ++counter; ++constant_code; break; } else if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == ',')) { constant_data [constant_code] = counter; ++counter; ++constant_code; } else if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == '=')) { ++offset; if (coin_data [offset] == coin_number) { int number = atoi (coin_text [offset]); constant_data [constant_code] = number; counter = number + 1; ++constant_code; ++offset; if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == ')')) { break; } else if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == ',')) { ++counter; /* Should I replace this? */ } else kill ("Expected , or ) ", offset); } else kill ("Expected constant data number:", offset); } else kill ("Expected = or , or ) ", offset); } else kill ("Expected constant name marker: ", offset); } ++type_code; } else kill ("Expected equal or open bracket 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] == ';')) { printf ("\033[1;32m%s: %s %i\033[0m\n", variable_name [variable_code], (type_size [variable_type [variable_code]] == 1) ? "db" : "dd", variable_data [variable_code]); ++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] == ';')) { printf ("\033[1;32m%s: %s %s, 0\033[0m\n", variable_name [variable_code], (type_size [variable_type [variable_code]] == 1) ? "db" : "dd", coin_text [offset - 1]); ++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] == ';')) { printf ("\033[1;32m%s: %s %i\033[0m\n", variable_name [variable_code], (type_size [variable_type [variable_code]] == 1) ? "db" : "dd", variable_data [variable_code]); ++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 if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == '(')) { string_copy (function_name [function_code], coin_text [offset - 1]); ++offset; if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == ')')) { ++offset; if ((coin_data [offset] == coin_symbol) && (* coin_text [offset] == ':')) { echo ("PROCESSING FUNCTION...\n"); ++function_code; } else kill ("Expected void function, symbol :: ", offset); } else kill ("Expected void function, symbol (): ", offset); } else kill ("Expected colon, open bracket or equal symbol: ", offset); } } /**/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]); /**/for (i = 0; i < constant_code; ++i) printf ("-constant- %s : %s = %i;\n", constant_name [i], type_name [constant_type [i]], constant_data [i]); /**/for (i = 0; i < function_code; ++i) printf ("-function- %s;\n", function_name [i]); buffer = deallocate (buffer); return (log_success); }