using System;
+using System.Collections.Generic;
using System.IO;
using M17N;
using M17N.Core;
public class Test
{
+ static MSymbol Mpreedit = MSymbol.Of ("preedit");
+
+ public static object insert (MExpression[] args, MExpression.Domain domain)
+ {
+ MText preedit = (MText) domain.GetValue (Mpreedit);
+ object val = args[0].Val;
+
+ if (val is int)
+ preedit.Cat ((int) val);
+ else
+ preedit.Cat ((MText) val);
+ return val;
+ }
+
public static void Main()
{
- MExpression expr = new MExpression ();
+ MExpression.Domain domain = new MExpression.Domain (null);
+
+ 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))
{
- MPlist plist = new MPlist (stream);
-
- foreach (MPlist p in plist)
- expr.Add (p);
+ expr = new MExpression (new MPlist (stream), domain);
}
- Console.WriteLine (expr+"="+expr.Eval (null));
+ Console.WriteLine (domain);
+ Console.Write (expr);
+ Console.WriteLine (" => " + expr.Eval (domain));
+ Console.WriteLine (domain);
}
}