Implementing xyntax into the compiler...

This commit is contained in:
Ognjen Milan Robovic 2024-04-04 16:06:02 -04:00
parent 5d81beb8d2
commit 98d86a3b3b

View File

@ -1,9 +1,5 @@
#include <xolatile/xtandard.c> #include <xolatile/xtandard.c>
#include <xolatile/xyntax.c>
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_symbol
};
static int coin_code = 0; static int coin_code = 0;
static int type_code = 0;/* static int type_code = 0;/*
@ -22,11 +18,11 @@ static char function_name [9] [40] = { "" };
static int function_type [9] = { 0 }; static int function_type [9] = { 0 };
static char function_argument_name [9] [6] [40] = { { "" } }; static char function_argument_name [9] [6] [40] = { { "" } };
static int function_argument_type [9] [6] = { { 0 } }; static int function_argument_type [9] [6] = { { 0 } };
*/
static char variable_name [27] [40] = { "" }; static char variable_name [27] [40] = { "" };
static int variable_type [27] = { 0 }; static int variable_type [27] = { 0 };
static int variable_data [27] = { 0 }; static int variable_data [27] = { 0 };
/*
static char constant_name [30] [40] = { "" }; static char constant_name [30] [40] = { "" };
static int constant_type [30] = { 0 }; static int constant_type [30] = { 0 };
static int constant_data [30] = { 0 }; static int constant_data [30] = { 0 };
@ -63,6 +59,20 @@ int main (void) {
int offset = 0; int offset = 0;
int length = 0; int length = 0;
int coin_blabla = 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);
int coin_if = syntax_define (false, true, "if", " \t\n", '\0', colour_yellow, effect_normal);
int coin_else = syntax_define (false, true, "else", " \t\n", '\0', colour_yellow, effect_normal);
int coin_case = syntax_define (false, true, "case", " \t\n", '\0', colour_yellow, effect_normal);
int coin_return = syntax_define (false, true, "return", " \t\n", '\0', colour_yellow, effect_normal);
int coin_import = syntax_define (false, true, "import", " \t\n", '\0', colour_yellow, effect_normal);
int coin_system = syntax_define (false, true, "system", " \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, "abcdefghijklmnopqrstuvwxyz_", " \t\n,.;:()", '\0', colour_white, effect_normal);
int coin_symbol = syntax_define (true, true, ",.;:()+-*/%&|!", "", '\0', colour_cyan, effect_normal);
buffer = record (); buffer = record ();
for (offset = 0; buffer [offset] != '\0'; ++offset) { for (offset = 0; buffer [offset] != '\0'; ++offset) {
@ -96,14 +106,14 @@ int main (void) {
} }
add_coin (coin_marker, 0, data); add_coin (coin_marker, 0, data);
if (coin_enum [coin_code - 2] == coin_type) { if (coin_enum [coin_code - 2] == coin_type) {
coin_enum [coin_code - 1] = coin_data_type; coin_enum [coin_code - 1] = coin_data;
string_copy (type_name [type_code], coin_text [coin_code - 1]); string_copy (type_name [type_code], coin_text [coin_code - 1]);
type_size [type_code] = 8; type_size [type_code] = 8;
++type_code; ++type_code;
} }
for (length = 0; length < type_code; ++length) { for (length = 0; length < type_code; ++length) {
if (string_compare_limit (data, type_name [length], string_length (type_name [length]) + 1) == true) { if (string_compare_limit (data, type_name [length], string_length (type_name [length]) + 1) == true) {
coin_enum [coin_code - 1] = coin_data_type; coin_enum [coin_code - 1] = coin_data;
} }
} }
here: here:
@ -125,7 +135,7 @@ int main (void) {
switch (coin_enum [length]) { switch (coin_enum [length]) {
case coin_string: printf ("\033[1;32m%s\033[0m ", coin_text [length]); break; case coin_string: printf ("\033[1;32m%s\033[0m ", coin_text [length]); break;
case coin_number: printf ("\033[1;34m%s\033[0m ", coin_text [length]); break; case coin_number: printf ("\033[1;34m%s\033[0m ", coin_text [length]); break;
case coin_data_type: printf ("\033[1;36m%s\033[0m ", coin_text [length]); break; case coin_data: printf ("\033[1;36m%s\033[0m ", coin_text [length]); break;
case coin_marker: printf ("\033[1;37m%s\033[0m ", coin_text [length]); break; case coin_marker: printf ("\033[1;37m%s\033[0m ", coin_text [length]); break;
case coin_type: case coin_type:
case coin_if: case coin_if:
@ -172,7 +182,7 @@ int main (void) {
} }
length += 1; length += 1;
if (coin_data [length] != ';') if (coin_data [length] != ';')
echo ("EXPECTED STOP ';'\n"); echo ("EXPECTED STOP WORD ';'\n");
printf ("syscall\n\n"); printf ("syscall\n\n");
} }
} }