Skip to content

honganh1206/wats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wats

A toy language that compiles to WebAssembly binary format, written in TypeScript.

Language

Wats uses a simple syntax with functions declared using funk:

funk add(x, y) { x + y }

funk main() {
  let result = add(1, 2);
  result
}

Supports arithmetic (+, -, *, /), let bindings, variable assignment (:=), and function calls.

Usage

# Run the REPL
npm run repl

# Run tests
bun test

# Type check
npm run check

Project Structure

  • src/wasm/ — Low-level WebAssembly binary encoding (LEB128, instructions, sections, module builder)
  • src/compiler/ — Language frontend: Ohm.js PEG grammar, semantic actions, and compiler
  • src/runtime/ — WebAssembly module loader
  • test/ — Tests (mirrors src/ structure)

About

💡 WebAssembly compiler

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors