This project is still under development, as such, the codebase should be considered as a reference to the current status of the compiler, and not as a complete implementation.
To use the compiler, the following command can be run:
$ ./path/to/compiler ./path/to/file.nox
From here, the newly created output.s
file can be constructed into a runnable by using gcc
. Here it is important to note that the -no-pie
flag for GCC is required when using strings.
We advice the reader to test the following examples:
$ ./build/compiler ./examples/hello_world.nox
$ gcc -no-pie output.s
$ ./a.out
Converting Enum's to their respective string representations is a pattern which occurs often in many projects. In the C++ code for Nox itself, this is handled by using maps
. Nox has built-in compile-time support for enum stringification by using the directive #enum_strings
, and works as follows.
#enum_strings
enum Colors {
Red,
Green,
Blue
}
func int main() {
my_color: enum Colors = Colors.Green;
print("My color is %s\n", my_color.str())
}
>> My color is Green
- the
defer
keyword, which executes a given statement, expression or block at scope-exit - Built-in
string
types similar to C++ - Default Values for Struct Fields
- Compile-time logic via. directives:
#some_directive
- Functions as first-class citizens
When compiling Nox from source, it is dependent on the precense of boost version 1.84.0 .