Stark is a strictly-typed stack-based compiled programming language with zero runtime.
extern fn printf(*i8 ...) -> (i32);
"hello world" printf// 5 4 3 2 1
5
while dup 0 != {
dup c"%d " printf(2) drop
1 -
} drop
c"\n" printf drop- Compilation
- Loops
- Labels:
'xwhile'x(I like the idea of having this "tick" syntax like rust) -
breakout of loop - break to label:
break'x
- Labels:
- Conditionals (see conditionals.st)
-
then -
else -
switch?
-
- Error handling
- Report good type errors
- Continue after error and report all at once
- Non-decimal integer literals
- Full suite of numbers: i8, i16, i32, i64, u8, u16, u32, u64
- Miette + thiserror for better errors
- Type system
- Somehow validate that functions are using the correct args
- Functions
- Extern functions
extern fn strlen(*i8) -> (i64);- Ability to change the linker symbol for this function
extern("strlen") fn string_length(*i8) -> (i32);
- 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
- Extern functions
- Macros
- Modules
- Imports
- Linking with libc
- Better CLI
- structs (#8)
- pointers
- Typed pointers
- Smarter pointer increments (like C)
- Typed pointers
- c-strings (null-terminated strings)
c"hello"->"hello", 0
- Auto drop (and other global directives):
@auto_dropat top of file or something
- Asymmetrical strings:
`'or even«»(or both!) - Optional stack assertion line suffix:
5 dup u32 | .. u64 u32(#12)- Syntax:
<statements> ::= ; to be defined <type> ::= ; to be defined <type_or_range> ::= <type> | ".." <stack_assertion> ::= <type_or_range> | <type_or_range> <stack_assertion> <line> ::= <statements> | <statements> "|" <stack_assertion>
- Syntax:
- Annotate stack cli argument that generates stack assertions automatically and print to stdout
- Proper BNF for the language