Experimental refactoring prototype finished...
This commit is contained in:
parent
98d86a3b3b
commit
59b8891b89
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
set -xe
|
set -xe
|
||||||
|
|
||||||
gcc -g -ansi -Wall -Wextra -Wpedantic -Werror -o xiranda xiranda.c
|
#~gcc -g -ansi -Wall -Wextra -Wpedantic -Werror -o xiranda xiranda.c
|
||||||
|
gcc -g -ansi -Wall -Wextra -Wpedantic -o xiranda xiranda.c
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
40
xiranda.c
40
xiranda.c
@ -30,21 +30,13 @@ static int constant_data [30] = { 0 };
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define STRING_LIMIT (40)
|
#define STRING_LIMIT (40)
|
||||||
|
/*
|
||||||
static char * word_list [] = {
|
static char * word_list [] = {
|
||||||
"type", "loop", "if", "else", "case", "return", "import", "system"
|
"type", "loop", "if", "else", "case", "return", "import", "system"
|
||||||
};
|
};
|
||||||
|
|
||||||
static char * register_list [] = {
|
static char * register_list [] = {
|
||||||
"rax","rdi","rsi","rdx","r10","r8","r9"
|
"rax","rdi","rsi","rdx","r10","r8","r9"
|
||||||
/*"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
|
|
||||||
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
|
|
||||||
"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
|
|
||||||
"r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d",
|
|
||||||
"ax", "cx", "dx", "bx", "sp", "bp", "si", "di",
|
|
||||||
"r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w",
|
|
||||||
"al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil",
|
|
||||||
"r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b"*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void add_coin (int type, int data, char * text) {
|
static void add_coin (int type, int data, char * text) {
|
||||||
@ -53,13 +45,14 @@ static void add_coin (int type, int data, char * text) {
|
|||||||
string_copy (coin_text [coin_code], text);
|
string_copy (coin_text [coin_code], text);
|
||||||
++coin_code;
|
++coin_code;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
int main (void) {
|
int main (void) {
|
||||||
char * buffer = null;
|
char * buffer = null;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
int select = 0;
|
||||||
|
|
||||||
int coin_blabla = syntax_define (false, false, "---", "\n", '\\', colour_pink, effect_normal);
|
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_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_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_loop = syntax_define (false, true, "loop", " \t\n", '\0', colour_yellow, effect_normal);
|
||||||
@ -69,12 +62,23 @@ int main (void) {
|
|||||||
int coin_return = syntax_define (false, true, "return", " \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_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_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_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_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);
|
int coin_symbol = syntax_define (true, false, ",.;:=#[]()+-*/%&|!", "", '\0', colour_cyan, effect_normal);
|
||||||
|
|
||||||
buffer = record ();
|
buffer = record ();
|
||||||
|
|
||||||
|
for (offset = 0; buffer [offset] != '\0'; offset += length) {
|
||||||
|
select = syntax_select (& buffer [offset], & length);
|
||||||
|
if (select >= syntax_count) {
|
||||||
|
terminal_colour (colour_red, effect_reverse);
|
||||||
|
} else {
|
||||||
|
terminal_colour (syntax_colour [select], syntax_effect [select]);
|
||||||
|
}
|
||||||
|
out (& buffer [offset], length);
|
||||||
|
terminal_cancel ();
|
||||||
|
}
|
||||||
|
/*
|
||||||
for (offset = 0; buffer [offset] != '\0'; ++offset) {
|
for (offset = 0; buffer [offset] != '\0'; ++offset) {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
char data [STRING_LIMIT] = "";
|
char data [STRING_LIMIT] = "";
|
||||||
@ -128,9 +132,8 @@ int main (void) {
|
|||||||
printf ("%c -- %i\n", buffer [offset], (int) buffer [offset]);
|
printf ("%c -- %i\n", buffer [offset], (int) buffer [offset]);
|
||||||
exit (log_failure);
|
exit (log_failure);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
/*
|
||||||
|
|
||||||
for (length = 0; length < coin_code; ++length) {
|
for (length = 0; length < coin_code; ++length) {
|
||||||
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;
|
||||||
@ -166,7 +169,6 @@ int main (void) {
|
|||||||
length += 2;
|
length += 2;
|
||||||
} else if ((coin_enum [length] == coin_system) && (coin_data [length + 1] == '(')) {
|
} else if ((coin_enum [length] == coin_system) && (coin_data [length + 1] == '(')) {
|
||||||
int use = 0;
|
int use = 0;
|
||||||
/*int fit = 0;*/
|
|
||||||
printf ("; system ({...});\n");
|
printf ("; system ({...});\n");
|
||||||
length += 2;
|
length += 2;
|
||||||
while (coin_data [length] != ')') {
|
while (coin_data [length] != ')') {
|
||||||
@ -191,7 +193,7 @@ int main (void) {
|
|||||||
printf ("segment readable writable\n\n");
|
printf ("segment readable writable\n\n");
|
||||||
printf ("text db 'Heyo world!', 10, 0\n\n");
|
printf ("text db 'Heyo world!', 10, 0\n\n");
|
||||||
printf ("size dq 12\n\n");
|
printf ("size dq 12\n\n");
|
||||||
|
*/
|
||||||
buffer = deallocate (buffer);
|
buffer = deallocate (buffer);
|
||||||
|
|
||||||
return (log_success);
|
return (log_success);
|
||||||
|
Loading…
Reference in New Issue
Block a user