From: handa Date: Mon, 9 Nov 2009 05:41:02 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=3cf61e3d98603a5fd08c1fe44e6d8d9aec02289e;p=m17n%2Fm17n-lib-cs.git *** empty log message *** --- diff --git a/XmlExpr.cs b/XmlExpr.cs index f877772..e37e7ea 100644 --- a/XmlExpr.cs +++ b/XmlExpr.cs @@ -321,8 +321,8 @@ namespace System.Xml return true; } - public StrType (Domain domain, Symbol name, string str, string desc, - string[] range) + public StrType (Domain domain, Symbol name, Str str, string desc, + string[] range) : base (domain, name, new Term (str), desc) { this.range = range; @@ -336,7 +336,7 @@ namespace System.Xml if (range == null) return true; Str str = val.Strval; - foreach (Str s in range) + foreach (string s in range) if (str.Equals (s)) return true; } @@ -914,7 +914,8 @@ namespace System.Xml } else { - vari = new Variable.StrType (this, name, str, desc, range); + vari = new Variable.StrType (this, name, new Str (str), desc, + range); variables[name] = vari; } return vari; @@ -1337,8 +1338,6 @@ namespace System.Xml private static Term Fnth (Domain domain, Variable vari, Term[] args) { - Term result; - if (args[1].IsStr) return new Term (args[1].Strval.Nth (args[0].Intval)); if (args[1].IsList) @@ -1880,15 +1879,19 @@ namespace System.Xml public Str Clone (Str str) { return new Str (str.str); } + public bool Equals (string str) { return this.str == str; } + public bool Equals (Str str) { return this.str == str.str; } public bool Matches (Str str) { - if (regex = null) + if (regex != null) regex = new Regex (this.str); return regex.IsMatch (str.str); } + public int Nth (int index) { return (int) str[index]; } + public void Insert (int index, Str str) { if (index < 0) @@ -1912,6 +1915,8 @@ namespace System.Xml this.str = this.str.Remove (from, to - from); regex = null; } + + public override string ToString () { return str; } } public struct Term @@ -1924,7 +1929,7 @@ namespace System.Xml // ... public Term (Symbol name) { intval = 0; objval = name; } // ... - public Term (string str) { intval = 0; objval = new StringBuilder (str); } + public Term (string str) { intval = 0; objval = new Str (str); } // ... public Term (List list) { intval = 0; objval = list; } // ERROR-MESSASGE @@ -1934,6 +1939,7 @@ namespace System.Xml objval = new ErrorTerm (name, message); } + public Term (Str str) { intval = 0; objval = str; } public Term (TermValue obj) { intval = 0; objval = obj; } // @@ -2019,14 +2025,14 @@ namespace System.Xml } public bool IsInt { get { return (objval == null); } } - public bool IsStr { get { return (objval is StringBuilder); } } + public bool IsStr { get { return (objval is Str); } } public bool IsSymbol { get { return (objval is Symbol); } } public bool IsList { get { return (objval is List); } } public bool IsError { get { return (objval is ErrorTerm); } } internal Term Eval (Domain domain) { - if (objval == null || objval is Symbol || objval is string + if (objval == null || objval is Symbol || objval is Str || objval is List) return this; try { @@ -2045,8 +2051,8 @@ namespace System.Xml { if (objval == null || objval is Symbol) return this; - if (objval is StringBuilder) - return new Term (((StringBuilder) objval).ToString ()); + if (objval is Str) + return new Term (((Str) objval).ToString ()); if (objval is List) { List list = new List (); @@ -2128,7 +2134,7 @@ namespace System.Xml str = "" + intval + ""; else if (objval is Symbol) str = "" + objval + ""; - else if (objval is string) + else if (objval is Str) str = "" + objval + ""; else if (objval is List) { diff --git a/xex.xml b/xex.xml index 3566ba7..008bd97 100644 --- a/xex.xml +++ b/xex.xml @@ -67,6 +67,6 @@ ?a?b 1 100 - 5 + 20