next = new MPlist ();
}
+ public MPlist (FileStream stream, MSymbol stop)
+ {
+ MStreamReader reader = new MStreamReader (stream);
+ bool result;
+
+ key = MSymbol.nil;
+ val = null;
+ while (true)
+ {
+ MSymbol this_key;
+ object this_val;
+
+ result = reader.ReadElement (out this_key, out this_val);
+ if (! result)
+ return;
+ if (this_key == MSymbol.plist)
+ {
+ MPlist plist = (MPlist) this_val;
+
+ if (plist.IsSymbol && plist.Symbol == stop)
+ return;
+ }
+ key = this_key;
+ val = this_val;
+ next = new MPlist (reader, stop);
+ }
+ }
+
public MPlist (FileStream stream, MSymbol target, MSymbol stop)
{
MStreamReader reader = new MStreamReader (stream);
next = new MPlist ();
}
+ private MPlist (MStreamReader reader, MSymbol stop)
+ {
+ bool result;
+ MPlist next_plist = null;
+
+ key = MSymbol.nil;
+ val = null;
+ while (true)
+ {
+ MSymbol this_key;
+ object this_val;
+
+ result = reader.ReadElement (out this_key, out this_val);
+ if (! result)
+ return;
+ if (this_key == MSymbol.plist)
+ {
+ MPlist plist = (MPlist) this_val;
+
+ if (plist.IsSymbol && plist.Symbol == stop)
+ return;
+ }
+ if (next_plist == null)
+ {
+ key = this_key;
+ val = this_val;
+ next = next_plist = new MPlist ();
+ }
+ else
+ {
+ next_plist.key = this_key;
+ next_plist.val = this_val;
+ next_plist.next = new MPlist ();
+ next_plist = next_plist.next;
+ }
+ }
+ }
+
private MPlist (MStreamReader reader, MSymbol target, MSymbol stop)
{
bool result;
}
}
+ public MPlist this[int i]
+ {
+ get {
+ MPlist p;
+ for (p = this; ! p.IsEmpty && i > 0; i--, p = p.next);
+ return (i == 0 ? p : null);
+ }
+ }
+
public MPlist Clone ()
{
MPlist plist = new MPlist (), pl = plist;
if (IsEmpty)
Push (key, val);
else
- this.val = val;
+ {
+ this.key = key;
+ this.val = val;
+ }
return this;
}
return p.Push (key, val);
}
+ public MPlist Cons (MSymbol key, object val)
+ {
+ MPlist plist = new MPlist ();
+ plist.key = key;
+ plist.val = val;
+ plist.next = this;
+ return plist;
+ }
+
public MPlist Clear ()
{
key = MSymbol.nil;
val = new MPlist (this);
key = MSymbol.plist;
}
- else if (c == '"' || c == '\\')
+ else if (c == '"')
{
MText mt;
ReadMText (out mt);