Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/y21/lang
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/y21/lang
- Owner: y21
- Created: 2024-06-16T14:48:46.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-09-16T14:23:20.000Z (4 months ago)
- Last Synced: 2024-09-17T17:09:43.418Z (4 months ago)
- Language: TypeScript
- Homepage:
- Size: 949 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# lang
### Usage
At this point the compiler is written in TypeScript (eventually it will be rewritten in this language and self-hosted).
So you'll need node.js installed (and clang).
Running `npm i --save-dev && npx tsc` will compile the compiler.```sh
# it currently just reads the `input` file
$ cat input
fn add(a: i32, b: i32): i32 {
return a + b;
}
fn identity(v: T): T {
return v;
}
fn main(): i32 {
return add(identity(40), identity(2));
}# run the compiler on that file
$ node .
parse: 1.564ms
name res: 0.453ms
typeck: 0.746ms
llir/mir codegen: 0.756ms
clang: 4.332mscompilation succeeded
# run it
$ ./a.out; echo $?
42
```You can also get errors
```sh
$ cat input
fn main(): i32 {
return "";
}$ node .
return "";
^^^^^^^^^ type error: string is not a subtype of i32 (reason: 'Return')
```