Kaynağa Gözat

Experimental refactoring prototype finished...

master
ebeveyn
işleme
59b8891b89
2 değiştirilmiş dosya ile 33 ekleme ve 30 silme
  1. +2
    -1
      compile.sh
  2. +31
    -29
      xiranda.c

+ 2
- 1
compile.sh Dosyayı Görüntüle

@@ -2,6 +2,7 @@

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

+ 31
- 29
xiranda.c Dosyayı Görüntüle

@@ -30,21 +30,13 @@ static int constant_data [30] = { 0 };
#include <stdio.h>

#define STRING_LIMIT (40)
/*
static char * word_list [] = {
"type", "loop", "if", "else", "case", "return", "import", "system"
};

static char * register_list [] = {
"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) {
@@ -53,28 +45,40 @@ static void add_coin (int type, int data, char * text) {
string_copy (coin_text [coin_code], text);
++coin_code;
}
*/
int main (void) {
char * buffer = null;
int offset = 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);
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);
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, 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 (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) {
int size = 0;
char data [STRING_LIMIT] = "";
@@ -128,9 +132,8 @@ int main (void) {
printf ("%c -- %i\n", buffer [offset], (int) buffer [offset]);
exit (log_failure);
}
}
}

}*/
/*
for (length = 0; length < coin_code; ++length) {
switch (coin_enum [length]) {
case coin_string: printf ("\033[1;32m%s\033[0m ", coin_text [length]); break;
@@ -166,7 +169,6 @@ int main (void) {
length += 2;
} else if ((coin_enum [length] == coin_system) && (coin_data [length + 1] == '(')) {
int use = 0;
/*int fit = 0;*/
printf ("; system ({...});\n");
length += 2;
while (coin_data [length] != ')') {
@@ -191,7 +193,7 @@ int main (void) {
printf ("segment readable writable\n\n");
printf ("text db 'Heyo world!', 10, 0\n\n");
printf ("size dq 12\n\n");
*/
buffer = deallocate (buffer);

return (log_success);


Yükleniyor…
İptal
Kaydet