add set type to set variable data type

This commit is contained in:
William Bell committed 2022-05-25 21:26:03 +00:00
1 parent e8a5a2ab00
commit 8466e481dc
2 files changed
+6

No files matched your search

+1
View File
@@ -18,6 +18,7 @@ type whileLoop struct {
}
type setVariable struct {
TYPE string
variable string
value interface{}
line int
+5
View File
@@ -111,6 +111,10 @@ var translateline = func(i int, codearray []code) (interface{}, int) {
} else if setVariableCompile.MatchString(codeseg.code) {
VAR := strings.Split(codeseg.code, "=")
firstSplit := strings.Split(strings.Trim(VAR[0], " "), " ")
TYPE := "var"
if len(firstSplit) > 1 {
TYPE = firstSplit[0]
}
variable := firstSplit[len(firstSplit)-1]
resp, worked := translateprocess(code{code: VAR[1],
line: codeseg.line})
@@ -118,6 +122,7 @@ var translateline = func(i int, codearray []code) (interface{}, int) {
log.Fatal("invalid value")
}
return setVariable{
TYPE: TYPE,
variable: variable,
value: resp,
line: codeseg.line,