emberc is a tiny C-to-WebAssembly (WAT) compiler written in Rust.
- Types:
int,unsigned int - Variables: block-scoped local declarations with optional initialization
- Expressions:
- arithmetic:
+ - * / % - bitwise:
& | ^ ~ - logical:
&& || ! - comparisons:
< <= > >= == != - assignment:
=
- arithmetic:
- Statements:
- blocks
- expression statements
if/elsewhileforbreakcontinuereturn
- Functions:
- function definitions and calls
- integer return types
mainentry required
printf(int)is available as a builtin import.- Current implementation is intentionally minimal: it prints one integer per call.
- Full libc
printfformatting is not implemented in this tiny subset.
- pointers
- arrays
- structs
- floating-point types
- preprocessor/macros
- full libc integration
cargo buildwasm-pack build --target web --out-dir web-next/public/wasm --out-name emberc_wasmThis exports a browser-loadable module with compileToWat.
cargo run -- examples/add.c -o examples/add.watIf -o is omitted, emberc writes output next to input with a .wat extension.
cargo testA small editor + compile UI is provided in web-next/README.md.
Quick start:
wasm-pack build --target web --out-dir web-next/public/wasm --out-name emberc_wasm
cd web-next
npm install
npm run dev