initial commit

This commit is contained in:
2025-08-31 13:48:32 +10:00
parent ea93fdb4f2
commit 0b6d74d3a9
5 changed files with 129 additions and 0 deletions

79
test.grnd Normal file
View File

@@ -0,0 +1,79 @@
# checks if the current index in the determiner matches the current index in the target string
fun -bool !currentCharsMatch -string &str -string &determiner -int &counter -int &detIndex
getstrcharat $str $counter &currentChar
getstrcharat $determiner $detIndex &currentDetChar
equal $currentChar $currentDetChar &equals
return $equals
endfun
fun -list !split -string &str -string &determiner
# create an empty list
setlist *output ""
set &counter 0
set &detIndex 0
set &currentLoop "" # basically we build out the current token until we reach the determiner
getstrsize $str &length
getstrsize $determiner &determinerLength
# go through each char in the string, does it match the first char in our determiner?
#@loop
# we are technically getting the current char twice
# 1. inside the currentCharsMatch function
# 2. here
# but oh well, it wont be that bad (i hope)
getstrcharat $str $counter &currentChar
pusharg $str
pusharg $determiner
pusharg $counter
pusharg $detIndex
call !currentCharsMatch &equals
not $equals &doesntMatch
if $doesntMatch %next
stdlnout "WE HAVE A MATCH"
set &detIndex 0
# WE HAVE A MATCH BABY, we gotta make sure it matches the whole determiner tho
@innerLoop
pusharg $str
pusharg $determiner
pusharg $counter
pusharg $detIndex
call !currentCharsMatch &equals
add $detIndex 1 &detIndex
equal $detIndex $determinerLength &endOfDet
if $endOfDet %append
if $equals %innerLoop
@append
listappend *output $currentLoop
set &currentLoop ""
set &detIndex 0
@next
add $currentLoop $currentChar &currentLoop
# next character in the string
add $counter 1 &counter
inequal $length $counter &notAtEnd
stdlnout $notAtEnd
if $notAtEnd %loop
return *output
endfun
pusharg "split this string"
pusharg " "
call !split *listOut
#getlistsize *listOut &length
#stdlnout $length
set &counter 0
@loopOverList
getlistat *listOut $counter &currentItem
stdlnout $currentItem
add $counter 1 &counter
getlistsize *listOut &length
inequal $counter $length &notDone
if $notDone %loopOverList