Skip to content

Commit

Permalink
variables now work
Browse files Browse the repository at this point in the history
  • Loading branch information
grngxd committed May 31, 2022
1 parent 42c17b9 commit c469c7c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion main.aoki
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
hi = "heyyo"
print "heyyo"
print hi
12 changes: 6 additions & 6 deletions run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ func Run(filePath string) {
}

readFile.Close()
variables := map[string]string{}
variables := map[string]interface{}{}

for _, line := range fileLines {
// Checking if the line starts with `//`
if strings.HasPrefix(line, "//") {
continue
} else if strings.Contains(line, "=") {
varName := strings.Split(line, "=")[0]
varName = strings.TrimSpace(varName)
varValue := strings.Split(line, "=")[1]
varValue = strings.TrimSpace(varValue)
if strings.HasPrefix(varValue, "\"") && strings.HasSuffix(varValue, "\"") {
variables[string(varName)] = string(varValue[1 : len(varValue)-1])
} else {
Expand All @@ -44,11 +46,9 @@ func Run(filePath string) {
// It's checking if the variable exists in the map.
} else {
// every key in the map is a string.
for key, value := range variables {
// first we check if the variable exists in the map.
if strings.Contains(args, key) {
// if it exists we print out the value of the variable.
fmt.Println(variables[value])
for key := range variables {
if key == args {
fmt.Println(variables[key])
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion variables.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
map[hi : "heyyo"]
map[hi:heyyo]

0 comments on commit c469c7c

Please sign in to comment.