using System;
-using M17N.Core;
-public class Test
+namespace M17N
{
- static void symbol_test ()
+ public class M17N
{
- MSymbol sym1, sym2;
-
- Console.WriteLine ("### Symbol test ###");
- sym1 = new MSymbol ("abc");
- Console.WriteLine (sym1.ToString ());
- sym2 = new MSymbol ("abc");
- Console.WriteLine (sym2.ToString ());
- Console.WriteLine (sym1 == sym2 ? "OK" : "NO");
- sym1.Put (MSymbol.nil, MSymbol.t);
-
- MPlist p = new MPlist ();
-
- p.Put (MSymbol.t, sym1);
- p.Push (MSymbol.t, sym2);
-
- MPlist pp = new MPlist ();
- pp.Put (MSymbol.t, p);
- Console.WriteLine (pp.ToString ());
- Console.WriteLine (p.Get (MSymbol.t));
- }
-
- static void mtext_test ()
- {
- MText mt;
-
- Console.WriteLine ("### MText test ###");
- mt = new MText ("abc");
- Console.WriteLine (mt);
- Console.WriteLine (mt + new MText ("def"));
- mt += new MText ("ghi");
- Console.WriteLine (mt);
+ public static readonly int MajorVersion = 0;
+ public static readonly int MinorVersion = 0;
+ public static readonly int ReleaseNumber = 0;
+
+ public static bool debug = false;
+
+ public static void DebugPrint (string fmt, object arg)
+ {
+ if (debug)
+ Console.Write (fmt, arg);
+ }
+
+ public static void DebugPrint (string fmt, object arg1, object arg2)
+ {
+ if (debug)
+ Console.Write (fmt, arg1, arg2);
+ }
}
-
- static void mtext_property_test ()
- {
- Console.WriteLine ("### MTextProperty test ###");
- }
-
- public static void Main()
- {
- symbol_test ();
- mtext_test ();
- mtext_property_test ();
- }
-
}
using System.Text;
using System.Collections;
using System.Collections.Generic;
+using M17N;
using M17N.Core;
namespace M17N.Core
{
Console.Write ("(");
foreach (MPlist p in intervals)
- ((MInterval) p.Val).Dump ();
+ ((MInterval) p.Val).Dump (true);
Console.WriteLine (")");
}
{
MInterval interval = new MInterval (Key, mtext, To - pos, Stack);
- Console.Write ("divide-right({0}) at ", pos); DumpOne (false, true);
+ M17N.DebugPrint ("divide-right({0}) at ", pos); DumpOne (false, true);
To = pos;
if (Right != null)
{
{
MInterval interval = new MInterval (Key, mtext, pos - From, Stack);
- Console.Write ("divide-left({0}) at ", pos); DumpOne (false, true);
+ M17N.DebugPrint ("divide-left({0}) at ", pos); DumpOne (false, true);
From = pos;
if (Left != null)
{
public void Insert (int pos, MInterval interval)
{
update_from_to ();
- Console.Write ("insert({0}) at {1} in ", interval.Length, pos);
+ M17N.DebugPrint ("insert({0}) at {1} in ", interval.Length, pos);
DumpOne (false, true);
interval.set_mtext (mtext);
private void vacate_node (MInterval interval)
{
- Console.WriteLine ("vacate #{0} to #{1}", ID, interval.ID);
+ M17N.DebugPrint ("vacate #{0} to #{1}", ID, interval.ID);
if (interval != null)
interval.Parent = Parent;
if (Parent == null)
public void Delete (int start, int end)
{
update_from_to ();
- Console.Write ("delete({0} {1}) from ", start, end); DumpOne (false, true);
+ M17N.DebugPrint ("delete({0} {1}) from ", start, end); DumpOne (false, true);
if (start < From)
{
if (end <= From)
public void Push (int start, int end, MTextProperty prop)
{
update_from_to ();
- Console.Write ("push({0} {1}) at ", start, end); DumpOne (false, true);
+ M17N.DebugPrint ("push({0} {1}) at ", start, end); DumpOne (false, true);
if (start < From)
{
if (end <= From)
public void Pop (int start, int end)
{
update_from_to ();
- Console.Write ("pop({0} {1}) at ", start, end); DumpOne (false, true);
+ M17N.DebugPrint ("pop({0} {1}) at ", start, end); DumpOne (false, true);
if (start < From)
{
if (end <= From)
private void DumpOne (bool with_prop, bool newline)
{
- Console.Write ("#{0}({1} {2} {3}", ID, Length, From, To);
- if (with_prop)
- foreach (MPlist p in Stack)
- Console.Write (" " + p.Val);
- Console.Write (")");
- if (newline)
- Console.WriteLine ();
+ DumpOne (with_prop, newline, false);
}
- public void Dump ()
+ private void DumpOne (bool with_prop, bool newline, bool force)
{
- update_from_to ();
+ if (force || M17N.debug)
+ {
+ Console.Write ("#{0}({1} {2} {3}", ID, Length, From, To);
+ if (with_prop)
+ foreach (MPlist p in Stack)
+ Console.Write (" " + p.Val);
+ Console.Write (")");
+ if (newline)
+ Console.WriteLine ();
+ }
+ }
- if (Left != null)
- Left.Dump ();
- if (From > 0)
- Console.Write (" ");
- DumpOne (true, false);
- if (Right != null)
- Right.Dump ();
+ public void Dump () { Dump (false); }
+
+
+ public void Dump (bool force)
+ {
+ if (force || M17N.debug)
+ {
+ update_from_to ();
+
+ if (Left != null)
+ Left.Dump (force);
+ if (From > 0)
+ Console.Write (" ");
+ DumpOne (true, false, force);
+ if (Right != null)
+ Right.Dump (force);
+ }
}
}
+M17N_SRC = M17N.cs
CORE_SRC = MSymbol.cs MPlist.cs MText.cs
CS=gmcs
-all: M17N.exe symbol.exe plist.exe mtext.exe textprop.exe
+all: M17N.dll symbol.exe plist.exe mtext.exe textprop.exe
-M17NCore.dll: ${CORE_SRC}
- $(CS) /out:$@ /t:library ${CORE_SRC}
+M17N.dll: ${M17N_SRC}
+ $(CS) /out:$@ /t:library ${M17N_SRC}
-M17N.exe: M17N.cs M17NCore.dll
- $(CS) /r:M17NCore M17N.cs
+M17NCore.dll: M17N.dll ${CORE_SRC}
+ $(CS) /out:$@ /t:library /r:M17N.dll ${CORE_SRC}
mtext.exe: mtext.cs M17NCore.dll
$(CS) -codepage:65001 /r:M17NCore mtext.cs
symbol.exe: symbol.cs M17NCore.dll
- $(CS) -codepage:65001 /r:M17NCore symbol.cs
+ $(CS) -codepage:65001 /r:M17N.dll /r:M17NCore symbol.cs
plist.exe: plist.cs M17NCore.dll
$(CS) -codepage:65001 /r:M17NCore plist.cs
textprop.exe: textprop.cs M17NCore.dll
- $(CS) -codepage:65001 /r:M17NCore textprop.cs
+ $(CS) -codepage:65001 /r:M17N.dll /r:M17NCore textprop.cs
clean:
rm -f *.dll *.exe
using System;
using System.Collections.Generic;
+using M17N;
using M17N.Core;
public class Test
MSymbol sym2 = new MSymbol ("symbol");
MSymbol sym3 = new MSymbol ("another sym:bol");
+ Console.WriteLine ("version {0}-{1}-{2}", M17N.M17N.MajorVersion,
+ M17N.M17N.MinorVersion, M17N.M17N.ReleaseNumber);
+
Console.WriteLine ("sym1 = {0}", sym1);
Console.WriteLine ("sym2 = {0}", sym2);
Console.WriteLine ("sym3 = {0}", sym3);
using System;
using System.Collections.Generic;
+using M17N;
using M17N.Core;
public class Test
MTextProperty prop1 = new MTextProperty (sym, "test1");
MTextProperty prop2 = new MTextProperty (sym, "test2");
+ M17N.M17N.debug = true;
+
mt.PushProp (2, 5, prop1);
mt.DumpProp ();
mt.PushProp (3, 6, prop2);