https://github.com/funnyboy-roks/stark
A strictly-typed stack-based compiled programming language
https://github.com/funnyboy-roks/stark
programming-language rust stack-based
Last synced: 8 months ago
JSON representation
A strictly-typed stack-based compiled programming language
- Host: GitHub
- URL: https://github.com/funnyboy-roks/stark
- Owner: funnyboy-roks
- License: other
- Created: 2025-04-21T04:19:32.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-04-28T05:00:22.000Z (8 months ago)
- Last Synced: 2025-05-07T18:14:37.513Z (8 months ago)
- Topics: programming-language, rust, stack-based
- Language: Rust
- Homepage:
- Size: 116 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# stark
A stack-based compiled programming language
## Examples
```zig
extern fn printf(ptr ...) -> (i64);
"hello world" printf
```
```zig
// 5 4 3 2 1
5 while dup 0 = ! {
dup c"%d\n" printf(2) drop
1 -
} drop
```
## TODO
- [x] Compilation
- [x] Loops
- [ ] Labels: `'x` `while'x` (I like the idea of having this "tick" syntax like rust)
- [ ] break: `break` or `break'x` -- still need to check that the stack has not changed
- [x] Conditionals (see [conditionals.st](./examples/conditional.st))
- [x] `then`
- [x] `else`
- [ ] `switch`?
- [ ] Error handling
- [ ] Report good type errors
- [ ] Continue after error and report all at once
- [ ] Non-decimal integer literals
- [x] Full suite of numbers: i8, i16, i32, i64, u8, u16, u32, u64
- [x] Miette + thiserror for better errors
- [x] Type system
- [x] Somehow validate that functions are using the correct args
- [ ] Functions
- [x] Extern functions
- `extern fn strlen(ptr) -> (i64);`
- [ ] Ability to change the linker symbol for this function- not
sure on the syntax yet:
```zig
extern fn strlen(ptr) -> (i32) @extern("strlen");
extern("strlen") fn strlen(ptr) -> (i32);
extern fn strlen(ptr) -> (i32) @ "strlen";
```
- [x] User-defined functions
- `fn double(i64) -> (i64) { dup + }`
- type check function: stack = args, compile body, assert(stack = results)
- [ ] Need to see if we can clean up the generated assembly
- [ ] Ideally use linux calling convention so we can export the
functions for use from other langauges
- [ ] Macros
- [ ] Modules
- [ ] Imports
- [ ] Namespaces
- [x] Linking with libc
- [ ] Better CLI
- [ ] structs
- [ ] pointers
- [ ] Typed pointers
- [ ] Smarter pointer increments (like C)
- [ ] Fat pointers for things like strings
- [x] c-strings (null-terminated strings)
- `c"hello"` -> `"hello", 0`
- [ ] Auto drop (and other global directives):
- `@auto_drop` at top of file or something