From: handa Date: Thu, 6 Aug 2009 02:49:03 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e7d0c9359879ed58eb5d50bd0fec86dd0c6660a;p=m17n%2Fm17n-lib-cs.git *** empty log message *** --- diff --git a/MExpression.cs b/MExpression.cs index f482088..2acb104 100644 --- a/MExpression.cs +++ b/MExpression.cs @@ -15,13 +15,19 @@ namespace M17N.Core internal delegate void PrettyPrinter (Function func, string indent, object[] args); + public enum ArgType + { + FIXED, + MANY, + UNEVALLED, + }; + internal class Function { internal readonly MSymbol name; internal readonly Evaluator eval; internal readonly int min_arg; - internal readonly int max_arg; - internal readonly Type[] arg_types; + internal readonly ArgType arg_type; internal object[] data; public PrettyPrinter pp; @@ -31,14 +37,13 @@ namespace M17N.Core internal static Function literal, varref, block, defun; public Function (MSymbol name, Evaluator eval, - int min_arg, int max_arg, params Type[] arg_types) + int min_arg, enum ArgType arg_type) { this.name = name; this.eval = eval; this.min_arg = min_arg; - this.max_arg = max_arg; - this.arg_types = (Type []) arg_types.Clone (); - if (arg_types.Length == 2 && arg_types[0] == typeof (MSymbol)) + this.arg_type = arg_type; + if (min_arg == 2 && arg_type = ArgType.FIXED) pp = set_pretty_printer; else pp = default_pretty_printer; @@ -650,10 +655,10 @@ namespace M17N.Core private static FunctionTable basic_table = new FunctionTable (); public static void Defun (FunctionTable table, string name, - Evaluator evaluator, int min_arg, int max_arg, - params Type[] arg_types) + Evaluator evaluator, int min_arg, + enum ArgType arg_type) { - Function func = Defun (name, evaluator, min_arg, max_arg, arg_types); + Function func = Defun (name, evaluator, min_arg, arg_type); table.table[func.name] = func; } @@ -669,20 +674,18 @@ namespace M17N.Core } private static Function Defun (string name, Evaluator evaluator, - int min_arg, int max_arg, - params Type[] arg_types) + int min_arg, enum ArgType arg_type) { MSymbol sym = MSymbol.Of (name); - Function func = new Function (sym, evaluator, min_arg, max_arg, - arg_types); + Function func = new Function (sym, evaluator, min_arg, arg_type); basic_table.table[sym] = func; return func; } private static Function Defun (string name, Evaluator evaluator, - int min_arg, int max_arg) + int min_arg, enum ArgType arg_type) { - return Defun (name, evaluator, min_arg, max_arg, typeof (MExpression)); + return Defun (name, evaluator, min_arg, arg_type, typeof (MExpression)); } private static Function Find (MSymbol name, FunctionTable table) @@ -699,7 +702,7 @@ namespace M17N.Core return func; } - private void invalid_expression (object o) + private static void invalid_expression (object o) { throw new Exception ("Invalid expresssion: " + o); } @@ -724,7 +727,8 @@ namespace M17N.Core this.args = (object[]) args.Clone (); } - private MExpression[] expression_list (MPlist plist, FunctionTable table) + private static MExpression[] expression_list (MPlist plist, + FunctionTable table) { int len = plist.Count; MExpression[] expr_list = new MExpression[len]; diff --git a/MInputMethod.cs b/MInputMethod.cs index 78f91ff..93c6591 100644 --- a/MInputMethod.cs +++ b/MInputMethod.cs @@ -394,47 +394,6 @@ namespace M17N.Input } } - private static void regulalize_command (MPlist plist) - { - if (plist.IsSymbol) - { - MSymbol sym = plist.Symbol; - - if (sym == MSymbol.Of ("add")) - plist.val = MSymbol.Of ("+="); - regulalize_actions (plist.next); - } - } - - private static void regulalize_actions (MPlist plist) - { - for (; ! plist.IsEmpty; plist = plist.next) - { - if (plist.IsMText) - { - MText mt = plist.Text; - MPlist p = new MPlist (); - p.Add (MSymbol.symbol, Minsert); - p.Add (MSymbol.mtext, mt); - plist.key = MSymbol.plist; - plist.val = p; - } - else if (plist.IsInteger) - { - int c = plist.Integer; - MPlist p = new MPlist (); - p.Add (MSymbol.symbol, Minsert); - p.Add (MSymbol.integer, c); - plist.key = MSymbol.plist; - plist.val = p; - } - else if (plist.IsPlist) - { - - } - } - } - private void parse_maps (MPlist plist) { for (; ! plist.IsEmpty; plist = plist.next) @@ -465,7 +424,6 @@ namespace M17N.Input p = p.next; if (p.IsEmpty) continue; - regulalize_actions (p); MExpression expr = new MExpression (p, local_table); map.Add (keys, 0, expr); } @@ -503,10 +461,7 @@ namespace M17N.Input continue; MSymbol map_name = p.Symbol; p = p.next; - if (! p.IsEmpty) - regulalize_actions (p); - state.branches[map_name] - = new MExpression (p, local_table); + state.branches[map_name] = new MExpression (p, local_table); } } }