rMox is a statically typed systems language for Linux x86-64.
The compiler is written in C11. It turns .rmx source into native ELF binaries through an IR backend, NASM, and GNU ld.
Current release: 1.4
- Static types (no C-style
NULL; future null iszero) - Native x86-64 code generation (System V AMD64)
- Functions, recursion, structs, enums
- Typed pointers
ptr[T]and fixed arraysarray T [N] if/elif/else,while, C-stylefor,for … inswitchwith multi-case armsdefer, generators (yield), async (spawn/await)- Modules and imports
- Inline NASM
- Built-in stdlib (
print,print_int,len, …) - Constant folding and peephole opts
- Shift operators
<<>> - Compile-time
lenfor fixed arrays
| Version | Planned |
|---|---|
| 1.5 | float, print_float |
| 1.6 | function pointers, human-readable any / voidptr |
| 1.7 | split ir.c into src/ir/ |
- Linux x86-64
- C11 compiler (
gccorclang) - GNU Make
- NASM
- GNU binutils (
ld)
git clone https://github.com/SpawnC/rmox.git
makeOr:
./build.shThis produces the rmoxc binary.
hello.rmx:
func main() -> int {
print("Hello, World!\n");
return 0;
}
Compile and run:
./rmoxc hello.rmx # writes a.out (or similar)
./a.out
./rmoxc hello.rmx -run # compile, link, and execute
./rmoxc hello.rmx -S -o hello.asm # emit NASM onlyEvery program needs a main that returns an int exit code.
Types are explicit. Variables are declared with var and initialized.
var int age = 18;
var bool enabled = true;
var char letter = 'A';
var string message = "Hello";
| Type | Meaning |
|---|---|
int |
signed 64-bit integer |
bool |
true / false |
char |
one byte |
string |
pointer to zero-terminated bytes |
void |
return type only |
ptr[T] |
pointer to T |
array T [N] |
fixed array of N elements |
Structs and enums are user-defined. C-style NULL / null is rejected with a moral error. A proper null pointer will arrive later as the keyword zero.
+ - * / %
== != < > <= >=
&& || !
& | ^ ~ << >>
+= -= *= /= %= <<= >>=
&& and || short-circuit. Division or remainder by zero traps at runtime.
if (x > 10) {
print("greater\n");
} elif (x == 10) {
print("equal\n");
} else {
print("less\n");
}
while (i < 5) {
print_int(i);
i = i + 1;
}
for (var int i = 0; i < 10; i = i + 1) {
print_int(i);
}
for-in over a fixed array (elements) or an integer range 0 .. n-1:
var array int [4] a = {10, 20, 30, 40};
for (var int x in a) {
print_int(x);
}
for (var int i in 3) {
print_int(i); // 0 1 2
}
switch (x) {
case 1:
print("one\n");
case 2, 3:
print("two or three\n");
default:
print("other\n");
}
break, continue, and return work as usual.
func int add(int a, int b) {
return a + b;
}
func main() -> int {
print_int(add(2, 3));
return 0;
}
Return type may be written before the name or with ->.
var array int [5] a = {10, 20, 30, 40, 50};
print_int(a[0]);
print_int(len(a)); // 5, folded at compile time
Out-of-bounds access traps at runtime.
var int x = 42;
var ptr[int] p = &x;
print_int(p^);
p^ = 99;
struct Point {
int x;
int y;
}
enum Color {
Red,
Green = 10,
Blue
}
Structs are passed and returned by value.
{
defer print("after\n");
print("before\n");
}
Defers run when the enclosing block exits (including via return), in reverse order.
gen func int seq() {
yield 1;
yield 2;
return 0;
}
async func int work(int n) {
return n * 2;
}
func main() -> int {
print_int(seq());
var int t = spawn work(21);
print_int(await t);
return 0;
}
Up to 16 concurrent tasks (fork + pipe).
import "lib/util.rmx";
export func int helper(int x) {
return x + 1;
}
Circular imports are not supported.
asm {
"nop"
}
NASM syntax. Register clobbers are not fully analyzed.
| Category | Functions |
|---|---|
| I/O | print, print_int, print_char, input, input_int |
| Numbers | abs, min, max, rand, len |
| Strings | strlen, strcmp, strcpy, strcat, strbuf |
No import is required for these.
Runtime traps:
- division / remainder by zero
- array index out of bounds
Compiler diagnostics use codes r1–r9 plus a source caret. Example:
file.rmx:4:5: error (r3): type mismatch in assignment: cannot assign 'string' to 'int'
NULL / null is rejected with a moral error. The planned readable null is the keyword zero.
- Lexical analysis
- Parsing
- Import processing
- Checking
- Semantic analysis
- IR
- NASM emission
nasm -f elf64ld
- Linux x86-64 only
- No garbage collector (planned later)
- No ownership / borrow checker
- No circular imports
- Async is a simple task model, not a full scheduler
rmox/
├── src/ # compiler sources
│ └── runtime/ # runtime support
├── examples/ # sample programs
├── Makefile
├── build.sh
├── LanguageGuide.md
└── README.md
- LanguageGuide.md — syntax and semantics
- WikiBooks (RU)
MIT. See LICENSE.