From 7d07bef760a8807fe49fbe5c90799a1822f95973 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 8 Oct 2026 19:45:19 +0200 Subject: Make modules re-exportable --- source/cctype.elna | 24 ---------------- source/command_line_interface.elna | 2 +- source/common.elna | 3 +- source/cstdio.elna | 59 -------------------------------------- source/cstdlib.elna | 24 ---------------- source/cstring.elna | 30 ------------------- source/diagnostic.elna | 2 +- source/lexer.elna | 6 ++-- source/main.elna | 2 +- source/name_analysis.elna | 2 +- source/parser.elna | 4 +-- source/qbe.elna | 2 +- source/symbol.elna | 2 +- source/sys/posix/cctype.elna | 24 ++++++++++++++++ source/sys/posix/cstdio.elna | 59 ++++++++++++++++++++++++++++++++++++++ source/sys/posix/cstdlib.elna | 24 ++++++++++++++++ source/sys/posix/cstring.elna | 30 +++++++++++++++++++ source/tac.elna | 2 +- 18 files changed, 150 insertions(+), 151 deletions(-) delete mode 100644 source/cctype.elna delete mode 100644 source/cstdio.elna delete mode 100644 source/cstdlib.elna delete mode 100644 source/cstring.elna create mode 100644 source/sys/posix/cctype.elna create mode 100644 source/sys/posix/cstdio.elna create mode 100644 source/sys/posix/cstdlib.elna create mode 100644 source/sys/posix/cstring.elna (limited to 'source') diff --git a/source/cctype.elna b/source/cctype.elna deleted file mode 100644 index 19c3491..0000000 --- a/source/cctype.elna +++ /dev/null @@ -1,24 +0,0 @@ -(* This Source Code Form is subject to the terms of the Mozilla Public License, - v. 2.0. If a copy of the MPL was not distributed with this file, You can - obtain one at https://mozilla.org/MPL/2.0/. *) -module - -proc isdigit*(c: Int ) -> Int -extern - -proc isalnum*(c: Int) -> Int -extern - -proc isalpha*(c: Int) -> Int -extern - -proc isspace*(c: Int) -> Int -extern - -proc tolower*(c: Int) -> Int -extern - -proc toupper*(c: Int) -> Int -extern - -end. diff --git a/source/command_line_interface.elna b/source/command_line_interface.elna index 1318e67..4c3c1a6 100644 --- a/source/command_line_interface.elna +++ b/source/command_line_interface.elna @@ -5,7 +5,7 @@ Command line handling. *) module -import cstdlib, cstring, common +import sys.posix.cstdlib, sys.posix.cstring, common type CommandLine* = record diff --git a/source/common.elna b/source/common.elna index 65b0a65..93b4363 100644 --- a/source/common.elna +++ b/source/common.elna @@ -2,7 +2,7 @@ v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. *) module -import cstring, cstdio, cstdlib +import sys.posix.cstring, sys.posix.cstdio, sys.posix.cstdlib type ElnaLocation* = record @@ -86,4 +86,3 @@ begin return nil end. - diff --git a/source/cstdio.elna b/source/cstdio.elna deleted file mode 100644 index 928c7e1..0000000 --- a/source/cstdio.elna +++ /dev/null @@ -1,59 +0,0 @@ -(* This Source Code Form is subject to the terms of the Mozilla Public License, - v. 2.0. If a copy of the MPL was not distributed with this file, You can - obtain one at https://mozilla.org/MPL/2.0/. *) -module - -type - FILE* = extern - -var - stdin*: ^FILE := extern - stdout*: ^FILE := extern - stderr*: ^FILE := extern - -proc fopen*(pathname, mode: ^const Word8) -> ^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*#[T](ptr: ^T; size: Word; nmemb: Word; stream: ^FILE) -> Word -extern - -proc fwrite*#[T](ptr: ^const T; size: Word; nitems: Word; stream: ^FILE) -> Word -extern - -proc fputc*(c: Int; stream: ^FILE) -> Word -extern - -proc perror*(s: ^const Word8) -extern - -proc puts*(s: ^const Word8) -> Int -extern - -proc putchar*(c: Int) -> Int -extern - -proc sprintf*(str: ^Word8; format: ^const Word8) #{varargs} -> Int -extern - -proc fprintf*(stream: ^FILE; format: ^const Word8) #{varargs} -> Int -extern - -proc fdopen*(fildes: Int; mode: ^const Word8) -> ^FILE -extern - -end. diff --git a/source/cstdlib.elna b/source/cstdlib.elna deleted file mode 100644 index 10a4d80..0000000 --- a/source/cstdlib.elna +++ /dev/null @@ -1,24 +0,0 @@ -(* This Source Code Form is subject to the terms of the Mozilla Public License, - v. 2.0. If a copy of the MPL was not distributed with this file, You can - obtain one at https://mozilla.org/MPL/2.0/. *) -module - -proc malloc*#[T](size: Word) -> ^T -extern - -proc free*#[T](ptr: ^T) -extern - -proc calloc*#[T](nmemb: Word; size: Word) -> ^T -extern - -proc realloc*#[T](ptr: ^T; size: Word) -> ^T -extern - -proc atoi*(str: ^Word8) -> Int -extern - -proc exit*(code: Int) #{noreturn} -extern - -end. diff --git a/source/cstring.elna b/source/cstring.elna deleted file mode 100644 index 3973573..0000000 --- a/source/cstring.elna +++ /dev/null @@ -1,30 +0,0 @@ -(* This Source Code Form is subject to the terms of the Mozilla Public License, - v. 2.0. If a copy of the MPL was not distributed with this file, You can - obtain one at https://mozilla.org/MPL/2.0/. *) -module - -proc memset*#[T](ptr: ^T; c: Int; n: Word) -> ^Word8 -extern - -proc memcpy*#[T](dst: ^T; src: ^const T; n: Word) -extern - -proc memcmp*#[T](s1, s2: ^const T; n: Word) -> Int -extern - -proc strcmp*(s1: ^const Word8; s2: ^const Word8) -> Int -extern - -proc strncmp*(s1: ^const Word8; s2: ^const Word8; n: Word) -> Int -extern - -proc strncpy*(dst: ^Word8; src: ^const Word8; dsize: Word) -> ^Word8 -extern - -proc strcpy*(dst: ^Word8; src: ^const Word8) -> ^Word8 -extern - -proc strlen*(ptr: ^const Word8) -> Word -extern - -end. diff --git a/source/diagnostic.elna b/source/diagnostic.elna index 771ce38..2356544 100644 --- a/source/diagnostic.elna +++ b/source/diagnostic.elna @@ -2,7 +2,7 @@ v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. *) module -import common, cstdio, cstdlib, lexer, ast +import common, sys.posix.cstdio, sys.posix.cstdlib, lexer, ast type ElnaErrorKind* = ( diff --git a/source/lexer.elna b/source/lexer.elna index 9ba593f..71e76a7 100644 --- a/source/lexer.elna +++ b/source/lexer.elna @@ -2,7 +2,7 @@ v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. *) module -import cstdio, common, cstdlib +import sys.posix.cstdio, common, sys.posix.cstdlib type ElnaLexerState* = ( @@ -762,8 +762,8 @@ begin cursor^.start := code_pointer; cursor^.finish := code_pointer; cursor^.token := nil; - cursor^.position.start_location := ElnaLocation{ line: 1u, column: 1u }; - cursor^.position.end_location := ElnaLocation{ line: 1u, column: 1u } + cursor^.position.start_location := { ElnaLocation; line: 1u, column: 1u }; + cursor^.position.end_location := { ElnaLocation; line: 1u, column: 1u } return (** diff --git a/source/main.elna b/source/main.elna index 6049362..3b78651 100644 --- a/source/main.elna +++ b/source/main.elna @@ -4,7 +4,7 @@ program(parameters) import - cstdio, cstdlib, cstring, common, command_line_interface, + sys.posix.cstdio, sys.posix.cstdlib, sys.posix.cstring, common, command_line_interface, lexer, ast, diagnostic, symbol, parser, name_analysis, type_check, tac, qbe proc read_file_to_buffer(filename: ^Word8) -> []const Word8 diff --git a/source/name_analysis.elna b/source/name_analysis.elna index 75d6dbd..cbb27c0 100644 --- a/source/name_analysis.elna +++ b/source/name_analysis.elna @@ -2,7 +2,7 @@ v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. *) module -import common, cstdlib, lexer, ast, symbol, diagnostic +import common, sys.posix.cstdlib, lexer, ast, symbol, diagnostic proc elna_name_type_expression*(parser_node: ^ElnaTreeTypeExpression; error_list: ^ElnaList) -> ^ElnaType var diff --git a/source/parser.elna b/source/parser.elna index 30f79f8..3912b65 100644 --- a/source/parser.elna +++ b/source/parser.elna @@ -2,7 +2,7 @@ v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. *) module -import common, cstdlib, lexer, ast, diagnostic +import common, sys.posix.cstdlib, lexer, ast, diagnostic proc elna_parser_expect*(cursor: ^ElnaLexerCursor; expected: ElnaLexerKind; error_list: ^ElnaList) -> ^ElnaLexerToken var @@ -1129,7 +1129,7 @@ var begin result := malloc#[ElnaTreeModuleDeclaration](#size(ElnaTreeModuleDeclaration)); result^.kind := ElnaTreeKind.module_declaration; - result^.position.start_location := ElnaLocation{ line: 1u, column: 1u }; + result^.position.start_location := { ElnaLocation; line: 1u, column: 1u }; result^.position.end_location := result^.position.start_location; result^.types := elna_parser_type_part(cursor, error_list); diff --git a/source/qbe.elna b/source/qbe.elna index 0a5a45b..47eac88 100644 --- a/source/qbe.elna +++ b/source/qbe.elna @@ -2,7 +2,7 @@ v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. *) module -import common, cstdlib, cstdio, cstring, lexer, ast, symbol, tac +import common, sys.posix.cstdlib, sys.posix.cstdio, sys.posix.cstring, lexer, ast, symbol, tac var qbe_unique_id: Word := 0u diff --git a/source/symbol.elna b/source/symbol.elna index 531f58c..a07a9f3 100644 --- a/source/symbol.elna +++ b/source/symbol.elna @@ -2,7 +2,7 @@ v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. *) module -import cstdlib, common, ast +import sys.posix.cstdlib, common, ast type ElnaSymbolInfoKind* = (type_info, temporary_info, procedure_info) diff --git a/source/sys/posix/cctype.elna b/source/sys/posix/cctype.elna new file mode 100644 index 0000000..19c3491 --- /dev/null +++ b/source/sys/posix/cctype.elna @@ -0,0 +1,24 @@ +(* This Source Code Form is subject to the terms of the Mozilla Public License, + v. 2.0. If a copy of the MPL was not distributed with this file, You can + obtain one at https://mozilla.org/MPL/2.0/. *) +module + +proc isdigit*(c: Int ) -> Int +extern + +proc isalnum*(c: Int) -> Int +extern + +proc isalpha*(c: Int) -> Int +extern + +proc isspace*(c: Int) -> Int +extern + +proc tolower*(c: Int) -> Int +extern + +proc toupper*(c: Int) -> Int +extern + +end. diff --git a/source/sys/posix/cstdio.elna b/source/sys/posix/cstdio.elna new file mode 100644 index 0000000..928c7e1 --- /dev/null +++ b/source/sys/posix/cstdio.elna @@ -0,0 +1,59 @@ +(* This Source Code Form is subject to the terms of the Mozilla Public License, + v. 2.0. If a copy of the MPL was not distributed with this file, You can + obtain one at https://mozilla.org/MPL/2.0/. *) +module + +type + FILE* = extern + +var + stdin*: ^FILE := extern + stdout*: ^FILE := extern + stderr*: ^FILE := extern + +proc fopen*(pathname, mode: ^const Word8) -> ^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*#[T](ptr: ^T; size: Word; nmemb: Word; stream: ^FILE) -> Word +extern + +proc fwrite*#[T](ptr: ^const T; size: Word; nitems: Word; stream: ^FILE) -> Word +extern + +proc fputc*(c: Int; stream: ^FILE) -> Word +extern + +proc perror*(s: ^const Word8) +extern + +proc puts*(s: ^const Word8) -> Int +extern + +proc putchar*(c: Int) -> Int +extern + +proc sprintf*(str: ^Word8; format: ^const Word8) #{varargs} -> Int +extern + +proc fprintf*(stream: ^FILE; format: ^const Word8) #{varargs} -> Int +extern + +proc fdopen*(fildes: Int; mode: ^const Word8) -> ^FILE +extern + +end. diff --git a/source/sys/posix/cstdlib.elna b/source/sys/posix/cstdlib.elna new file mode 100644 index 0000000..10a4d80 --- /dev/null +++ b/source/sys/posix/cstdlib.elna @@ -0,0 +1,24 @@ +(* This Source Code Form is subject to the terms of the Mozilla Public License, + v. 2.0. If a copy of the MPL was not distributed with this file, You can + obtain one at https://mozilla.org/MPL/2.0/. *) +module + +proc malloc*#[T](size: Word) -> ^T +extern + +proc free*#[T](ptr: ^T) +extern + +proc calloc*#[T](nmemb: Word; size: Word) -> ^T +extern + +proc realloc*#[T](ptr: ^T; size: Word) -> ^T +extern + +proc atoi*(str: ^Word8) -> Int +extern + +proc exit*(code: Int) #{noreturn} +extern + +end. diff --git a/source/sys/posix/cstring.elna b/source/sys/posix/cstring.elna new file mode 100644 index 0000000..3973573 --- /dev/null +++ b/source/sys/posix/cstring.elna @@ -0,0 +1,30 @@ +(* This Source Code Form is subject to the terms of the Mozilla Public License, + v. 2.0. If a copy of the MPL was not distributed with this file, You can + obtain one at https://mozilla.org/MPL/2.0/. *) +module + +proc memset*#[T](ptr: ^T; c: Int; n: Word) -> ^Word8 +extern + +proc memcpy*#[T](dst: ^T; src: ^const T; n: Word) +extern + +proc memcmp*#[T](s1, s2: ^const T; n: Word) -> Int +extern + +proc strcmp*(s1: ^const Word8; s2: ^const Word8) -> Int +extern + +proc strncmp*(s1: ^const Word8; s2: ^const Word8; n: Word) -> Int +extern + +proc strncpy*(dst: ^Word8; src: ^const Word8; dsize: Word) -> ^Word8 +extern + +proc strcpy*(dst: ^Word8; src: ^const Word8) -> ^Word8 +extern + +proc strlen*(ptr: ^const Word8) -> Word +extern + +end. diff --git a/source/tac.elna b/source/tac.elna index 7b05ab2..3d65e42 100644 --- a/source/tac.elna +++ b/source/tac.elna @@ -2,7 +2,7 @@ v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. *) module -import common, cstdlib, cstdio, cstring, lexer, ast, symbol, diagnostic +import common, sys.posix.cstdlib, sys.posix.cstdio, sys.posix.cstring, lexer, ast, symbol, diagnostic type ElnaTacOperator* = ( -- cgit v1.2.3