From d514dc2573b9efceca395594cefa93c6446f961d Mon Sep 17 00:00:00 2001 From: handa Date: Wed, 21 Oct 2009 01:19:44 +0000 Subject: [PATCH] *** empty log message *** --- MInputMethod.cs | 4 ++- Makefile | 2 +- XmlExpr.cs | 100 +++++++++++++++++++++++++++++++++---------------------- input.cs | 41 +++++++++++++++++------ 4 files changed, 95 insertions(+), 52 deletions(-) diff --git a/MInputMethod.cs b/MInputMethod.cs index a0a1e76..9618135 100644 --- a/MInputMethod.cs +++ b/MInputMethod.cs @@ -2295,7 +2295,7 @@ namespace M17N.Input Xex.Term[] args) { return new Xex.Term (((Context) domain.context).GetSurroundingText == null - ? 0 : 1); + ? -2 : -1); } public override string ToString () @@ -2727,6 +2727,8 @@ namespace M17N.Input private bool handle_key () { + Console.WriteLine ("{0}:key='{1}'", state.name, + new MText (keys.keyseq[key_head].ToChar ())); Keymap sub = keymap.Lookup (keys, ref key_head); if (sub != keymap) diff --git a/Makefile b/Makefile index aa7e4eb..c2b2490 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CS=gmcs +CS=gmcs2 DEBUG_FLAG = -debug CODEPAGE = 65001 diff --git a/XmlExpr.cs b/XmlExpr.cs index 5251080..a82abde 100644 --- a/XmlExpr.cs +++ b/XmlExpr.cs @@ -394,8 +394,6 @@ namespace System.Xml public virtual void Reset () { val = Zero; } - public virtual string Description { get { return null; } } - public Term Value { get { return val; } @@ -435,7 +433,10 @@ namespace System.Xml public override void Reset () { val = default_val; } - public override string Description { get { return desc; } } + public string Description { + get { return desc; } + set { desc = value; } + } } public class Int : Typed @@ -924,7 +925,6 @@ namespace System.Xml vari = new Variable (this, name, Zero); variables[name] = vari; } - Console.WriteLine (vari); return vari; } @@ -951,15 +951,20 @@ namespace System.Xml Variable.Int intvari = vari as Variable.Int; if (intvari == null) throw new Exception ("Variable type mismatch: " + name); - if (range == null) - range = intvari.Range; - else if (! intvari.IsSubrange (range)) - throw new Exception ("Variable range mismatch: " + name); - if (desc == null) - desc = vari.Description; + if (range != null) + { + if (! intvari.IsSubrange (range)) + throw new Exception ("Variable range mismatch: " + name); + intvari.Range = range;; + } + if (desc != null) + intvari.Description = desc; + } + else + { + vari = new Variable.Int (this, name, n, desc, range); + variables[name] = vari; } - vari = new Variable.Int (this, name, n, desc, range); - variables[name] = vari; return vari; } @@ -973,15 +978,20 @@ namespace System.Xml Variable.Str strvari = vari as Variable.Str; if (strvari == null) throw new Exception ("Variable type mismatch: " + name); - if (range == null) - range = strvari.Range; - else if (! strvari.IsSubrange (range)) - throw new Exception ("Variable range mismatch: " + name); - if (desc == null) - desc = vari.Description; + if (range != null) + { + if (! strvari.IsSubrange (range)) + throw new Exception ("Variable range mismatch: " + name); + strvari.Range = range; + } + if (desc != null) + strvari.Description = desc; + } + else + { + vari = new Variable.Str (this, name, str, desc, range); + variables[name] = vari; } - vari = new Variable.Str (this, name, str, desc, range); - variables[name] = vari; return vari; } @@ -995,15 +1005,20 @@ namespace System.Xml Variable.Sym symvari = vari as Variable.Sym; if (symvari == null) throw new Exception ("Variable type mismatch: " + name); - if (range == null) - range = symvari.Range; - else if (! symvari.IsSubrange (range)) - throw new Exception ("Variable range mismatch: " + name); - if (desc == null) - desc = vari.Description; + if (range != null) + { + if (! symvari.IsSubrange (range)) + throw new Exception ("Variable range mismatch: " + name); + symvari.Range = range; + } + if (desc != null) + symvari.Description = desc; + } + else + { + vari = new Variable.Sym (this, name, sym, desc, range); + variables[name] = vari; } - vari = new Variable.Sym (this, name, sym, desc, range); - variables[name] = vari; return vari; } @@ -1060,17 +1075,13 @@ namespace System.Xml return str; } - internal void DebugWrite (bool head, string fmt, params string[] arg) + internal void DebugWrite (string fmt, params string[] arg) { if (debug_depth > depth) { - if (head) - { - Console.WriteLine (); - for (int i = 0; i < depth; i++) - Console.Write (" "); - } - Console.Write (fmt, arg); + for (int i = 0; i < depth; i++) + Console.Write (" "); + Console.WriteLine (fmt, arg); } } @@ -1554,7 +1565,13 @@ namespace System.Xml if (result.IsTrue) { for (int i = 1; i < list.Count; i++) - result = list[i].Eval (domain); + { + domain.depth++; + result = list[i].Eval (domain); + domain.depth--; + if (domain.Thrown) + return result; + } return result; } } @@ -1715,11 +1732,11 @@ namespace System.Xml public override Term Eval (Domain domain) { - domain.DebugWrite (true, ToString ()); + domain.DebugWrite (ToString ()); domain.depth++; Term result = func.Call (domain, vari, args); domain.depth--; - domain.DebugWrite (true, " ==> {0}", result.ToString ()); + domain.DebugWrite ("=> {0}", result.ToString ()); return result; } @@ -1737,7 +1754,10 @@ namespace System.Xml return str + "/>"; str += ">"; if (func is Function.SpecialForm) - str += String.Format ("({0})...", args.Length); + { + for (int i = 0; i < args.Length; i++) + str += "."; + } else foreach (Term e in args) str += e; diff --git a/input.cs b/input.cs index 3e87235..ca3f7e4 100644 --- a/input.cs +++ b/input.cs @@ -12,15 +12,27 @@ public class Test public static void Main(string[] args) { // M17n.debug = true; - // Xex.DebugDepth = 10; int argc = 0; - if (args[0] == "xml") + string appdir = "/usr/local/share/m17n"; + int debug_depth = 0; + + while (argc < args.Length && args[argc][0] == '-') { - MDatabase.ApplicationDir = "/usr/local/share/m17n-xml"; + if (args[argc] == "-debug") + debug_depth = 10; + else if (args[argc] == "-xml") + appdir = "/usr/local/share/m17n-xml"; argc++; } - else - MDatabase.ApplicationDir = "/usr/local/share/m17n"; + if (argc + 2 >= args.Length) + { + Console.WriteLine ("Usage: mono [--debug] input.exe" + + " [-debug] [-xml] LANG NAME KEY-SEQUECE"); + return; + } + + Xex.DebugDepth = debug_depth; + MDatabase.ApplicationDir = appdir; MInputMethod im = MInputMethod.Find (args[argc], args[argc + 1]); MText mt = new MText (); MInputMethod.Session session = new MInputMethod.Session (im, mt, 0); @@ -31,11 +43,20 @@ public class Test MInputMethod.Key key = new MInputMethod.Key (str[i]); session.HandleKey (key); int pos = session.CurrentPos; - Console.WriteLine ("{0} -> \"{1}|{2}|{3}\"", - str[i, i + 1], - mt[0, pos], - session.Preedit, - mt[pos, mt.Length]); + MText head = mt[0, pos]; + MText preedit = session.Preedit; + MText tail = mt[pos, mt.Length]; + Console.Write ("{0} -> \"{1}|{2}|{3}\" (", + str[i, i + 1], head, preedit, tail); + for (int j = 0; j < head.Length; j++) + Console.Write ("{0}U+{1:X4}", j == 0 ? "(" : " ", head[j]); + Console.Write ("|"); + for (int j = 0; j < preedit.Length; j++) + Console.Write ("{0}U+{1:X4}", j == 0 ? "" : " ", preedit[j]); + Console.Write ("|"); + for (int j = 0; j < tail.Length; j++) + Console.Write ("{0}U+{1:X4}", j == 0 ? "" : " ", tail[j]); + Console.WriteLine (")"); } } } -- 1.7.10.4