瀏覽代碼

Work in progress push...

master
父節點
當前提交
40917b92c1
共有 3 個文件被更改,包括 62 次插入11 次删除
  1. +12
    -1
      heyo.x
  2. +4
    -4
      test.asm
  3. +46
    -6
      xiranda.c

+ 12
- 1
heyo.x 查看文件

@@ -1,9 +1,20 @@
одреди слово = 1;
одреди број = 4;

одреди системски_позив (
читај = 0,
пиши = 1,
отвори = 2,
затвори = 3,
изађи = 60)

одреди описивач (
улаз,
излаз)

текст: слово = "Здраво свете!";
дужина: број = 12;

главна_процедура ():
изврши (1, 1, #текст, дужина);
изврши (пиши, излаз, #текст, дужина);
врати;;

+ 4
- 4
test.asm 查看文件

@@ -16,9 +16,9 @@ _start:
mov [echo_0], text_data ; text);
call echo ; echo (

loop_1:
лоопаа:
cmp [main_x], 51
jnb loop_1e
jnb лоопааe
xor rdx, rdx
mov eax, [main_x]
mov ebx, 15
@@ -53,8 +53,8 @@ _start:
call echo
n0:
inc [main_x]
jmp loop_1
loop_1e:
jmp лоопаа
лоопааe:
;
mov rax, linux_exit_system_call ; <main> return;;
xor rdi, rdi


+ 46
- 6
xiranda.c 查看文件

@@ -3,8 +3,8 @@

static int coin_code = 0;
static int type_code = 0;
static int variable_code = 0;/*
static int constant_code = 0;
static int variable_code = 0;
static int constant_code = 0;/*
static int function_code = 0;*/

static int coin_data [240] = { 0 };
@@ -17,11 +17,11 @@ 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] = { { "" } };
@@ -68,7 +68,7 @@ int main (void) {
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_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 ();
@@ -103,7 +103,34 @@ int main (void) {
++type_code;
} else kill ("Expected semicolon symbol: ", offset);
} else kill ("Expected number: ", offset);
} else kill ("Expected equal symbol: ", 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_symbol) && (* coin_text [offset] == ')')) {
++offset;
break;
} else 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;
} 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;
} else kill ("Expected number:", offset);
} else kill ("Expected = or ,:", offset);
} else kill ("Expected either marker or close symbol: ", 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;
@@ -128,18 +155,30 @@ int main (void) {
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 %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_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);
@@ -151,6 +190,7 @@ int main (void) {

/**/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]);

buffer = deallocate (buffer);



Loading…
取消
儲存