Allow extern variables

This commit is contained in:
2025-08-20 21:47:50 +02:00
parent 0c2a396320
commit 809e41bcc3
8 changed files with 45 additions and 12 deletions

View File

@@ -16,6 +16,7 @@ proc write*(fd: Int, buf: Pointer, Word: Int) -> Int; extern;
proc write_s*(value: String);
begin
(* fwrite(cast(value.ptr: Pointer), value.length, 1u, stdout) *)
write(1, cast(value.ptr: Pointer), cast(value.length: Int))
end;

View File

@@ -6,14 +6,20 @@ module;
type
FILE* = record end;
proc fopen(pathname: ^Char, mode: ^Char) -> ^FILE; extern;
proc fclose(stream: ^FILE) -> Int; extern;
proc fseek(stream: ^FILE, off: Int, whence: Int) -> Int; extern;
proc rewind(stream: ^FILE); extern;
proc ftell(stream: ^FILE) -> Int; extern;
proc fflush(stream: ^FILE) -> Int; extern;
var
stdin*: ^FILE := extern;
stdout*: ^FILE := extern;
stderr*: ^FILE := extern;
proc fread(ptr: Pointer, size: Word, nmemb: Word, stream: ^FILE) -> Word; extern;
proc fopen*(pathname: ^Char, mode: ^Char) -> ^FILE; extern;
proc fclose*(stream: ^FILE) -> Int; extern;
proc fseek*(stream: ^FILE, off: Int, whence: Int) -> Int; extern;
proc rewind*(stream: ^FILE); extern;
proc ftell*(stream: ^FILE) -> Int; extern;
proc fflush*(stream: ^FILE) -> Int; extern;
proc fread*(ptr: Pointer, size: Word, nmemb: Word, stream: ^FILE) -> Word; extern;
proc fwrite*(ptr: Pointer, size: Word, nitems: Word, stream: ^FILE) -> Word; extern;
proc perror(s: ^Char); extern;

View File

@@ -624,7 +624,7 @@ end;
proc parse(tokens: ^Token, tokens_size: Word);
var
current_token: ^Token;
i: Word := 0;
i: Word := 0u;
begin
while i < tokens_size do
current_token := tokens + i;