Update, removed export and define keywords...

This commit is contained in:
Ognjen Milan Robovic 2024-04-02 11:36:20 -04:00
parent 7a9e5f894c
commit f7754b4753
4 changed files with 33 additions and 35 deletions

View File

@ -2,7 +2,6 @@
set -xe
#~gcc -g -ansi -Wall -Wextra -Wpedantic -Werror -o xiranda xiranda.c
gcc -g -Wall -Wextra -Wpedantic -o xiranda xiranda.c
gcc -g -ansi -Wall -Wextra -Wpedantic -Werror -o xiranda xiranda.c
exit

3
test.x
View File

@ -33,9 +33,8 @@ main () > integer:
echo ("and again fizz");;
else if (x % 5 = 0)
echo ("buzz\n");
else:
else
echo ("fuck formatting...");
echo ("fuck formatting twice...");;
echo ("\n");;
return (0);;

View File

@ -11,6 +11,18 @@ format ELF64 executable 3
segment readable executable
macro begin {
push rdi
enter 0, 0
xor rax, rax
}
macro end {
leave
pop rdi
ret
}
main:
nop
nop
@ -20,7 +32,7 @@ main:
loop_1:
cmp [main_x], 16
jnb loop_1e
je loop_1e
xor rdx, rdx
mov eax, [main_x]
mov ebx, 15
@ -83,13 +95,8 @@ main:
;~return (length);;
string_length: ; string_length
nop
nop
nop
push rdi
enter 0, 0
begin
mov [string_length_length], 0
xor rax, rax
loop_0: ; loop_0
cmp byte [rdi], 0 ; (* (text + length)) != '\0'
je loop_0e
@ -97,20 +104,14 @@ string_length: ; string_
inc rdi ; length++
jmp loop_0 ; if not go loop_0
loop_0e:
leave
mov eax, [string_length_length]
pop rdi
ret ; ;
end
;~echo (character * text):
;~system (linux_write_system_call, standard_output, text, string_length (text));
;~return;;
echo: ; echo )
nop
nop
nop
push rdi
enter 0, 0
echo:
begin
call string_length ; |
mov rdx, rax ; | string_length (text)
mov rsi, rdi ; text
@ -118,13 +119,8 @@ echo: ; echo )
mov rax, linux_write_system_call ; linux_write_system_call
syscall ; system (
xor rax, rax ; return;;
leave
pop rdi
ret ;
end
nop
nop
nop
segment readable writable
; variable

View File

@ -7,7 +7,7 @@ enum {
enum {
word_type, word_loop, word_if, word_else, word_case,
word_return, word_import, word_export, word_define, word_system
word_return, word_import, word_system
};
#define STRING_LIMIT (80)
@ -31,12 +31,16 @@ static char * * marker_name = null;
static char * * type_name = null;
static int * marker_type = null;
static char * symbol_data = null;
/*
static int * function_name = null;
static int * function_type = null;
static int * * function_argument_name = null;
static int * * function_argument_type = null;
*/
#include <stdio.h>
static char * word_list [] = {
"type", "loop", "if", "else", "case", "return",
"import", "export", "define", "system"
"type", "loop", "if", "else", "case", "return", "import", "system"
};
static void add_token (int type, int data) {
@ -128,7 +132,7 @@ int main (void) {
name [size++] = buffer [offset];
}
name [size] = '\0';
for (length = 0; length < 10; ++length) {
for (length = 0; length < (int) (sizeof (word_list) / sizeof (word_list [0])); ++length) {
if (string_compare_limit (name, word_list [length], string_length (word_list [length]) + 1) == true) {
add_token (core_word, length);
goto here;
@ -136,12 +140,12 @@ int main (void) {
}
add_token (core_marker, marker_code);
add_marker (name, token_type [token_count - 1]);
if ((token_type [token_count - 2] == core_word) && (token_data [token_count - 2] == word_type)) { // NEW TYPE
if ((token_type [token_count - 2] == core_word) && (token_data [token_count - 2] == word_type)) {
token_type [token_count - 1] = core_type;
add_type (name);
}
for (length = 0; length < type_code; ++length) {
if (string_compare_limit (name, type_name [length], string_length (type_name [length]) + 1) == true) { // EXISTING TYPE
if (string_compare_limit (name, type_name [length], string_length (type_name [length]) + 1) == true) {
token_type [token_count - 1] = core_type;
}
}
@ -180,7 +184,7 @@ int main (void) {
echo ("return (\n");
++length;
} else if ((token_type [length] == core_symbol) && (symbol_data [token_data [length]] == ';')) {
echo ("return ; -- 48 33 C0 3C -- xor rax rax ret\n");
echo ("; return;\nxor rax, rax\nret\n");
++length;
} else {
kill ("return ?\n");
@ -202,7 +206,7 @@ int main (void) {
echo ("else if\n");
++length;
} else {
kill ("else ?\n");
echo ("expression\n");
}
} else if ((token_type [length] == core_word) && (token_data [length] == word_type)) {
++length;