Fix indentation in GPL headers
[hcoop/domtool2.git] / src / env.sml
index b52ead1..2141f64 100644 (file)
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*)
+ *)
 
 (* Domtool type-checking and reduction environments *)
 
@@ -25,6 +25,24 @@ open Ast
 structure SS = StringSet
 structure SM = StringMap
 
+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)