public MDatabaseInfo ()
{
+ Description = null;
Format = Schema = MSymbol.nil;
}
return ((major << 16) | (minor << 8) | release);
}
- public MDatabaseInfo (MPlist plist)
+ public MDatabaseInfo (MPlist plist) : this ()
{
- Format = MSymbol.nil;
if (plist.IsMText)
{
Format = MSymbol.plist;
private static Xex.Symbol name = "selector";
public static Xex.Symbol Name { get { return name; } }
- static new Dictionary<MSymbol, Selector> selectors;
+ static Dictionary<MSymbol, Selector> selectors;
static Selector ()
{
private int cache_idx;
private MPlist intervals;
private MPlist default_property;
- private bool read_only;
+ private bool read_only = false;
private static UTF8Encoding utf8 = new UTF8Encoding ();
$(RUNCS) -out:$@ -t:library ${XEX_SRC}
input.exe: input.cs M17NIM.dll XmlExpr.dll
- $(RUNCS) -r:M17N.dll -r:M17NCore -r:XmlExpr -r:M17NIM.dll $<
+ $(RUNCS) -r:M17N.dll -r:M17NCore.dll -r:XmlExpr.dll -r:M17NIM.dll $<
expr.exe: expr.cs
- $(RUNCS) -r:M17N.dll -r:M17NCore -r:M17NExpr $<
+ $(RUNCS) -r:M17N.dll -r:M17NCore.dll -r:M17NExpr.dll $<
xex.exe: xex.cs XmlExpr.dll
$(RUNCS) -r:XmlExpr.dll $<
%.exe: %.cs ${DLL}
- $(RUNCS) -r:M17N.dll -r:M17NCore $<
+ $(RUNCS) -r:M17N.dll -r:M17NCore.dll $<
clean:
rm -f $(DLL) *.exe
domain.functions[kv.Key] = kv.Value;
}
- public Variable GetVar (Symbol name)
+ public Variable GetVarCreate (Symbol name)
{
Variable vari;
return vari;
}
+ public Variable GetVar (Symbol name)
+ {
+ Variable vari;
+
+ if (! variables.TryGetValue (name, out vari))
+ return null;
+ return vari;
+ }
+
public override string ToString ()
{
string str = "<(functions";
public virtual bool Matches (TermValue other) { return Equals (other); }
public override abstract bool Equals (object obj);
public override abstract int GetHashCode ();
- public abstract string ToString (bool detail);
+ public virtual string ToString (bool detail) { return ToString (); }
}
private class Varref : TermValue
public override Term Eval (Domain domain)
{
if (vari == null || vari.domain != domain)
- vari = domain.GetVar (vname);
+ vari = domain.GetVarCreate (vname);
return vari.Value;
}
{
private static Symbol name = "funcall";
public static Symbol Name { get { return name; } }
+ private static Term[] null_args = new Term[0];
internal Function func;
internal Variable vari;
public Funcall (Function func, Variable vari, Term[] args)
{
+ if (args == null)
+ args = null_args;
int nargs = args.Length;
-
if (nargs < func.min_args
|| (func.max_args >= 0 && nargs > func.max_args))
throw new Error (Error.WrongArgument,
Function func = domain.GetFunc (fname);
Variable vari;
attr = node.Attributes[Qvname];
- vari = attr == null ? null : domain.GetVar (attr.Value);
+ vari = attr == null ? null : domain.GetVarCreate (attr.Value);
XmlNodeList nlist = node.ChildNodes;
int nargs = nlist.Count;
Term[] args = new Term[nargs];
intval = 0;
Function func = domain.GetFunc (fname);
- Variable vari = vname == Qnull ? null : domain.GetVar (vname);
+ Variable vari = vname == Qnull ? null : domain.GetVarCreate(vname);
Funcall funcall = new Funcall (func, vari, args);
if (func is Function.Macro)
{
return Parse (domain, node.FirstChild, null);
}
+ public static Term Eval (Domain domain, Term term)
+ {
+ return Eval (domain, new Term[] { term });
+ }
+
public static Term Eval (Domain domain, Term[] terms)
{
Term result = Zero;
+++ /dev/null
-using System;
-using System.Collections.Generic;
-using M17N.Core;
-
-public class Test
-{
- public static void Main()
- {
- String str = "a𝄀あc";
- MText mt = new MText (str), mt2;
-
- Console.WriteLine (str + mt);
- Console.WriteLine (mt + str);
- Console.WriteLine (mt + 'a');
- mt2 = mt.Dup ();
- mt2 += str;
- Console.WriteLine (mt2);
-
- Console.WriteLine ("{0}, Length={1}", mt, mt.Length);
- foreach (int c in mt)
- Console.WriteLine ("U+{0:X4}", c);
- Console.WriteLine (mt + new MText ("漢字"));
- Console.WriteLine (mt[2,4]);
- mt[0] = '日'; // == mt.Del (0, 1); mt.Ins (0, char)
- Console.WriteLine (mt);
- mt[1,3] = new MText ('本'); // == mt.Del (1, 3); mt.Ins (1, mt)
- Console.WriteLine (mt);
- mt[1,2] = null; // == mt.Del (1, 2)
- Console.WriteLine (mt);
- // explicit casting (MText -> string)
- string str2 = " " + (string) mt + (string) ((MText) "abc").Cat ('a');
- Console.WriteLine (str2);
- // implicit casting (string -> MText)
- mt2 = "abc";
- mt2.Cat ("def");
- mt2 += "ghi";
- Console.WriteLine (mt2);
- }
-}
foreach (int c in mt)
Console.WriteLine ("U+{0:X4}", c);
Console.WriteLine (mt + new MText ("漢字"));
+ Console.WriteLine (mt[2,4]);
+ mt[0] = '日'; // == mt.Del (0, 1); mt.Ins (0, char)
+ Console.WriteLine (mt);
+ mt[1,3] = new MText ('本'); // == mt.Del (1, 3); mt.Ins (1, mt)
+ Console.WriteLine (mt);
+ mt[1,2] = null; // == mt.Del (1, 2)
+ Console.WriteLine (mt);
+ // explicit casting (MText -> string)
+ string str2 = " " + (string) mt + (string) ((MText) "abc").Cat ('a');
+ Console.WriteLine (str2);
+ // implicit casting (string -> MText)
+ mt2 = "abc";
+ mt2.Cat ("def");
+ mt2 += "ghi";
+ Console.WriteLine (mt2);
}
}