BIDHU/SCRIPT
system online·llvm backend·native binary

COMPILE
THE FUTURE
FROM THE PAST.

BidhuScript is a statically-typed language with a native Go compiler. It lowers source through a three-address-code IR to LLVM IR, producing real native executables for Linux and Windows. Forge. Blueprint. Spawn. Snap. Skip.

language ref
6
Phases
lex→eval
2
Backends
LLVM · C
2
Targets
linux · win
bidhu@playground — zsh80×24
bidhu@playground:~/src$ ./bidhu run examples/functions.bidhu
▸ lexing...
▸ parsing...
▸ sema ok
▸ ir lowered
▸ llvm ir emitted
▸ clang link ok
▸ exec ▸ ▸ ▸

====================
BidhuScript functions
====================
9
120
snap and skip:
0 1 2 4 5 6
done
bidhu@playground:~/src$ 
forgeblueprintspawnsnapskipspanmy~>letwhileif / elseprintforgeblueprintspawnsnapskipspanmy~>letwhileif / elseprint
01

FEATURES

What makes BidhuScript tick
FORGE

First-class functions

forge add(int a, int b) ~> int defines a typed routine. ~> declares the return type. Snap and skip replace break and continue inside loops.

BLUEPRINT

Stack-allocated objects

blueprint Point { int x; int y; } declares a class. spawn Point(3, 4) constructs one. Methods use my to refer to the receiver, like a hidden this pointer.

LLVM IR

Native code, no VM

Source lowers through a three-address IR to LLVM IR, then to a real ELF or .exe via clang / llc+mingw. The legacy C backend is kept for side-by-side study.

WHILE

Loop with an inverse flag

while(init; cond; incr; false) — the 4th clause toggles do-while semantics. A subtle nod to C's for, repurposed for explicit control.

ARRAYS

Fixed-size, second-class

let int[4] nums = [10,20,30,40]; — declared size, stack-allocated. span(nums) folds to a compile-time constant. No array params or returns (yet).

SEMA

Static type checking

Forge signatures are unique. Arity and types are checked at every call. ~> functions must return on every path. snap and skip are only legal inside a loop.

02

SYNTAX

A tour of the language
core
Variables, arithmetic, conditionals.
let int x = 5;
let float y = 10.9;
let float result = x + y * 2;
let bool flag = true;
let string s = "Hello, " + "World";

if (result > 20.0) {
    print("big");
} else {
    print("small");
}

while(let int i = 0; i < 5; i = i + 1; false) {
    print(i);
}
forge & recursion
Functions with the ~> return-type arrow.
forge factorial(int n) ~> int {
    if (n <= 1) { return 1; }
    return n * factorial(n - 1);
}

forge banner(string title) {
    print("====================");
    print(title);
}

banner("BidhuScript");
print(factorial(5));
loops with snap & skip
The 4th while clause is the inverse flag — true means do-while.
while(let int i = 0; i < 10; i = i + 1; false) {
    if (i == 3) { skip; }
    if (i == 7) { snap; }
    print(i);
}

let int j = 0;
while(; j < 2; j = j + 1; true) {
    print(j);
}
blueprint & spawn
Classes with the my self-reference.
blueprint Point {
    int x;
    int y;
    forge sum() ~> int {
        return my.x + my.y;
    }
    forge scale(int k) {
        my.x = my.x * k;
        my.y = my.y * k;
    }
}

let Point p = spawn Point(3, 4);
print(p.sum());
p.scale(10);
print(p.sum());
03

PIPELINE

source → tokens → AST → IR → LLVM → executable
01
lexer
source → tokens
lexer.go
02
parser
Pratt, precedence climbing
parser.go
03
sema
scopes, types, bounds
sema.go
04
ir
three-address code
irgen.go
05
llvm
LLVM IR (.ll)
codegen_llvm.go
06
link
clang / llc+mingw
build.go
▸ architecture
source
.bidhu
lexer
lexer.go
parser
parser.go
sema
sema.go
irgen
irgen.go
codegen
two backends
codegen_llvm
→ LLVM IR
[opt passes]
clang / llc+mingw
→ ELF / .exe
codegen_c
→ C source
cc
cc
→ ELF / .exe
executable
Linux · Windows
scroll horizontally if needed →
irgen: three-address IR (ir.go + irgen.go)
codegen_llvm: native backend (default)
codegen_c: legacy backend for comparison
04

PLAYGROUND

Run BidhuScript live in your browser
BIDHU://playgroundv2.0
native
bidhu utf-8 · nativeln 37 · 580 ch
lexparsesemairllvmnative
stdout/READY
$ waiting for input...

The in-browser interpreter is a TypeScript port of the reference Go implementation. For full LLVM-native compilation, build the bidhu CLI from source.