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;
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;
}
}
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;
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)
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)
this.str = this.str.Remove (from, to - from);
regex = null;
}
+
+ public override string ToString () { return str; }
}
public struct Term
// <symbol>...</symbol>
public Term (Symbol name) { intval = 0; objval = name; }
// <string>...</string>
- public Term (string str) { intval = 0; objval = new StringBuilder (str); }
+ public Term (string str) { intval = 0; objval = new Str (str); }
// <list>...</list>
public Term (List<Term> list) { intval = 0; objval = list; }
// <error ename="ERROR-NAME">ERROR-MESSASGE</error>
objval = new ErrorTerm (name, message);
}
+ public Term (Str str) { intval = 0; objval = str; }
public Term (TermValue obj) { intval = 0; objval = obj; }
// <varref vname="VNAME"/>
}
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<Term>); } }
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<Term>)
return this;
try {
{
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<Term>)
{
List<Term> list = new List<Term> ();
str = "<integer>" + intval + "</integer>";
else if (objval is Symbol)
str = "<symbol>" + objval + "</symbol>";
- else if (objval is string)
+ else if (objval is Str)
str = "<string>" + objval + "</string>";
else if (objval is List<Term>)
{