{
private int[] range;
- public bool IsSubrange (int[] r)
- {
- if (range == null)
- return true;
- for (int i = 0; i < r.Length; i += 2)
- {
- int j;
- for (j = 0; j < range.Length; j += 2)
- if (range[j] <= r[i] && range[j + 1] >= r[i + 1])
- break;
- if (j >= range.Length)
- return false;
- }
- return true;
- }
-
public IntType (Domain domain, Symbol name, int n, string desc,
int[] range)
: base (domain, name, new Term (n), desc)
{
private string[] range;
- public bool IsSubrange (string[] r)
- {
- if (range == null)
- return true;
- for (int i = 0; i < r.Length; i++)
- {
- int j;
- for (j = 0; j < range.Length; j++)
- if (range[j] == r[i])
- break;
- if (j >= range.Length)
- return false;
- }
- return true;
- }
-
public StrType (Domain domain, Symbol name, Str str, string desc,
string[] range)
: base (domain, name, new Term (str), desc)
{
public Symbol[] range;
- public bool IsSubrange (Symbol[] r)
- {
- if (range == null)
- return true;
- for (int i = 0; i < r.Length; i++)
- {
- int j;
- for (j = 0; j < range.Length; j++)
- if (range[j] == r[i])
- break;
- if (j >= range.Length)
- return false;
- }
- return true;
- }
-
public SymType (Domain domain, Symbol name, Symbol sym, string desc,
Symbol[] range)
: base (domain, name, new Term (sym), desc)
return vari;
}
- public Variable DefvarInt (Symbol name, int n, string desc, int[] range)
+ public Variable Defvar (Symbol name, int n, string desc, int[] range)
{
Variable vari;
throw new Error (Error.VariableTypeConflict,
"Not an integer variable: {0}", name);
if (range != null)
- {
- if (! intvari.IsSubrange (range))
- throw new Error (Error.VariableRangeConflict,
- "Conflicting variable range: {0}", name);
- intvari.Range = range;;
- }
+ intvari.Range = range;;
if (desc != null)
intvari.Description = desc;
}
return vari;
}
- public Variable DefvarStr (Symbol name, string str, string desc,
- string[] range)
+ public Variable Defvar (Symbol name, Symbol sym, string desc,
+ Symbol[] range)
{
Variable vari;
if (variables.TryGetValue (name, out vari))
{
- Variable.StrType strvari = vari as Variable.StrType;
- if (strvari == null)
+ Variable.SymType symvari = vari as Variable.SymType;
+ if (symvari == null)
throw new Error (Error.VariableTypeConflict,
- "Not a string variable: {0}", name);
+ "Not a symbol variable: {0}", name);
if (range != null)
- {
- if (! strvari.IsSubrange (range))
- throw new Error (Error.VariableRangeConflict,
- "Conflicting variable range: {0}", name);
- strvari.Range = range;
- }
+ symvari.Range = range;
if (desc != null)
- strvari.Description = desc;
+ symvari.Description = desc;
}
else
{
- vari = new Variable.StrType (this, name, new Str (str), desc,
- range);
+ vari = new Variable.SymType (this, name, sym, desc, range);
variables[name] = vari;
}
return vari;
}
- public Variable DefvarSym (Symbol name, Symbol sym, string desc,
- Symbol[] range)
+ public Variable Defvar (Symbol name, string str, string desc,
+ string[] range)
{
Variable vari;
if (variables.TryGetValue (name, out vari))
{
- Variable.SymType symvari = vari as Variable.SymType;
- if (symvari == null)
+ Variable.StrType strvari = vari as Variable.StrType;
+ if (strvari == null)
throw new Error (Error.VariableTypeConflict,
- "Not a symbol variable: {0}", name);
+ "Not a string variable: {0}", name);
if (range != null)
- {
- if (! symvari.IsSubrange (range))
- throw new Error (Error.VariableRangeConflict,
- "Conflicting variable range: {0}", name);
- symvari.Range = range;
- }
+ strvari.Range = range;
if (desc != null)
- symvari.Description = desc;
+ strvari.Description = desc;
}
else
{
- vari = new Variable.SymType (this, name, sym, desc, range);
+ vari = new Variable.StrType (this, name, new Str (str), desc,
+ range);
variables[name] = vari;
}
return vari;
{
Term result = arg.Eval (domain);
if (domain.Thrown ())
- result;
+ return result;
if (! result.IsTrue)
return Zero;
}
{
Term result = args[0].Eval (domain);
- if (domain.Thrown)
+ if (domain.Thrown ())
return result;
if (result.IsTrue)
return args[1].Eval (domain);
{
Term result = args[0].Eval (domain);
- if (domain.Thrown)
+ if (domain.Thrown ())
return result;
if (! result.IsTrue)
return Zero;
for (int i = 1; i < args.Length; i++)
{
result = args[i].Eval (domain);
- if (domain.Thrown)
+ if (domain.Thrown ())
return result;
}
return result;
/// <summary>Create a term of a specific value</summary>
/// <param name='val'>Value of the term.</param>
/// <returns>A term.</returns>
- /// <remarks>Create a term whose value is <paramref name="val">.
+ /// <remarks>Create a term whose value is <paramref name="val"/>.
/// It is evaluated to a term that is returned by "Eval" method
- /// of <paramref name="val">.</remarks>
+ /// of <paramref name="val"/>.</remarks>
public Term (TermValue val) { intval = 0; objval = val; }
internal Term (Str str) { intval = 0; objval = str; }
/// function as arguments.</param>
/// <returns>A funcall term.</returns>
/// <remarks>Create a funcall term that is evaluated to a term
- /// returned by the function <paramref name="fname"> when called
- /// with <paramref name="args">.<remarks>
+ /// returned by the function <paramref name="fname"/> when called
+ /// with <paramref name="args"/>.</remarks>
public Term (Domain domain, Symbol fname, Term[] args)
: this (domain, fname, Qnull, args) { }
}
}
}
- vari = domain.DefvarInt (vname, val, desc, range);
+ vari = domain.Defvar (vname, val, desc, range);
}
else if (type == Qstring)
{
for (int i = 0; i < nranges; i++)
range[i] = range_list[i].FirstChild.InnerText;
}
- vari = domain.DefvarStr (vname, node.InnerText, desc, range);
+ vari = domain.Defvar (vname, node.InnerText, desc, range);
}
else if (type == Qsymbol)
{
for (int i = 0; i < nranges; i++)
range[i] = range_list[i].FirstChild.InnerText;
}
- vari = domain.DefvarSym (vname, (Symbol) node.InnerText, desc,
+ vari = domain.Defvar (vname, (Symbol) node.InnerText, desc,
range);
}
else