X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=expr.cs;h=3ad5f767f9de40dbea4c9bf2990460e24e11e2c9;hb=139bdc3719eee81aa203e40f40c612fb799b8ed4;hp=1d4af267cfab4e6cbed2d4e20944dafc08051043;hpb=04d20a4293c7fb0db73511e9e6009cf4d4d2a9bd;p=m17n%2Fm17n-lib-cs.git diff --git a/expr.cs b/expr.cs index 1d4af26..3ad5f76 100644 --- a/expr.cs +++ b/expr.cs @@ -1,11 +1,41 @@ 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.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)) + { + expr = new MExpression (new MPlist (stream), domain); + } + Console.WriteLine (domain); + Console.Write (expr); + Console.WriteLine (" => " + expr.Eval (domain)); + Console.WriteLine (domain); } }