X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/6be996d467429cc09f81becd3fd4e294ae1871ae..a3698041b3521c3cb17b3546ecdc08ba101c788a:/src/env.sml?ds=sidebyside diff --git a/src/env.sml b/src/env.sml index d18a5a9..47003cb 100644 --- a/src/env.sml +++ b/src/env.sml @@ -25,10 +25,24 @@ open Ast structure SS = StringSet structure SM = StringMap -val typeRules : (exp -> bool) SM.map ref = ref SM.empty +type typeRule = exp -> bool +val typeRules : typeRule SM.map ref = ref SM.empty fun registerType (name, rule) = typeRules := SM.insert (!typeRules, name, rule) fun typeRule name = SM.find (!typeRules, name) +type env_vars = exp SM.map +type action = env_vars * Ast.exp list -> env_vars +val actions : action SM.map ref = ref SM.empty +fun registerAction (name, action) = actions := SM.insert (!actions, name, action) +fun action name = SM.find (!actions, name) + +val containers : (action * (unit -> unit)) SM.map ref = ref SM.empty +fun registerContainer (name, befor, after) = + containers := SM.insert (!containers, name, (befor, after)) +fun container name = SM.find (!containers, name) + +fun badArgs name = raise Fail ("Invalid arguments to " ^ name) + type env = SS.set * (typ * exp option) SM.map val empty : env = (SS.add (SS.singleton "int", "string"), SM.empty)