Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/discretetom/dt0
The minimal programming language that compiles to WebAssembly via Binaryen & retsac.
https://github.com/discretetom/dt0
Last synced: 16 days ago
JSON representation
The minimal programming language that compiles to WebAssembly via Binaryen & retsac.
- Host: GitHub
- URL: https://github.com/discretetom/dt0
- Owner: DiscreteTom
- License: mit
- Created: 2022-09-04T12:55:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-11T13:02:35.000Z (about 1 year ago)
- Last Synced: 2024-12-11T00:39:36.375Z (2 months ago)
- Language: TypeScript
- Homepage:
- Size: 479 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DT0

[](https://github.com/DiscreteTom/retsac)The **_minimal_** programming language that compiles to [WebAssembly](https://webassembly.org/) via [Binaryen](https://github.com/WebAssembly/binaryen). This is used to test/demo [retsac](https://github.com/DiscreteTom/retsac). This is also suitable for beginners to learn how to create a compiler.
Since this is a **_minimal_** language, any advanced language features will not be implemented: struct, enum, class, closure, array, etc.
## Spec
Since retsac already makes it intuitive to create a compiler, I recommend you to read the source code directly to understand the grammar specs.
For lexical specs, see [this file](https://github.com/DiscreteTom/dt0/blob/main/src/lexer/index.ts).
For grammar rules, see [this folder](https://github.com/DiscreteTom/dt0/tree/main/src/parser/rules).
## Limitations
For simplicity, these limitations are enforced by design:
- You can't define functions inside functions.
- No type system, `i32` is the only type.
- Every function is exported.
- Local variables defined in if/while blocks are accessible outside the block.