From 68fa53c022ba8b4a62de8482348aa5899130cbd8 Mon Sep 17 00:00:00 2001 From: Travis Avey Date: Fri, 15 May 2026 13:40:57 -0400 Subject: [PATCH] source code migration from gitlab --- 001HelloWorld/.gitignore | 2 ++ 001HelloWorld/LICENSE | 0 001HelloWorld/README.md | 0 001HelloWorld/docs/.gitkeep | 0 001HelloWorld/lib/.gitkeep | 0 001HelloWorld/project.json | 45 +++++++++++++++++++++++++++++++ 001HelloWorld/resources/.gitkeep | 0 001HelloWorld/scripts/.gitkeep | 0 001HelloWorld/src/.gitkeep | 0 001HelloWorld/src/main.c3 | 46 ++++++++++++++++++++++++++++++++ 001HelloWorld/test.txt | 4 +++ 001HelloWorld/test/.gitkeep | 0 README.md | 12 +++++++++ 13 files changed, 109 insertions(+) create mode 100644 001HelloWorld/.gitignore create mode 100644 001HelloWorld/LICENSE create mode 100644 001HelloWorld/README.md create mode 100644 001HelloWorld/docs/.gitkeep create mode 100644 001HelloWorld/lib/.gitkeep create mode 100644 001HelloWorld/project.json create mode 100644 001HelloWorld/resources/.gitkeep create mode 100644 001HelloWorld/scripts/.gitkeep create mode 100644 001HelloWorld/src/.gitkeep create mode 100644 001HelloWorld/src/main.c3 create mode 100644 001HelloWorld/test.txt create mode 100644 001HelloWorld/test/.gitkeep create mode 100644 README.md diff --git a/001HelloWorld/.gitignore b/001HelloWorld/.gitignore new file mode 100644 index 0000000..3c0160d --- /dev/null +++ b/001HelloWorld/.gitignore @@ -0,0 +1,2 @@ +build/ +out/ diff --git a/001HelloWorld/LICENSE b/001HelloWorld/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/001HelloWorld/README.md b/001HelloWorld/README.md new file mode 100644 index 0000000..e69de29 diff --git a/001HelloWorld/docs/.gitkeep b/001HelloWorld/docs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/001HelloWorld/lib/.gitkeep b/001HelloWorld/lib/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/001HelloWorld/project.json b/001HelloWorld/project.json new file mode 100644 index 0000000..def7a5d --- /dev/null +++ b/001HelloWorld/project.json @@ -0,0 +1,45 @@ +{ + // Language version of C3. + "langrev": "1", + // Warnings used for all targets. + "warnings": [ "no-unused" ], + // Directories where C3 library files may be found. + "dependency-search-paths": [ "lib" ], + // Libraries to use for all targets. + "dependencies": [ ], + // Authors, optionally with email. + "authors": [ "John Doe " ], + // Version using semantic versioning. + "version": "0.1.0", + // Sources compiled for all targets. + "sources": [ "src/**" ], + // Test sources compiled for all targets. + "test-sources": [ "test/**" ], + // C sources if the project also compiles C sources + // relative to the project file. + // "c-sources": [ "csource/**" ], + // Include directories for C sources relative to the project file. + // "c-include-dirs": [ "csource/include" ], + // Build location, relative to project file. + "build-dir": "build", + // Output location, relative to project file. + "output": "build", + // Architecture and OS target. + // You can use 'c3c --list-targets' to list all valid targets. + // "target": "windows-x64", + // Targets. + "targets": { + "HelloWorld": { + // Executable or library. + "type": "executable", + // Additional libraries, sources + // and overrides of global settings here. + }, + }, + // Global settings. + // CPU name, used for optimizations in the LLVM backend. + "cpu": "generic", + // Optimization: "O0", "O1", "O2", "O3", "O4", "O5", "Os", "Oz". + "opt": "O0" + // See resources/examples/project_all_settings.json and 'c3c --list-project-properties' to see more properties. +} \ No newline at end of file diff --git a/001HelloWorld/resources/.gitkeep b/001HelloWorld/resources/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/001HelloWorld/scripts/.gitkeep b/001HelloWorld/scripts/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/001HelloWorld/src/.gitkeep b/001HelloWorld/src/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/001HelloWorld/src/main.c3 b/001HelloWorld/src/main.c3 new file mode 100644 index 0000000..b766e8f --- /dev/null +++ b/001HelloWorld/src/main.c3 @@ -0,0 +1,46 @@ +module helloworld; +import std::io; +import std::io::file; + +extern fn int printf(char *format, ...); + +fn void? readFile(String filename) { + File? file = file::open(filename, "r")!; + + defer (void)file.close(); + + while (try line = io::treadline(&file)) { + io::printn(line); + } +} + +//fn int main() {} +fn int main(String[] args) { + printf("Hello %s\n", "world!"); + + //foreach (arg : args) { + // io::printn(arg); + //} + + //io::printn("Hello, World!"); + + // struct { *type, ulong len} + //if (args.len < 2) { + // io::printn("Usage: HelloWorld "); + // return -1; + //} + //io::printfn("filename: %s", args[1]); + //String filename = args[1]; + + io::print("enter the file name: "); + String? filename = io::treadline(); + if (catch error = filename) { + io::printfn("error invalid input: %s", error); + return -1; + } + if (catch error = readFile(filename)) { + io::printfn("error opening file: %s", error); + } + + return 0; +} diff --git a/001HelloWorld/test.txt b/001HelloWorld/test.txt new file mode 100644 index 0000000..b7cd094 --- /dev/null +++ b/001HelloWorld/test.txt @@ -0,0 +1,4 @@ +hey, this is a file +let's read it line by line +with C3 +Do you like C3? diff --git a/001HelloWorld/test/.gitkeep b/001HelloWorld/test/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md new file mode 100644 index 0000000..5aafb86 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# C3 + + + +## For Learning Only + +These little projects are for learning only and you can see the videos: [here](https://www.youtube.com/@aveydotdev) + + +## Collaborate + +Feel free to reach out if something isn't write or there's an update to C3 that could benefit someone learning C3. Thanks!