diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c1389b4..f260c49 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,11 +7,8 @@
-
+
-
-
-
@@ -289,15 +286,7 @@
-
-
-
-
- 1718895358320
-
-
-
- 1718895358320
+
@@ -683,7 +672,15 @@
1723213598029
-
+
+
+ 1723305700296
+
+
+
+ 1723305700297
+
+
@@ -740,7 +737,6 @@
-
@@ -765,7 +761,8 @@
-
+
+
diff --git a/build/out.asm b/build/out.asm
index a0801fe..eaee14f 100644
--- a/build/out.asm
+++ b/build/out.asm
@@ -2,6 +2,230 @@
section .text
+_12:
+ push rbp
+ mov rbp, rsp
+ mov rax, [rbp+16]
+ add rax, 0x0000000000000000
+ mov qword [rbp-8], rax
+ mov rdx, qword [rbp-8]
+ mov rax, qword [rdx+0]
+ mov qword [rbp-16], rax
+ mov rax, qword [rbp+24]
+ mov qword [rbp-24], rax
+ mov rax, qword [rbp-24]
+ mov qword [rbp-48], rax
+ mov rax, qword [rbp-16]
+ mov qword [rbp-56], rax
+ sub rsp, 0x0000000000000038
+ call _17
+ add rsp, 0x0000000000000038
+ mov rax, qword [rbp-40]
+ mov qword [rbp+32], rax
+ leave
+ ret
+
+
+_19:
+ push rbp
+ mov rbp, rsp
+ mov rax, [rbp+16]
+ add rax, 0x0000000000000000
+ mov qword [rbp-16], rax
+ mov rdx, qword [rbp-16]
+ mov rax, qword [rdx+0]
+ mov qword [rbp-8], rax
+ mov rdi, __8_fstr
+ mov rsi, [rbp-8]
+ mov al, 0
+ sub rsp, 16
+ extern printf
+ call printf
+ add rsp, 16
+ mov rax, [rbp+16]
+ add rax, 0x0000000000000008
+ mov qword [rbp-34], rax
+ mov rdx, qword [rbp-34]
+ mov rax, qword [rdx+0]
+ mov qword [rbp-26], rax
+ mov rax, qword [rbp-26]
+ cmp rax, 0
+ jz __36_18
+ mov byte [rbp-18], 0
+ jmp __36_19
+ __36_18:
+ mov byte [rbp-18], 1
+ __36_19:
+ mov al, byte [rbp-18]
+ cmp al, 0
+ jz __23_20
+ mov byte [rbp-17], 0
+ jmp __23_21
+ __23_20:
+ mov byte [rbp-17], 1
+ __23_21:
+ cmp byte [rbp-17], 0
+ jz _19_22
+ mov rax, [rbp+16]
+ add rax, 0x0000000000000008
+ mov qword [rbp-42], rax
+ mov rdx, qword [rbp-42]
+ mov rax, qword [rdx+0]
+ mov qword [rbp-50], rax
+ mov rax, qword [rbp-50]
+ mov qword [rbp-58], rax
+ sub rsp, 0x000000000000003a
+ call _19
+ add rsp, 0x000000000000003a
+ _19_23:
+ _19_22:
+
+leave
+ret
+
+_10:
+ push rbp
+ mov rbp, rsp
+ mov qword [rbp+16], 0
+ leave
+ ret
+
+
+_13:
+ push rbp
+ mov rbp, rsp
+ mov rax, [rbp+16]
+ add rax, 0x0000000000000000
+ mov qword [rbp-17], rax
+ mov rdx, qword [rbp-17]
+ mov rax, qword [rdx+0]
+ mov qword [rbp-25], rax
+ mov rax, [rbp-25]
+ add rax, 0x0000000000000008
+ mov qword [rbp-33], rax
+ mov rdx, qword [rbp-33]
+ mov rax, qword [rdx+0]
+ mov qword [rbp-9], rax
+ mov rax, qword [rbp-9]
+ cmp rax, 0
+ jz __36_6
+ mov byte [rbp-1], 0
+ jmp __36_7
+ __36_6:
+ mov byte [rbp-1], 1
+ __36_7:
+ cmp byte [rbp-1], 0
+ jz _13_8
+ mov rax, [rbp+16]
+ add rax, 0x0000000000000000
+ mov qword [rbp-49], rax
+ mov rdx, qword [rbp-49]
+ mov rax, qword [rdx+0]
+ mov qword [rbp-57], rax
+ mov rax, [rbp-57]
+ add rax, 0x0000000000000000
+ mov qword [rbp-65], rax
+ mov rdx, qword [rbp-65]
+ mov rax, qword [rdx+0]
+ mov qword [rbp-41], rax
+ mov rax, [rbp+16]
+ add rax, 0x0000000000000000
+ mov qword [rbp-81], rax
+ mov rdx, qword [rbp-81]
+ mov rax, qword [rdx+0]
+ mov qword [rbp-73], rax
+ mov rdi, qword [rbp-73]
+ sub rsp, 81
+ extern free
+ call free
+ add rsp, 81
+ mov rax, [rbp+16]
+ add rax, 0x0000000000000000
+ mov qword [rbp-89], rax
+ mov qword [rbp-97], 0
+ mov rdx, qword [rbp-89]
+ mov rax, qword [rbp-97]
+ mov qword [rdx+0], rax
+ mov rax, qword [rbp-41]
+ mov qword [rbp+24], rax
+ leave
+ ret
+ _13_9:
+ _13_8:
+ mov rax, [rbp+16]
+ add rax, 0x0000000000000000
+ mov qword [rbp-41], rax
+ mov rdx, qword [rbp-41]
+ mov rax, qword [rdx+0]
+ mov qword [rbp-49], rax
+ mov rax, qword [rbp-49]
+ mov qword [rbp-65], rax
+ sub rsp, 0x0000000000000041
+ call _18
+ add rsp, 0x0000000000000041
+ mov rax, qword [rbp-57]
+ mov qword [rbp+24], rax
+ leave
+ ret
+
+
+_11:
+ push rbp
+ mov rbp, rsp
+ mov rax, [rbp+16]
+ add rax, 0x0000000000000000
+ mov qword [rbp-17], rax
+ mov rdx, qword [rbp-17]
+ mov rax, qword [rdx+0]
+ mov qword [rbp-9], rax
+ mov rax, qword [rbp-9]
+ cmp rax, 0
+ jz __36_24
+ mov byte [rbp-1], 0
+ jmp __36_25
+ __36_24:
+ mov byte [rbp-1], 1
+ __36_25:
+ cmp byte [rbp-1], 0
+ jz _11_27
+ mov rax, [rbp+16]
+ add rax, 0x0000000000000000
+ mov qword [rbp-25], rax
+ mov rax, qword [rbp+24]
+ mov qword [rbp-41], rax
+ mov rax, qword [rbp-41]
+ mov qword [rbp-57], rax
+ sub rsp, 0x0000000000000039
+ call _15
+ add rsp, 0x0000000000000039
+ mov rax, qword [rbp-49]
+ mov qword [rbp-33], rax
+ mov rdx, qword [rbp-25]
+ mov rax, qword [rbp-33]
+ mov qword [rdx+0], rax
+ jmp _11_26
+ _11_27:
+ mov rax, [rbp+16]
+ add rax, 0x0000000000000000
+ mov qword [rbp-25], rax
+ mov rdx, qword [rbp-25]
+ mov rax, qword [rdx+0]
+ mov qword [rbp-33], rax
+ mov rax, qword [rbp+24]
+ mov qword [rbp-41], rax
+ mov rax, qword [rbp-41]
+ mov qword [rbp-65], rax
+ mov rax, qword [rbp-33]
+ mov qword [rbp-73], rax
+ sub rsp, 0x0000000000000049
+ call _16
+ add rsp, 0x0000000000000049
+ _11_28:
+ _11_26:
+
+leave
+ret
+
main:
push rbp
mov rbp, rsp
@@ -120,35 +344,71 @@ main:
ret
-_10:
+_14:
push rbp
mov rbp, rsp
- mov qword [rbp+16], 0
- leave
- ret
+ mov rax, [rbp+16]
+ add rax, 0x0000000000000000
+ mov qword [rbp-18], rax
+ mov rdx, qword [rbp-18]
+ mov rax, qword [rdx+0]
+ mov qword [rbp-10], rax
+ mov rax, qword [rbp-10]
+ cmp rax, 0
+ jz __36_0
+ mov byte [rbp-2], 0
+ jmp __36_1
+ __36_0:
+ mov byte [rbp-2], 1
+ __36_1:
+ mov al, byte [rbp-2]
+ cmp al, 0
+ jz __23_2
+ mov byte [rbp-1], 0
+ jmp __23_3
+ __23_2:
+ mov byte [rbp-1], 1
+ __23_3:
+ cmp byte [rbp-1], 0
+ jz _14_4
+ mov rax, [rbp+16]
+ add rax, 0x0000000000000000
+ mov qword [rbp-26], rax
+ mov rdx, qword [rbp-26]
+ mov rax, qword [rdx+0]
+ mov qword [rbp-34], rax
+ mov rax, qword [rbp-34]
+ mov qword [rbp-42], rax
+ sub rsp, 0x000000000000002a
+ call _19
+ add rsp, 0x000000000000002a
+ _14_5:
+ _14_4:
+leave
+ret
-_11:
+_16:
push rbp
mov rbp, rsp
mov rax, [rbp+16]
- add rax, 0x0000000000000000
+ add rax, 0x0000000000000008
mov qword [rbp-17], rax
mov rdx, qword [rbp-17]
mov rax, qword [rdx+0]
mov qword [rbp-9], rax
mov rax, qword [rbp-9]
cmp rax, 0
- jz __36_16
+ jz __36_29
mov byte [rbp-1], 0
- jmp __36_17
- __36_16:
+ jmp __36_30
+ __36_29:
mov byte [rbp-1], 1
- __36_17:
+ __36_30:
cmp byte [rbp-1], 0
- jz _11_19
+ jz _16_32
mov rax, [rbp+16]
- add rax, 0x0000000000000000
+ add rax, 0x0000000000000008
mov qword [rbp-25], rax
mov rax, qword [rbp+24]
mov qword [rbp-41], rax
@@ -162,10 +422,10 @@ _11:
mov rdx, qword [rbp-25]
mov rax, qword [rbp-33]
mov qword [rdx+0], rax
- jmp _11_18
- _11_19:
+ jmp _16_31
+ _16_32:
mov rax, [rbp+16]
- add rax, 0x0000000000000000
+ add rax, 0x0000000000000008
mov qword [rbp-25], rax
mov rdx, qword [rbp-25]
mov rax, qword [rdx+0]
@@ -179,41 +439,17 @@ _11:
sub rsp, 0x0000000000000049
call _16
add rsp, 0x0000000000000049
- _11_20:
- _11_18:
+ _16_33:
+ _16_31:
leave
ret
-_12:
- push rbp
- mov rbp, rsp
- mov rax, [rbp+16]
- add rax, 0x0000000000000000
- mov qword [rbp-8], rax
- mov rdx, qword [rbp-8]
- mov rax, qword [rdx+0]
- mov qword [rbp-16], rax
- mov rax, qword [rbp+24]
- mov qword [rbp-24], rax
- mov rax, qword [rbp-24]
- mov qword [rbp-48], rax
- mov rax, qword [rbp-16]
- mov qword [rbp-56], rax
- sub rsp, 0x0000000000000038
- call _17
- add rsp, 0x0000000000000038
- mov rax, qword [rbp-40]
- mov qword [rbp+32], rax
- leave
- ret
-
-
-_13:
+_18:
push rbp
mov rbp, rsp
mov rax, [rbp+16]
- add rax, 0x0000000000000000
+ add rax, 0x0000000000000008
mov qword [rbp-17], rax
mov rdx, qword [rbp-17]
mov rax, qword [rdx+0]
@@ -226,16 +462,16 @@ _13:
mov qword [rbp-9], rax
mov rax, qword [rbp-9]
cmp rax, 0
- jz __36_26
+ jz __36_10
mov byte [rbp-1], 0
- jmp __36_27
- __36_26:
+ jmp __36_11
+ __36_10:
mov byte [rbp-1], 1
- __36_27:
+ __36_11:
cmp byte [rbp-1], 0
- jz _13_28
+ jz _18_12
mov rax, [rbp+16]
- add rax, 0x0000000000000000
+ add rax, 0x0000000000000008
mov qword [rbp-49], rax
mov rdx, qword [rbp-49]
mov rax, qword [rdx+0]
@@ -247,7 +483,7 @@ _13:
mov rax, qword [rdx+0]
mov qword [rbp-41], rax
mov rax, [rbp+16]
- add rax, 0x0000000000000000
+ add rax, 0x0000000000000008
mov qword [rbp-81], rax
mov rdx, qword [rbp-81]
mov rax, qword [rdx+0]
@@ -258,7 +494,7 @@ _13:
call free
add rsp, 81
mov rax, [rbp+16]
- add rax, 0x0000000000000000
+ add rax, 0x0000000000000008
mov qword [rbp-89], rax
mov qword [rbp-97], 0
mov rdx, qword [rbp-89]
@@ -268,10 +504,10 @@ _13:
mov qword [rbp+24], rax
leave
ret
- _13_29:
- _13_28:
+ _18_13:
+ _18_12:
mov rax, [rbp+16]
- add rax, 0x0000000000000000
+ add rax, 0x0000000000000008
mov qword [rbp-41], rax
mov rdx, qword [rbp-41]
mov rax, qword [rdx+0]
@@ -287,130 +523,6 @@ _13:
ret
-_14:
- push rbp
- mov rbp, rsp
- mov rax, [rbp+16]
- add rax, 0x0000000000000000
- mov qword [rbp-18], rax
- mov rdx, qword [rbp-18]
- mov rax, qword [rdx+0]
- mov qword [rbp-10], rax
- mov rax, qword [rbp-10]
- cmp rax, 0
- jz __36_4
- mov byte [rbp-2], 0
- jmp __36_5
- __36_4:
- mov byte [rbp-2], 1
- __36_5:
- mov al, byte [rbp-2]
- cmp al, 0
- jz __23_6
- mov byte [rbp-1], 0
- jmp __23_7
- __23_6:
- mov byte [rbp-1], 1
- __23_7:
- cmp byte [rbp-1], 0
- jz _14_8
- mov rax, [rbp+16]
- add rax, 0x0000000000000000
- mov qword [rbp-26], rax
- mov rdx, qword [rbp-26]
- mov rax, qword [rdx+0]
- mov qword [rbp-34], rax
- mov rax, qword [rbp-34]
- mov qword [rbp-42], rax
- sub rsp, 0x000000000000002a
- call _19
- add rsp, 0x000000000000002a
- _14_9:
- _14_8:
-
-leave
-ret
-
-_15:
- push rbp
- mov rbp, rsp
- mov rax, qword [rbp+16]
- mov qword [rbp-16], rax
- mov qword [rbp-8], 0
- mov rdi, 16
- sub rsp, 16
- extern malloc
- call malloc
- add rsp, 16
- mov qword [rbp-24], rax
- mov rdx, qword [rbp-24]
- mov rax, qword [rbp-16]
- mov qword [rdx+0], rax
- mov rax, qword [rbp-8]
- mov qword [rdx+8], rax
- mov rax, qword [rbp-24]
- mov qword [rbp+24], rax
- leave
- ret
-
-
-_16:
- push rbp
- mov rbp, rsp
- mov rax, [rbp+16]
- add rax, 0x0000000000000008
- mov qword [rbp-17], rax
- mov rdx, qword [rbp-17]
- mov rax, qword [rdx+0]
- mov qword [rbp-9], rax
- mov rax, qword [rbp-9]
- cmp rax, 0
- jz __36_21
- mov byte [rbp-1], 0
- jmp __36_22
- __36_21:
- mov byte [rbp-1], 1
- __36_22:
- cmp byte [rbp-1], 0
- jz _16_24
- mov rax, [rbp+16]
- add rax, 0x0000000000000008
- mov qword [rbp-25], rax
- mov rax, qword [rbp+24]
- mov qword [rbp-41], rax
- mov rax, qword [rbp-41]
- mov qword [rbp-57], rax
- sub rsp, 0x0000000000000039
- call _15
- add rsp, 0x0000000000000039
- mov rax, qword [rbp-49]
- mov qword [rbp-33], rax
- mov rdx, qword [rbp-25]
- mov rax, qword [rbp-33]
- mov qword [rdx+0], rax
- jmp _16_23
- _16_24:
- mov rax, [rbp+16]
- add rax, 0x0000000000000008
- mov qword [rbp-25], rax
- mov rdx, qword [rbp-25]
- mov rax, qword [rdx+0]
- mov qword [rbp-33], rax
- mov rax, qword [rbp+24]
- mov qword [rbp-41], rax
- mov rax, qword [rbp-41]
- mov qword [rbp-65], rax
- mov rax, qword [rbp-33]
- mov qword [rbp-73], rax
- sub rsp, 0x0000000000000049
- call _16
- add rsp, 0x0000000000000049
- _16_25:
- _16_23:
-
-leave
-ret
-
_17:
push rbp
mov rbp, rsp
@@ -419,14 +531,14 @@ _17:
mov qword [rbp-17], 0
mov rax, qword [rbp-9]
cmp rax, qword [rbp-17]
- jz __16_0
+ jz __16_14
mov byte [rbp-1], 0
- jmp __16_1
- __16_0:
+ jmp __16_15
+ __16_14:
mov byte [rbp-1], 1
- __16_1:
+ __16_15:
cmp byte [rbp-1], 0
- jz _17_2
+ jz _17_16
mov rax, [rbp+16]
add rax, 0x0000000000000000
mov qword [rbp-25], rax
@@ -435,8 +547,8 @@ _17:
mov qword [rbp+32], rax
leave
ret
- _17_3:
- _17_2:
+ _17_17:
+ _17_16:
mov rax, [rbp+16]
add rax, 0x0000000000000008
mov qword [rbp-25], rax
@@ -462,141 +574,29 @@ _17:
ret
-_18:
+_15:
push rbp
mov rbp, rsp
- mov rax, [rbp+16]
- add rax, 0x0000000000000008
- mov qword [rbp-17], rax
- mov rdx, qword [rbp-17]
- mov rax, qword [rdx+0]
- mov qword [rbp-25], rax
- mov rax, [rbp-25]
- add rax, 0x0000000000000008
- mov qword [rbp-33], rax
- mov rdx, qword [rbp-33]
- mov rax, qword [rdx+0]
- mov qword [rbp-9], rax
- mov rax, qword [rbp-9]
- cmp rax, 0
- jz __36_30
- mov byte [rbp-1], 0
- jmp __36_31
- __36_30:
- mov byte [rbp-1], 1
- __36_31:
- cmp byte [rbp-1], 0
- jz _18_32
- mov rax, [rbp+16]
- add rax, 0x0000000000000008
- mov qword [rbp-49], rax
- mov rdx, qword [rbp-49]
- mov rax, qword [rdx+0]
- mov qword [rbp-57], rax
- mov rax, [rbp-57]
- add rax, 0x0000000000000000
- mov qword [rbp-65], rax
- mov rdx, qword [rbp-65]
- mov rax, qword [rdx+0]
- mov qword [rbp-41], rax
- mov rax, [rbp+16]
- add rax, 0x0000000000000008
- mov qword [rbp-81], rax
- mov rdx, qword [rbp-81]
- mov rax, qword [rdx+0]
- mov qword [rbp-73], rax
- mov rdi, qword [rbp-73]
- sub rsp, 81
- extern free
- call free
- add rsp, 81
- mov rax, [rbp+16]
- add rax, 0x0000000000000008
- mov qword [rbp-89], rax
- mov qword [rbp-97], 0
- mov rdx, qword [rbp-89]
- mov rax, qword [rbp-97]
+ mov rax, qword [rbp+16]
+ mov qword [rbp-16], rax
+ mov qword [rbp-8], 0
+ mov rdi, 16
+ sub rsp, 16
+ extern malloc
+ call malloc
+ add rsp, 16
+ mov qword [rbp-24], rax
+ mov rdx, qword [rbp-24]
+ mov rax, qword [rbp-16]
mov qword [rdx+0], rax
- mov rax, qword [rbp-41]
- mov qword [rbp+24], rax
- leave
- ret
- _18_33:
- _18_32:
- mov rax, [rbp+16]
- add rax, 0x0000000000000008
- mov qword [rbp-41], rax
- mov rdx, qword [rbp-41]
- mov rax, qword [rdx+0]
- mov qword [rbp-49], rax
- mov rax, qword [rbp-49]
- mov qword [rbp-65], rax
- sub rsp, 0x0000000000000041
- call _18
- add rsp, 0x0000000000000041
- mov rax, qword [rbp-57]
+ mov rax, qword [rbp-8]
+ mov qword [rdx+8], rax
+ mov rax, qword [rbp-24]
mov qword [rbp+24], rax
leave
ret
-_19:
- push rbp
- mov rbp, rsp
- mov rax, [rbp+16]
- add rax, 0x0000000000000000
- mov qword [rbp-16], rax
- mov rdx, qword [rbp-16]
- mov rax, qword [rdx+0]
- mov qword [rbp-8], rax
- mov rdi, __8_fstr
- mov rsi, [rbp-8]
- mov al, 0
- sub rsp, 16
- extern printf
- call printf
- add rsp, 16
- mov rax, [rbp+16]
- add rax, 0x0000000000000008
- mov qword [rbp-34], rax
- mov rdx, qword [rbp-34]
- mov rax, qword [rdx+0]
- mov qword [rbp-26], rax
- mov rax, qword [rbp-26]
- cmp rax, 0
- jz __36_10
- mov byte [rbp-18], 0
- jmp __36_11
- __36_10:
- mov byte [rbp-18], 1
- __36_11:
- mov al, byte [rbp-18]
- cmp al, 0
- jz __23_12
- mov byte [rbp-17], 0
- jmp __23_13
- __23_12:
- mov byte [rbp-17], 1
- __23_13:
- cmp byte [rbp-17], 0
- jz _19_14
- mov rax, [rbp+16]
- add rax, 0x0000000000000008
- mov qword [rbp-42], rax
- mov rdx, qword [rbp-42]
- mov rax, qword [rdx+0]
- mov qword [rbp-50], rax
- mov rax, qword [rbp-50]
- mov qword [rbp-58], rax
- sub rsp, 0x000000000000003a
- call _19
- add rsp, 0x000000000000003a
- _19_15:
- _19_14:
-
-leave
-ret
-
section .data_readonly
__42_fstr db `\n`,0
__8_fstr db `Integer: %ld\n`,0
\ No newline at end of file
diff --git a/build/out.o b/build/out.o
index 0325874..713f979 100644
Binary files a/build/out.o and b/build/out.o differ
diff --git a/build/out.out b/build/out.out
index c517ce4..26b5516 100755
Binary files a/build/out.out and b/build/out.out differ
diff --git a/src/root/compiler/compile.rs b/src/root/compiler/compile.rs
index 6f143cb..dc5d006 100644
--- a/src/root/compiler/compile.rs
+++ b/src/root/compiler/compile.rs
@@ -37,7 +37,7 @@ pub fn compile(
let current_function = *open_set.iter().next().unwrap();
open_set.remove(¤t_function);
-
+
compiled_count += 1;
let Some(current_function_token) = unprocessed_functions.remove(¤t_function) else {
diff --git a/src/root/name_resolver/resolve.rs b/src/root/name_resolver/resolve.rs
index 20b8c7c..95b60c9 100644
--- a/src/root/name_resolver/resolve.rs
+++ b/src/root/name_resolver/resolve.rs
@@ -14,6 +14,7 @@ pub fn resolve(
ast: Vec,
) -> Result<(GlobalDefinitionTable, HashMap), WErr> {
let mut global_table = GlobalDefinitionTable::new();
+
register_builtin(&mut global_table);
let unprocessed_functions = resolve_names(ast, &mut global_table)?;
diff --git a/src/root/parser/parse.rs b/src/root/parser/parse.rs
index 9a95fb1..eb61ed4 100644
--- a/src/root/parser/parse.rs
+++ b/src/root/parser/parse.rs
@@ -35,7 +35,8 @@ pub fn parse(path_storage: &mut PathStorage) -> Result, WErr
let base = Span::new_extra(&text, file_id);
- let (after_use, new_files) = handle_error(parse_imports(base, path_storage, file_id), path_storage)?;
+ let (after_use, new_files) =
+ handle_error(parse_imports(base, path_storage, file_id), path_storage)?;
path_queue.extend(new_files);
let res = parse_toplevel::parse_toplevel(after_use);
diff --git a/src/root/parser/parse_imports.rs b/src/root/parser/parse_imports.rs
index 26a3078..897a5b6 100644
--- a/src/root/parser/parse_imports.rs
+++ b/src/root/parser/parse_imports.rs
@@ -44,7 +44,7 @@ pub fn parse_imports<'a>(
}
let (_, ids) = path_storage.get_id_and_add_to_file(current_file, is_use, path)?;
-
+
for id in ids {
found_paths.push((id, Location::from_span(&path)));
}
diff --git a/src/root/parser/path_storage.rs b/src/root/parser/path_storage.rs
index 0c69666..ddd5604 100644
--- a/src/root/parser/path_storage.rs
+++ b/src/root/parser/path_storage.rs
@@ -1,11 +1,11 @@
-use std::collections::HashMap;
-use std::fs;
use crate::root::errors::parser_errors::create_custom_error;
use crate::root::errors::WErr;
use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
use crate::root::utils::identify_first_last::IdentifyLast;
use nom::character::complete::anychar;
use nom::InputTake;
+use std::collections::HashMap;
+use std::fs;
#[derive(Hash, Copy, Clone, Debug, Eq, PartialEq)]
pub struct FileID(usize);
@@ -52,7 +52,9 @@ pub struct PathStorage {
impl PathStorage {
pub fn new(main: &str) -> Result {
// TODO: Only allow certain characters in base
- if !main.ends_with(".why") { todo!() }
+ if !main.ends_with(".why") {
+ todo!()
+ }
let main = &main[..main.len() - ".why".len()];
let mut folders = vec![CodeFolder::root()];
@@ -195,24 +197,38 @@ impl PathStorage {
if is_folder {
let folder = self.add_folder(section, current);
if !is_use {
- self.get_file_mut(current_file).imported_folders.push(folder);
+ self.get_file_mut(current_file)
+ .imported_folders
+ .push(folder);
}
let folder_path = self.reconstruct_folder(folder);
let mut new_files = Vec::new();
- let Ok(subpaths) = fs::read_dir(folder_path) else { todo!() };
+ let Ok(subpaths) = fs::read_dir(folder_path) else {
+ todo!()
+ };
for path in subpaths {
let Ok(path) = path else { todo!() };
let Ok(t) = path.file_type() else { todo!() };
- if !t.is_file() { continue; }
+ if !t.is_file() {
+ continue;
+ }
let path = path.path();
- if !path.extension().and_then(|e| e.to_str()).is_some_and(|e| e == "why") {
+ if !path
+ .extension()
+ .and_then(|e| e.to_str())
+ .is_some_and(|e| e == "why")
+ {
continue;
}
- let Some(name) = path.file_stem().and_then(|f| f.to_str()) else { todo!() };
+ let Some(name) = path.file_stem().and_then(|f| f.to_str()) else {
+ todo!()
+ };
let (file, is_new) = self.add_file(name, folder);
- if is_new { new_files.push(file); }
+ if is_new {
+ new_files.push(file);
+ }
if is_use {
self.get_file_mut(current_file).imported_files.push(file);
}
@@ -235,7 +251,7 @@ impl PathStorage {
Ok(((), vec![file]))
} else {
Ok(((), vec![]))
- }
+ };
}
} else {
current = self.add_folder(section, current);