mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 08:56:07 +00:00
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
func getValuesFromLetter(str string, splitstr string, index int, codelines []UNPARSEcode, allowempty bool) ([]any, bool, ArErr) {
|
|
// make a function which takes a string of code and returns a translated values
|
|
str = strings.Trim(str, " ")
|
|
commasplit := strings.Split(str, splitstr)
|
|
temp := []string{}
|
|
arguments := []any{}
|
|
if str != "" {
|
|
for i, arg := range commasplit {
|
|
temp = append(temp, arg)
|
|
test := strings.TrimSpace(strings.Join(temp, splitstr))
|
|
if test == "" && allowempty {
|
|
arguments = append(arguments, nil)
|
|
temp = []string{}
|
|
} else {
|
|
resp, worked, _, _ := translateVal(UNPARSEcode{code: test, realcode: codelines[index].realcode, line: index, path: codelines[index].path}, index, codelines, 0)
|
|
if worked {
|
|
arguments = append(arguments, resp)
|
|
temp = []string{}
|
|
if i == len(commasplit)-1 {
|
|
return arguments, true, ArErr{}
|
|
}
|
|
} else if i == len(commasplit)-1 {
|
|
return nil, false, ArErr{"Syntax Error", "invalid argument", codelines[index].line, codelines[index].path, codelines[index].realcode, true}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return arguments, true, ArErr{}
|
|
}
|