|
|
|
@ -2,6 +2,7 @@ package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"sort"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type UnknownSymbolError struct{ symbol }
|
|
|
|
@ -40,6 +41,15 @@ func (e environment) set(key symbol, val interface{}) {
|
|
|
|
|
e.items[key] = val
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e environment) keys() []string {
|
|
|
|
|
keys := make([]string, 0, len(e.items))
|
|
|
|
|
for key, _ := range e.items {
|
|
|
|
|
keys = append(keys, string(key))
|
|
|
|
|
}
|
|
|
|
|
sort.Strings(keys)
|
|
|
|
|
return keys
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e environment) defined(key symbol) bool {
|
|
|
|
|
_, err := e.get(key)
|
|
|
|
|
return err == nil
|
|
|
|
|