From 4e9354a3d9cd58551dc94eb395ca260e71c60a66 Mon Sep 17 00:00:00 2001 From: Tyler McGurrin Date: Tue, 14 Oct 2025 11:57:11 -0400 Subject: [PATCH] RAAAAAAAAAAAAAAH --- CMakeLists.txt | 13 ++++--------- README.md | 2 ++ documentation/Basics.md | 8 +++++++- documentation/Filetypes.md | 4 ++++ documentation/Variable Types.md | 7 +++++++ examples/return.s | 7 +++++-- src/main.c | 19 ------------------- src/main.cxx | 22 ++++++++++++++++++++++ 8 files changed, 51 insertions(+), 31 deletions(-) create mode 100644 documentation/Filetypes.md create mode 100644 documentation/Variable Types.md delete mode 100644 src/main.c create mode 100644 src/main.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c448bd..293a7b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,9 @@ -cmake_minimum_required(VERSION 3.14.0) -project(xic - LANGUAGES C - DESCRIPTION "XILANG Compilier" -) +cmake_minimum_required(VERSION 3.25.0) +project(xic) -set(CVERSION "-std=c99") +set(CMAKE_CXX_STANDARD 26) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CVERSION}") - -add_executable(${PROJECT_NAME} src/main.c) +add_executable(${PROJECT_NAME} src/main.cxx) target_link_libraries( ${PROJECT_NAME} diff --git a/README.md b/README.md index fa55be0..4fbbfe9 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ # Xircon-s-Lang + +A language and a compiler with decent documentation, uses nasm under the hood as an assembler \ No newline at end of file diff --git a/documentation/Basics.md b/documentation/Basics.md index ff8118b..0a70899 100644 --- a/documentation/Basics.md +++ b/documentation/Basics.md @@ -6,7 +6,7 @@ A short and relatively detailed list of all the basics of XILANG. Also yes, the * `ret` then a value (can be a numeral or a string) will return that value * `func` then a name (ex: `func main() {}`) allows you to define a new function -* `import` and a filename (either in `""` or `<>` depending on if it is a local file in the dir or a file from the include path, similar to C) allows you to import the functions from another file +* `import` and a filename (either in `""` or `<>` depending on if it is a local file in the dir or a file from the include path, similar to C) allows you to import the functions from another file (ex: `import Example.xh`) * `print` then a value will allow to print a character or string to the screen (you can also print any other type of varible) ## Defining Varibles @@ -19,6 +19,12 @@ you define something by doing the type of var you want to define then a name the * `string` for a string value (the value MUST be wrapped in `""`s!) * `char` for a single character value (must be wrapped in `''`s!) +## Ifs and Loops + +* `if` is pretty simple its just `if x = y {do this}` +* `loop` is a bit more... dangerous. you can loop... well... basically forever if you were to... forget the value... `loop 100 {print "This"}` or `loop {print "This"}` are both valid ways to use loop, one does the same thing 100 times the other does it until your CPU stops CPUing. +* `while` does something while something is true, for example `while x = 1 {print "This"}` or `while x > 1 {print "This"}` + ## A Basic Program A Basic program that just prints text and then returns. diff --git a/documentation/Filetypes.md b/documentation/Filetypes.md new file mode 100644 index 0000000..699c9af --- /dev/null +++ b/documentation/Filetypes.md @@ -0,0 +1,4 @@ +# File Types + +* `*.x` main file same as a `*.c` file is in C +* `*.xh` basically the same idea as a C header file \ No newline at end of file diff --git a/documentation/Variable Types.md b/documentation/Variable Types.md new file mode 100644 index 0000000..bd8df0b --- /dev/null +++ b/documentation/Variable Types.md @@ -0,0 +1,7 @@ +# Types Of Variables + +outlines how these work under the hood i guess... + +## Boolean +Under the hood its basically just an int... with a value of either 1 or 0 (1 being true 0 being false) +for example if you wanted to set an int to 1 *technically* you can do this `int Example = true` as a boolean is just an int internally. \ No newline at end of file diff --git a/examples/return.s b/examples/return.s index a6dee1d..ec8b1e4 100644 --- a/examples/return.s +++ b/examples/return.s @@ -1,4 +1,7 @@ ;This is a comment -main: - ret \ No newline at end of file +global _start +_start: + mov rax, 60 + mov rsi, 0 + syscall \ No newline at end of file diff --git a/src/main.c b/src/main.c deleted file mode 100644 index 07e795b..0000000 --- a/src/main.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include -#include - -#define version "RD-00001" - -int main(int argC, char *argV[]) -{ - if(argC != 1) { - for( int i=1; i < argC; i++) { - if (strcmp(argV[i], "-v") == false) { printf("Xircon's Lang Compilier %s\n", version); return false;} - } - - } else { - printf("Usage: %s [OPTIONS] [SERVER] [PORT]\n", argV[0]); - return true; - } -} \ No newline at end of file diff --git a/src/main.cxx b/src/main.cxx new file mode 100644 index 0000000..81214a4 --- /dev/null +++ b/src/main.cxx @@ -0,0 +1,22 @@ +#include +#include +#include + +#define version "RD-00002" + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 + +int main(int argC, char *argV[]) { + if(argC > 2) { + std::cerr << "Usage: xic [OPTIONS] [INPUT FILE]\n" << std::endl; + return EXIT_FAILURE; + } + + std::fstream input(argV[1], std::ios::in); + std::stringstream contents_stream; + contents_stream << input.rdbuf(); + input.close(); + + return 0; +} \ No newline at end of file