Added unicode support

Replaced strings with rune-slices, which capture unicode codepoints more
accurately.
This commit is contained in:
2024-11-18 10:41:50 -05:00
parent 805766a5ba
commit 8a1f1dc621
5 changed files with 8 additions and 8 deletions

View File

@@ -406,7 +406,7 @@ func main() {
startState := thompson(re_postfix)
// Read every string from stdin until we encounter an error. If the error isn't EOF, panic.'
for test_str, err = reader.ReadString('\n'); err == nil; test_str, err = reader.ReadString('\n') {
matchIndices := findAllMatches(startState, test_str)
matchIndices := findAllMatches(startState, []rune(test_str))
// Decompose the array of matchIndex structs into a flat unique array of ints - if matchIndex is {4,7}, flat array will contain 4,5,6
// This should make checking O(1) instead of O(n)
indicesToPrint := new_uniq_arr[int]()