From 093302f7036acd5f1782a4867b87ee8df1972479 Mon Sep 17 00:00:00 2001 From: handa Date: Tue, 10 Nov 2009 02:09:18 +0000 Subject: [PATCH] *** empty log message *** --- MInputMethod.cs | 110 ++++++++++++++++++------------------------------------- 1 file changed, 35 insertions(+), 75 deletions(-) diff --git a/MInputMethod.cs b/MInputMethod.cs index ebb8277..8b2e7f8 100644 --- a/MInputMethod.cs +++ b/MInputMethod.cs @@ -396,7 +396,7 @@ namespace M17N.Input if (list[i].IsInt) keyseq.Add (new Key (list[i].Intval)); else if (list[i].IsStr) - keyseq.Add (new Key (list[i].Strval)); + keyseq.Add (new Key (list[i].Strval.ToString ())); else if (list[i].IsSymbol) keyseq.Add (new Key ((string) list[i].Symval)); else @@ -406,8 +406,9 @@ namespace M17N.Input public static Xex.TermValue Parser (Xex.Domain domain, XmlNode node) { - Xex.Term term = new Xex.Term (domain, node.FirstChild).Eval (domain); - return (term.IsStr ? new KeySeq ((MText) term.Strval) + Xex.Term term = Xex.Parse (domain, node.FirstChild); + term = Xex.Eval (domain, term); + return (term.IsStr ? new KeySeq ((MText) term.Strval.ToString ()) : new KeySeq (term.Listval)); } @@ -541,7 +542,7 @@ namespace M17N.Input object[] parameters = new object[2]; public PluginMethod (Plugin plugin, string name) - : base ((Xex.Symbol) name, 0, -1) + : base ((Xex.Symbol) name, false, 0, -1) { this.plugin = plugin; } @@ -552,8 +553,8 @@ namespace M17N.Input args = (Xex.Term[]) args.Clone (); for (int i = 0; i < args.Length; i++) { - args[i] = args[i].Eval (domain); - if (domain.Thrown) + args[i] = Xex.Eval (domain, args[i]); + if (domain.Thrown ()) return args[i]; } if (method_info == null) @@ -753,13 +754,13 @@ namespace M17N.Input { Index = index; if (term.IsStr) - Data = (MText) term.Strval; + Data = (MText) term.Strval.ToString (); else { MPlist plist = new MPlist (); MPlist p = plist; foreach (Xex.Term t in term.Listval) - p = p.Add (MSymbol.mtext, (MText) t.Strval); + p = p.Add (MSymbol.mtext, (MText) t.Strval.ToString ()); Data = plist; } } @@ -1121,7 +1122,7 @@ namespace M17N.Input public bool Run (Xex.Domain domain) { - Xex.Term result = action.Eval (domain); + Xex.Term result = Xex.Eval (domain, action); if (result.IsError) { ((Context) domain.context).Error = result.ToString (); @@ -1240,16 +1241,16 @@ namespace M17N.Input for (node = node.FirstChild; node != null; node = node.NextSibling) { if (node.Name == Qstate_hook) - enter_actions = Xex.ParseTerms (im.domain, node.FirstChild); + enter_actions = Xex.Parse (im.domain, node.FirstChild, null); else if (node.Name == Qcatch_all_branch) - fallback_actions = Xex.ParseTerms (im.domain, node.FirstChild); + fallback_actions = Xex.Parse (im.domain, node.FirstChild, null); else if (node.Name == Qbranch) { MSymbol mapname = node.Attributes[Qmname].Value; Map map; if (im.maps.TryGetValue (mapname, out map)) - keymap.AddMap (map, Xex.ParseTerms (im.domain, - node.FirstChild)); + keymap.AddMap (map, Xex.Parse (im.domain, node.FirstChild, + null)); else throw new Exception ("Unknown map: " + mapname); } @@ -1387,7 +1388,7 @@ namespace M17N.Input variables = new Xex.Variable[var_names.Length]; int i = 0; foreach (Xex.Symbol name in var_names) - variables[i++] = domain.GetVar (name, false); + variables[i++] = domain.GetVar (name); } commands = this.commands; return true; @@ -1618,7 +1619,7 @@ namespace M17N.Input if (! im_global.Open ()) throw new Exception ("Failed to load global"); } - return im_global.domain.GetVar (name, false); + return im_global.domain.GetVar (name); } private void parse_variables (MPlist plist) @@ -1726,7 +1727,7 @@ namespace M17N.Input Xex.Variable vari = get_global_var (name); if (vari != null) domain.Defvar (vari); - domain.Defvar (node_list[i]); + Xex.Parse (domain, node_list[i]); var_names[i] = name; } } @@ -1814,17 +1815,13 @@ namespace M17N.Input private void parse_macros (XmlNode node) { for (XmlNode nn = node.FirstChild; nn != null; nn = nn.NextSibling) - if (nn.NodeType == XmlNodeType.Element) - { - if (nn.Name == Xex.Qdefun) - domain.Defun (nn, true); - else if (nn.Name == Qxi_include) + if (nn.NodeType == XmlNodeType.Element && nn.Name == Qxi_include) + { parse_include (nn); - } - for (XmlNode nn = node.FirstChild; nn != null; nn = nn.NextSibling) - if (nn.NodeType == XmlNodeType.Element - && nn.Name == Xex.Qdefun) - domain.Defun (nn, false); + nn = nn.PreviousSibling; + node.RemoveChild (nn.NextSibling); + } + Xex.Parse (domain, node.FirstChild, null); } private void parse_maps (XmlNode node) @@ -1844,7 +1841,8 @@ namespace M17N.Input if (n.Name != Qkeyseq) continue; KeySeq keyseq = (KeySeq) KeySeq.Parser (domain, n); - Xex.Term[] actions = Xex.ParseTerms (domain, n.NextSibling); + n = n.NextSibling; + Xex.Term[] actions = Xex.Parse (domain, n, null); map.entries.Add (new Map.Entry (domain, keyseq, actions)); } } @@ -2132,44 +2130,6 @@ namespace M17N.Input return terms; } - private Xex.Variable[] parse_args (Xex.Domain domain, Xex.Symbol[] args) - { - int nfixed = 0; - int noptional = 0; - int nrest = 0; - - if (args.Length > 0) - { - int i = 0; - for (i = 0; i < args.Length; i++, nfixed++) - if (args[i] == Qoptional || args[i] == Qrest) - break; - if (i < args.Length) - { - if (args[i] == Qoptional) - { - for (i++; i < args.Length; i++, noptional++) - if (args[i] == Qrest) - break; - if (i < args.Length) - nrest = 1; - } - } - min_args = nfixed; - max_args = nfixed + noptional + nrest; - this.args = new Variable[max_args]; - int j; - for (i = j = 0; j < this.args.Length; i++) - if (args[i] != Qoptional || args[i] != Qrest) - this.args[j++] = domain.Defvar (args[i]); - } - else - { - min_args = max_args = 0; - } - with_var = false; - } - private void parse_macros (MPlist plist) { for (MPlist pl = plist; ! pl.IsEmpty; pl = pl.next) @@ -2178,17 +2138,16 @@ namespace M17N.Input MPlist p = pl.Plist; if (! p.IsSymbol) continue; - domain.Defun ((Xex.Symbol) p.Symbol.Name, null, null, true); + domain.Defun ((Xex.Symbol) p.Symbol.Name, 0, 0, null, null); } for (MPlist pl = plist; ! pl.IsEmpty; pl = pl.next) if (pl.IsPlist) { MPlist p = pl.Plist; - if (! p.IsSymbol) continue; - domain.Defun ((Xex.Symbol) p.Symbol.Name, null, - parse_actions (p.next, false), false); + domain.Defun ((Xex.Symbol) p.Symbol.Name, 0, 0, null, + parse_actions (p.next, false)); } } @@ -2229,7 +2188,8 @@ namespace M17N.Input if (args[0].IsInt) ((Context) domain.context).insert (args[0].Intval, null); else - ((Context) domain.context).insert ((MText) args[0].Strval, null); + ((Context) domain.context).insert ((MText) args[0].Strval.ToString (), + null); return args[0]; } @@ -2238,8 +2198,8 @@ namespace M17N.Input Xex.Term[] args) { Context ic = (Context) domain.context; - Xex.Variable v = ic.domain.GetVar (Qcandidates_group_size, false); - int column = (v == null ? 0 : v.Value.Intval); + Xex.Variable v = ic.domain.GetVar (Qcandidates_group_size); + int column = v == null ? 0 : v.Value.Intval; Candidates candidates = new Candidates (args, column); object candidate = candidates.Current; @@ -2341,7 +2301,7 @@ namespace M17N.Input if (args[0].IsInt) ic.pushback (args[0].Intval); else if (args[0].IsStr) - ic.pushback (new KeySeq (args[0].Strval)); + ic.pushback (new KeySeq (args[0].Strval.ToString ())); else ic.pushback ((KeySeq) args[0].Objval); return args[0]; @@ -2536,7 +2496,7 @@ namespace M17N.Input catch_args[0] = Tcatch_tag; catch_args[1]= new Xex.Term (domain, Qprogn, actions); Xex.Term term = new Xex.Term (domain, Qcatch, catch_args); - term = term.Eval (domain); + term = Xex.Eval (domain, term); return (! term.IsSymbol || term.Symval != Tcatch_tag.Symval); } @@ -2797,7 +2757,7 @@ namespace M17N.Input { if (im.load_status != LoadStatus.Full && ! im.Open ()) - throw new Exception ("Openging " + im.tag + " failed"); + throw new Exception ("Opening " + im.tag + " failed"); this.im = im; domain = new Xex.Domain ("context", im.domain, this); initial_state = (State) im.states.Val; -- 1.7.10.4