source code migration from gitlab
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
build/
|
||||||
|
out/
|
||||||
@@ -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 <john.doe@example.com>" ],
|
||||||
|
// 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.
|
||||||
|
}
|
||||||
@@ -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 <filename>");
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
hey, this is a file
|
||||||
|
let's read it line by line
|
||||||
|
with C3
|
||||||
|
Do you like C3?
|
||||||
@@ -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!
|
||||||
Reference in New Issue
Block a user