way better lex function

This commit is contained in:
Aidan Hahn 2019-11-28 22:43:30 -08:00
parent 6f7adc0789
commit 65cecb3647
No known key found for this signature in database
GPG key ID: 327711E983899316
7 changed files with 60 additions and 37 deletions

22
var_table.go Normal file
View file

@ -0,0 +1,22 @@
package shsh
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 scope, dict := range library {
val, ok := dict[arg]
if ok {
scope = scope // TEMP LINE
// TODO: maybe log which scope it was found in?
return val
}
}
return nil
}