From 3575b518ea2ff9615b37a443721c24d819b3fc52 Mon Sep 17 00:00:00 2001 From: xolatile Date: Fri, 5 Apr 2024 02:52:26 -0400 Subject: [PATCH] Changed a lot of things, parsing now... --- xiranda.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/xiranda.c b/xiranda.c index 3875a49..fda77c1 100644 --- a/xiranda.c +++ b/xiranda.c @@ -1,35 +1,34 @@ #include #include -static int coin_code = 0; -static int type_code = 0;/* +static int coin_code = 0;/* +static int type_code = 0; static int function_code = 0; static int variable_code = 0; static int constant_code = 0;*/ static int coin_enum [240] = { 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 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 } }; -*/ + 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 }; */ #include - -#define STRING_LIMIT (40) /* static char * word_list [] = { "type", "loop", "if", "else", "case", "return", "import", "system" @@ -38,21 +37,21 @@ static char * word_list [] = { static char * register_list [] = { "rax","rdi","rsi","rdx","r10","r8","r9" }; - -static void add_coin (int type, int data, char * text) { +*/ +static void add_coin (int type, int data, int size, char * text) { coin_enum [coin_code] = type; coin_data [coin_code] = data; + coin_size [coin_code] = size; string_copy (coin_text [coin_code], text); ++coin_code; } -*/ + int main (void) { char * buffer = null; int offset = 0; int length = 0; int select = 0; - int coin_ignore = syntax_define (false, false, "---", "\n", '\\', colour_pink, effect_normal); int coin_string = syntax_define (false, false, "\"", "\"", '\\', colour_red, effect_normal); int coin_type = syntax_define (false, true, "type", " \t\n", '\0', colour_yellow, effect_normal); int coin_loop = syntax_define (false, true, "loop", " \t\n(:", '\0', colour_yellow, effect_normal); @@ -70,14 +69,21 @@ int main (void) { for (offset = 0; buffer [offset] != '\0'; offset += length) { select = syntax_select (& buffer [offset], & length); - if (select >= syntax_count) { - terminal_colour (colour_grey, effect_normal); - } else { + if (select < syntax_count) { terminal_colour (syntax_colour [select], syntax_effect [select]); + add_coin (select, 0, length, & buffer [offset]); + } else { + terminal_colour (colour_red, effect_bold); + if (character_compare_array (buffer [offset], " \t\n") == false) { + printf ("ERROR!\n"); + exit (1); + } } out (& buffer [offset], length); terminal_cancel (); } +int i; + for (i = 0; i < coin_code; ++i) printf ("--- %2i : %2i = %.*s\n", coin_enum [i], coin_size [i], coin_size [i], coin_text [i]); /* for (offset = 0; buffer [offset] != '\0'; ++offset) { int size = 0;