How dvtate/postfix-haskell works
postfix-haskell is a low-level functional language compiler targeting WebAssembly. Users enter code through the interactive shell or compile a source file; both paths lex and interpret it, then produce WebAssembly Text. The compiler’s central context manages language values, macros, namespaces, and module imports, while expression nodes represent generated code. The README also documents branching, enums, inline assembly, and an embeddable API. Some subsystem links are based on documented capabilities and tree paths because their implementation was not sampled.
Main entry points: context.ts Compiler context · wat.ts WAT generation · index.ts CLI · file.ts File compiler
Components 20
User entry
- CLI
index.ts - File compiler
tools/file.ts - Interactive shell
tools/shell.ts
Language processing
- Lexer
lib/scan.ts - Parser
lib/parse.ts - Compiler context
lib/context.ts - Values and types
lib/value.ts - Macros and operators
lib/globals.ts - Namespaces
lib/namespace.ts - Module manager
lib/module.ts
WebAssembly backend
- Expression IR
lib/expr/index.ts - Functions and closures
lib/expr/func.ts - WAT generation
lib/wat.ts - Wasm runtime
lib/rt.wat - Runtime-free mode
lib/no_rt.wat
Language library
- Standard library
std/lang.phs
Other components
- Programmer
- WAT output
- WABT validator
- Binaryen optimizer
Connections 22
- Programmer → CLI: runs command
- CLI → Interactive shell: starts shell
- CLI → File compiler: compiles file
- Programmer → Interactive shell: enters code
- File compiler → Lexer: lexes source
- Interactive shell → Lexer: lexes input
- Lexer → Parser: supplies tokens
- Parser → Compiler context: interprets tokens
- Compiler context → Macros and operators: invokes operators
- Compiler context → Values and types: manages values
- Compiler context → Namespaces: resolves names
- Compiler context → Module manager: manages imports
- Compiler context → Expression IR: builds expressions
- Expression IR → Functions and closures: represents functions
- Compiler context → WAT generation: generates output
- WAT generation → Wasm runtime: includes runtime
- WAT generation → Runtime-free mode: omits runtime
- WAT generation → WABT validator: validates output
- File compiler → Binaryen optimizer: optimizes output
- WAT generation → WAT output: returns WAT
- Programmer → Standard library: imports features
- Standard library → Compiler context: defines language operators