func BuildContext(nodes []*lang.Node) *Context { ctx := Context{collections.NewPersistentMap()} for _, node := range nodes { head := node.Values[0].(*lang.Node) switch { default: case head.Type == lang.REF: // ctx.Inject(lang.Ref{head}.String(), node) } } return &ctx }
func Start() { ctx := runtime.Context{collections.NewPersistentMap()} http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "OPTION": io.WriteString(w, "OPTIONS") case "GET": } }) log.Fatal(http.ListenAndServe(":8830", nil)) }
func InitPredefs() { Predefs = collections.NewPersistentMap() Predefs.Set("std:len", length) Predefs.Set("std:sprintf", sprintf) Predefs.Set("std:printf", printf) Predefs.Set("std:println", println) Predefs.Set("std:exit", exit) Predefs.Set("std:open", fileOpen) Predefs.Set("std:write", fileWrite) Predefs.Set("std:close", fileClose) logging.Debug("Built-in environment:") for k, _ := range Predefs.Freeze() { logging.Debug(" |- %s", k) } }