public void DumpPropNested ()
{
- Console.Write ("(");
foreach (MPlist p in intervals)
((MInterval) p.Val).DumpNested (true);
- Console.WriteLine (")");
}
private class MInterval
if (! mergeable (prev))
return false;
+ M17N.DebugPrint ("merging "); DumpOne (false, false);
+ M17N.DebugPrint (" with prev "); prev.DumpOne (false, true);
int len = prev.Length - prev.LeftLength;
// PREV is Left, Left.Right, ..., or Left....Right.
if (prev != Left)
{
+ if (prev.Left != null)
+ prev.Left.Parent = prev.Parent;
prev.Parent.Right = prev.Left;
while (prev.Parent != Left)
{
}
Left.Length -= len;
if (Left.Length == Left.LeftLength)
- Left = Left.Left;
+ {
+ if (Left.Left != null)
+ Left.Left.Parent = this;
+ Left = Left.Left;
+ }
return true;
}
if (! mergeable (next))
return false;
- int len = next.Length - next.LeftLength;
+ M17N.DebugPrint ("merging "); DumpOne (false, false);
+ M17N.DebugPrint (" with next "); next.DumpOne (false, true);
+
+ int len = next.Length - next.RightLength;
// NEXT is Right, Right.Left, ..., or Right....Left.
if (next != Right)
{
+ if (next.Right != null)
+ next.Right.Parent = next.Parent;
next.Parent.Left = next.Right;
while (next.Parent != Right)
{
}
}
Right.Length -= len;
- if (Right.Length == Right.LeftLength)
- Right = Right.Left;
-
+ if (Right.Length == Right.RightLength)
+ {
+ if (Right.Right != null)
+ Right.Right.Parent = this;
+ Right = Right.Right;
+ }
return true;
}
}
}
+ private int Depth {
+ get { return (Parent == null ? 0 : Parent.Depth + 1); }
+ }
+
+ private void DumpNestedOne ()
+ {
+ int depth;
+ MInterval i;
+
+ for (depth = 0, i = this; i.Parent != null; depth++, i = i.Parent)
+ Console.Write (" ");
+ DumpOne (true, true);
+ }
+
public void DumpNested (bool force)
{
+ DumpNested ("", force);
+ }
+
+ public void DumpNested (string indent, bool force)
+ {
if (force || M17N.debug)
{
- update_from_to ();
+ int indent_type = (Parent == null ? 1
+ : Parent.Left == this ? 0 : 2);
- Console.Write ("#{0}({1} {2} {3}", ID, Length, From, To);
- foreach (MPlist p in Stack)
- Console.Write (" " + p.Val);
+ update_from_to ();
if (Left != null)
{
- Console.Write (" left=");
- Left.DumpNested (force);
+ if (indent_type <= 1)
+ Left.DumpNested (indent + " ", force);
+ else
+ Left.DumpNested (indent + "| ", force);
}
+ if (indent_type == 0)
+ Console.Write (indent + ".-");
+ else if (indent_type == 2)
+ Console.Write (indent + "`-");
+ DumpOne (true, true);
if (Right != null)
{
- Console.Write (" right=");
- Right.DumpNested (force);
+ if (indent_type >= 1)
+ Right.DumpNested (indent + " ", force);
+ else if (indent_type == 2)
+ Right.DumpNested (indent + "| ", force);
}
- Console.Write (")");
}
}
}
{
String str = "0123456789";
MText mt = new MText (str);
- MSymbol sym = new MSymbol ("sym");
- MTextProperty prop1 = new MTextProperty (sym, "test1");
- MTextProperty prop2 = new MTextProperty (sym, "test2");
+ MSymbol sym = new MSymbol ("key");
+ MTextProperty prop1 = new MTextProperty (sym, "val0");
+ MTextProperty prop2 = new MTextProperty (sym, "val1");
M17N.M17N.debug = true;
+ mt.PushProp (1, 3, prop1);
+ mt.PushProp (0, 1, prop1);
+ mt.PushProp (0, 1, prop2);
+ mt.PushProp (3, 5, prop1);
+ mt.PushProp (3, 5, prop2);
+ mt.PushProp (7, 8, prop2);
+ mt.PushProp (5, 7, prop2);
+ mt.PushProp (5, 7, prop1);
+ mt.PushProp (8, 10, prop1);
+ mt.PopProp (8, 9, sym);
+ mt.DumpPropNested ();
+ mt.PopProp (5, 9, sym);
+ mt.DumpPropNested ();
+
+ mt = new MText (str);
mt.PushProp (2, 5, prop1);
mt.DumpProp ();
mt.PushProp (3, 6, prop2);
mt.DumpProp ();
mt.Ins (5, new MText ("45678"));
mt.DumpProp ();
+ mt.Dup ().DumpProp ();
mt.PopProp (0, 3, sym);
mt.DumpProp ();
mt.PopProp (2, 8, sym);