*** empty log message ***
[m17n/m17n-lib-cs.git] / expr.cs
diff --git a/expr.cs b/expr.cs
index 43d6bec..3ad5f76 100644 (file)
--- a/expr.cs
+++ b/expr.cs
@@ -8,37 +8,34 @@ public class Test
 {
   static MSymbol Mpreedit = MSymbol.Of ("preedit");
 
-  public static object insert (object[] args, MPlist bindings)
+  public static object insert (MExpression[] args, MExpression.Domain domain)
   {
-    object arg = ((MExpression) args[0]).Eval (bindings);
-    MPlist slot = bindings.Find (Mpreedit);
-    MText preedit = (MText) slot.val;
+    MText preedit = (MText) domain.GetValue (Mpreedit);
+    object val = args[0].Val;
 
-    if (arg is int)
-      preedit.Cat ((int) arg);
+    if (val is int)
+      preedit.Cat ((int) val);
     else
-      preedit.Cat ((MText) arg);
-    return arg;
+      preedit.Cat ((MText) val);
+    return val;
   }
 
   public static void Main()
   {
-    MExpression expr;
-    MPlist bindings = new MPlist ();
-    MExpression.FunctionTable func_table = new MExpression.FunctionTable ();
+    MExpression.Domain domain = new MExpression.Domain (null);
 
-    MExpression.Defun (func_table, "insert", new MExpression.Evaluator (insert),
-                      1, 1, typeof (MExpression));
-    bindings.Add (MSymbol.Of ("X"), 10);
-    bindings.Add (Mpreedit, new MText ("PREEDIT TEXT"));
+    domain.Defun ("insert", insert, 1, 1, false);
+    domain.Bind (MSymbol.Of ("X"), 10);
+    domain.Bind (Mpreedit, new MText ("PREEDIT TEXT"));
 
+    MExpression expr;
     using (FileStream stream = new FileStream ("eval.txt", FileMode.Open))
       {
-       expr = new MExpression (new MPlist (stream), func_table);
+       expr = new MExpression (new MPlist (stream), domain);
       }
-    Console.WriteLine (bindings);
-    expr.PrettyPrint ();
-    Console.WriteLine ("\n  => " + expr.Eval (bindings, null));
-    Console.WriteLine (bindings);
+    Console.WriteLine (domain);
+    Console.Write (expr);
+    Console.WriteLine ("  => " + expr.Eval (domain));
+    Console.WriteLine (domain);
   }
 }