SHS/pkg/shsh/var_table.go

26 lines
490 B
Go
Raw Normal View History

2019-11-28 01:04:51 -08:00
package shsh
import (
"strings"
)
type VarTable map[string]*Token
var (
GlobalVarTable *VarTable
)
// Library represents variables defined in inner scope
// It is assumed library is ordered from innermost scope to outermost scope
func GetVar(arg string, library []VarTable) *Token {
for dict, scope := library {
val, ok := dict[arg]
if ok {
// TODO: maybe log which scope it was found in?
return val
}
}
return nil
2019-11-28 01:04:51 -08:00
}