conlang: add lang items, remove Empty, and shuffle typeck

This commit is contained in:
2025-09-15 10:45:14 -04:00
parent ead1f351a7
commit f41e5fc49a
26 changed files with 172 additions and 154 deletions

View File

@@ -1,5 +1,8 @@
//! Implements format string evaluation in weak Conlang
fn f(__fmt: str) -> str {
/// Formats a string
fn f(__fmt: &str) -> &str {
let __out = "";
let __expr = "";
let __label = "";

View File

@@ -4,13 +4,11 @@
// These two functions shouldn't actually be polymorphic, but
// the AST interpreter doesn't know about type annotations
// or operator overloading.
#[generic("T")]
pub fn max(a: T, b: T) -> T {
pub fn max<T>(a: T, b: T) -> T {
(if a < b { b } else { a })
}
#[generic("T")]
pub fn min(a: T, b: T) -> T {
pub fn min<T>(a: T, b: T) -> T {
(if a > b { b } else { a })
}

View File

@@ -13,11 +13,11 @@ pub fn lfsr_next() {
}
/// Returns a pseudorandom byte
pub fn rand() -> u8 {
pub fn rand() -> u64 {
for _ in 0..8 {
lfsr_next()
}
state & 0xff
};
(state & 0xff) as u64
}
// Prints a maze out of diagonal box drawing characters, ['', '']