-
✅ Tokenizer
-
✅ Scopes
-
✅ Parser (WIP)
-
✅ Intermediate Representation (WIP)
-
✅ CodeGen (WIP)
- ✅ Hello World with all handwritten pieces
- ✅ Simple math operations
- Scene 001 -
Gently it touches the ground,
A footprint without a sound,
Its form remarkably delicate,
Creating code, light and intricate.
In this Tyrant's paradise,
hand-tuned control, yet precise.
- Scene 002 -
Welcome, Zep, our hero.
In the realm of the One and Zero,
where the ruler's grip, firm and tight
the developer is given power, shining bright.
- Scene 003 -
Reveal to us this Zep, they pled
If only it was ready, was said.
And so there was silence oh so profound,
Between the darkness and daybreak's sound.
std:io.zp
#[extern]: env
export fn print(data: i32) -> none
hello.zp
// Global Scope
import "std:io/print"
string foo = "Hello from Zep!"
fn main() -> none {
// Local Scope
print(foo)
}
For more details, see Reference.md
// Give it a spin!
import { Parser } from "./parser/parser.js";
import { Tokenizer } from "./tokenizer/tokenizer.js";
import { TreeObject, asTree } from "treeify";
import { Generator } from "./generator/index.js";
import { readFileSync, writeFileSync } from "fs";
import { execSync } from "child_process";
const tokenizer = new Tokenizer(`
#[extern]: env.print
fn print(num: i32) -> none
export fn main(a: i32, b: i32) -> i32 {
print(123)
rt a + b
}
`);
console.log(tokenizer.getAll());
const parser = new Parser(tokenizer, "test.zp");
const fnImport = parser.parseImportFunctionDeclaration();
const fnMain = parser.parseFunctionDeclaration();
console.log(
"AST (Top Level): \n" +
asTree(
parser.program.topLevelStatements as unknown as TreeObject,
true,
false,
),
);
console.log(
"AST (Statements): \n" +
asTree(parser.program.statements as unknown as TreeObject, true, false),
);
console.log(
"Scope (Global): \n", parser.program.globalScope.nodes,
);
const generator = new Generator();
generator.parseFnImport(fnImport!);
generator.parseFn(fnMain!);
const wat = generator.toWat();
console.log(wat);
writeFileSync("./test.wat", wat);
execSync("wat2wasm test.wat -o test.wasm");
const wasm = readFileSync("./test.wasm");
const module = new WebAssembly.Module(wasm);
const instance = new WebAssembly.Instance(module, {
env: {
print: (data: number) => console.log("Print: " + data)
}
});
instance.exports.main(3,4)