feat: Std::String, Std::Map, Result/Option, ? operator, sizeof fix, docs
Add standard library modules: - Std::String: strlen, strcmp, concat, copy, starts_with wrappers - Std::Map: linear-probing hash map with String keys, int values Add error handling: - Result and Option algebraic enum examples - ? try operator for automatic error propagation in HIR lowering Compiler bugfixes: - Fix sizeof() for user-defined structs (new hSizeOf HIR node) - Fix HIR type lowering for char8, bool8, int8, uint8, etc. - Fix let statement lowering for pointer types (*char8 → int* bug) - Fix PrintInt ABI mismatch (int64_t → int in io.c) - Fix Makefile test bug (_test_tmp_pkg already exists) Documentation: - Rewrite README.md with features, examples, project structure - Add docs/LanguageRef.md — complete language reference - Add docs/Stdlib.md — standard library documentation - Add docs/BuildAndTest.md — build and test guide New examples: strings, map, result_option, try_operator (13 total)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
// Strings - String manipulation with Std::String
|
||||
import Std::Io::{PrintLine, PrintInt};
|
||||
import Std::String::{String_Len, String_Eq, String_Concat};
|
||||
|
||||
func Main() -> int {
|
||||
let hello: String = "Hello";
|
||||
let world: String = "World";
|
||||
|
||||
PrintLine("String operations:");
|
||||
|
||||
// Length
|
||||
PrintLine("Length of 'Hello':");
|
||||
PrintInt(String_Len(hello));
|
||||
PrintLine("");
|
||||
|
||||
// Concatenation
|
||||
let greeting: String = String_Concat(hello, ", ");
|
||||
let greeting2: String = String_Concat(greeting, world);
|
||||
let full: String = String_Concat(greeting2, "!");
|
||||
|
||||
PrintLine("Concatenated:");
|
||||
PrintLine(full);
|
||||
|
||||
// Equality
|
||||
if String_Eq(hello, "Hello") {
|
||||
PrintLine("'Hello' equals 'Hello'");
|
||||
}
|
||||
|
||||
if !String_Eq(hello, world) {
|
||||
PrintLine("'Hello' does not equal 'World'");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user