forked from slope-lang/slope
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
320 B
25 lines
320 B
package main
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type vars map[symbol]expression
|
|
|
|
type env struct {
|
|
vars
|
|
outer *env
|
|
}
|
|
|
|
func (e *env) Find(s symbol) *env {
|
|
if _, ok := e.vars[s]; ok {
|
|
return e
|
|
} else if e.outer == nil {
|
|
panic(fmt.Sprintf("Symbol %q is not defined", s))
|
|
} else {
|
|
return e.outer.Find(s)
|
|
}
|
|
}
|
|
|
|
var globalenv env
|