restore(lang): full lang tree from ff3ef452 (306 files) — compiler, vm, shared, runner, c-abi, etc.\n\n- Restores lang/ directory (files≈306, dirs≈64) as per historical branch with selfhost sources\n- Keeps our recent parser index changes in compiler/* (merged clean by checkout)\n- Unblocks selfhost development and documentation references
This commit is contained in:
23
lang/src/shared/common/string_ops.hako
Normal file
23
lang/src/shared/common/string_ops.hako
Normal file
@ -0,0 +1,23 @@
|
||||
// string_ops.hako — Common string utility functions
|
||||
// Responsibility: Basic string operations used across the codebase
|
||||
// Non-goals: JSON parsing, complex text processing
|
||||
|
||||
static box StringOps {
|
||||
// Find substring starting from position
|
||||
// Returns: index of first occurrence at/after pos, or -1 if not found
|
||||
index_of_from(text, needle, pos) {
|
||||
if text == null { return -1 }
|
||||
if pos < 0 { pos = 0 }
|
||||
local n = text.size()
|
||||
if pos >= n { return -1 }
|
||||
local m = needle.size()
|
||||
if m <= 0 { return pos }
|
||||
local i = pos
|
||||
local limit = n - m
|
||||
loop (i <= limit) {
|
||||
if text.substring(i, i + m) == needle { return i }
|
||||
i = i + 1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user