This is an attempt to create a statically-typed, compiled programming language which compiles to Web Assembly bytecode. The project is implemented in Zig 0.3.0. The compiler generates valid .wasm objects in most of the cases and can be verified using wasm tools.
The project originally started as a Lua implementation which compiles to WASM. However, as Lua is a dynamically typed language and its table-oriented object system needs significant runtime support, the idea was shortly scraped. Thus, I modified the code to be its own language, somewhat inspired by Python and Odin.
- Tokenizer: It uses a standard state-machine based tokenizer
- Parser: Arranges tokens into an AST
- analysis: Converts AST into IR and performs type checking
- WasmGen: Responsible for actually generating the WASM bytecode
Currently the following types are implemented in the language:
- void: void
- bool: i32
- float: f64
- func: i32, stored in an IR node
- Numeric and boolean literals
- Binary expressions
- Unary expressions
- If-elseif-else statements
- While loops
- Diagnostics and error messages
- Function
- Function parameters
- Function return values
- Multi-return values (using WASM extensions)
- Multi-return values using globals
- Sequence types (arrays, lists)
- For-loops for sequence types
- Hash types (dictionary, set)
- User defined types (structs) - Work in progress
- Enum and union types