Nexus is a small interpreted scripting language implemented in C++.
This README tracks project progress and documents what currently works.
- CLI entrypoint that reads source from a file path or stdin.
- Lexer with:
- identifiers, numbers, strings
- operators:
+ - * / > < = == - punctuation:
() { } ; - keywords:
let const out if else repeat times - comments:
// lineand/* block */ - line/column diagnostics with source name
- Parser + AST with:
- declarations:
let,const - output statement:
out(...) - control flow:
if / else if / else - loops:
repeat <ident> <expr> times { ... } - expression precedence: equality, comparison, add/sub, mul/div, grouping
- declarations:
- Runtime with:
- integer arithmetic and comparisons
- variable declarations and reassignment (
x = ...;) - block-based lexical scoping for
{ ... },if/else, andrepeatbodies - nested loop/conditional scope isolation (inner variables do not overwrite outer scope bindings)
- runtime diagnostics (with caret and location)
- variable environment + const tracking
- runtime diagnostics (with caret and location)
- Assignment to existing variables (e.g.
x = x + 1;) - Functions and function calls
- Modules/imports
- Rich types (arrays, maps/objects, booleans as first-class type)
- Standard library (
fs,http,json,process, etc.) - Bytecode VM / JIT (performance-focused execution backend)
- Automated tests in CTest
- Add functions + call stack.
- Add core stdlib (IO, JSON, HTTP, process).
- Move from AST-walk execution toward bytecode for speed.
- Add test suite + benchmarks.
- Add assignment statements and scoped blocks.
- Add functions + call stack.
- Add core stdlib (IO, JSON, HTTP, process).
- Move from AST-walk execution toward bytecode for speed.
- Add test suite + benchmarks.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release -j"$(nproc)"Run from file:
./build/nexus examples.nxt
./build/nexus examples.nxOr pipe from stdin:
echo 'out("hello");' | ./build/nexusSource files are required to use the .nxt extension when passed as a file argument.
```nx
let x = 10;
const y = 3;
out(x + y);
Expected output:
13
```nx
repeat i 5 times {
out(i);
}
Expected output:
0
1
2
3
4
let x = 1;
{
let x = 10;
x = x + 5;
out(x);
}
out(x);
Expected output:
15
1
let i = 99;
repeat i 2 times {
out(i);
{
let i = 42;
out(i);
}
}
out(i);
Expected output:
0
42
1
42
99
## 3) Conditionals
```nx
let n = 7;
if n > 10 {
out("big");
} else if n == 7 {
out("lucky");
} else {
out("small");
}
Expected output:
lucky
## 4) Comments and grouping
```nx
// line comment
/* block
comment */
out((2 + 3) * 4);
Expected output:
20
Build image:
docker build -t nexus:local .Run with stdin:
echo 'out("from container");' | docker run --rm -i nexus:localThe Docker publish workflow builds the project via CMake inside the image build stage. If C++ compilation fails, the Docker build step will fail as expected.