Giter VIP home page Giter VIP logo

zep's Introduction

logo

Zep Language

Compiles to WebAssembly.
Tuned for WebAssembly.

Capabilities

  • ✅ Tokenizer

  • ✅ Scopes

  • ✅ Parser (WIP)

  • ✅ Intermediate Representation (WIP)

  • ✅ CodeGen (WIP)

Achievements

  • ✅ 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)

zep's People

Contributors

jairussw avatar

Stargazers

 avatar Andrew Johnson avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.