b0-language
v1.0.2
Published
B0 compiler toolchain: C-like source -> 0/1 .b0 -> native Windows x64 .exe
Maintainers
Readme
B0
B0 is a small compiler toolchain with a deliberate two-stage pipeline:
C-like source (.c)
|
v
B0 compiler
|
v
binary text (.b0)
|
v
B0 native backend
|
v
Windows x64 PE (.exe)Install from npm
After publishing this package under the package name you choose:
npm install -g b0-languageThe package exposes the b0 executable through npm's bin field, so a global install adds the command to npm's global executable path. On Windows, npm normally wires this into the PATH used by the shell after installation.
Check:
b0 versionCommands
Compile C-like source to a .b0 program:
b0 input.c output.b0Compile C-like source directly to an executable. B0 checks for GCC first; when GCC is available it is used to build the .exe. If GCC is not installed, the built-in Windows PE backend is used instead:
b0 input.c output.exeCompile .b0 to a native Windows x64 executable:
b0 output.b0 output.exeRun .b0 directly with the built-in VM:
b0 run output.b0Example
examples/hello.c:
int x = 10;
int y = 20;
print("Hello from B0!\n");
print(x + y);
print("\n");Then:
b0 examples/hello.c hello.b0
b0 hello.b0 hello.exe
hello.exeThe generated .b0 file is intentionally plain text containing only 0 and 1 plus a final newline.
B0 v0.1 language
Supported source constructs:
intvariable declarations- variable assignment
print(...)- integer arithmetic:
+ - * / - parentheses
- quoted strings with common escapes
//comments
This first release is intentionally small. The native backend turns the program's VM-visible output into a self-contained Windows x64 PE console program. More advanced B0 instructions, control flow, functions, and a real native code generator are planned for later versions.
Development
Requirements:
- Node.js 18+
- npm
- TypeScript compiler
Build:
npm install
npm run buildTest:
npm testCheck the npm package contents:
npm pack --dry-runPublish after logging into npm and choosing a package name that is available:
npm login
npm publish --access public