X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=MPlist.cs;h=57005c90dcc3f79a8c02cfd515c6f42b547fc2dd;hb=b0944101586bc138ea4bd2df4ce4ee8f6cc8c2c4;hp=e62fdb4882cfb8b2b1a8e762cbfddd65bf41f598;hpb=979b3ac2f471babc8f225af5725bf0230f2eae7d;p=m17n%2Fm17n-lib-cs.git diff --git a/MPlist.cs b/MPlist.cs index e62fdb4..57005c9 100644 --- a/MPlist.cs +++ b/MPlist.cs @@ -54,6 +54,34 @@ namespace M17N.Core 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); @@ -107,6 +135,44 @@ namespace M17N.Core 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; @@ -170,6 +236,15 @@ namespace M17N.Core } } + 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; @@ -249,7 +324,10 @@ namespace M17N.Core if (IsEmpty) Push (key, val); else - this.val = val; + { + this.key = key; + this.val = val; + } return this; } @@ -613,7 +691,7 @@ namespace M17N.Core val = new MPlist (this); key = MSymbol.plist; } - else if (c == '"' || c == '\\') + else if (c == '"') { MText mt; ReadMText (out mt);