diff options
author | Matthias Benkard <mulk@minimulk.mst-plus> | 2008-07-27 09:44:01 +0200 |
---|---|---|
committer | Matthias Benkard <mulk@minimulk.mst-plus> | 2008-07-27 09:44:01 +0200 |
commit | a234e03248b1a8a97ee5f0b1d3a8f988d275cea8 (patch) | |
tree | aa7ebafc37ced87a96855b9758310dd80c84d2fc /MLKParenReader.m | |
parent | 39c7ec616a22882c2b98244c7dcb39b6cd8ef122 (diff) | |
parent | bcde0dca1696a9f9e754d52776700edc83663453 (diff) |
Merge branch 'master' of http://matthias.benkard.de/code/mulklisp
Diffstat (limited to 'MLKParenReader.m')
-rw-r--r-- | MLKParenReader.m | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/MLKParenReader.m b/MLKParenReader.m index 9287ce9..b61a332 100644 --- a/MLKParenReader.m +++ b/MLKParenReader.m @@ -59,6 +59,7 @@ static unichar slurpWhitespaceAndPeek (MLKStream *stream, MLKReadtable *readtabl while ((nextChar = slurpWhitespaceAndPeek(stream, readtable)) != ')') { id item; + id dotMarker = [[NSObject alloc] init]; // FIXME: What to do about dots? Maybe add a new // singleDotAllowed:(BOOL)dotp argument to readFromStream:...? @@ -66,8 +67,35 @@ static unichar slurpWhitespaceAndPeek (MLKStream *stream, MLKReadtable *readtabl eofError:YES eofValue:nil recursive:YES - preserveWhitespace:NO]; - + preserveWhitespace:NO + singleDotMarker:dotMarker]; + + if (item == dotMarker) + { + id nextItem; + + RELEASE (dotMarker); + + nextItem = [MLKReader readFromStream:stream + eofError:YES + eofValue:nil + recursive:YES + preserveWhitespace:NO + singleDotMarker:nil]; + [tail setCdr:nextItem]; + + if ((nextChar = slurpWhitespaceAndPeek (stream, readtable)) == ')') + { + [stream readChar]; + return [NSArray arrayWithObject:cons]; + } + else + { + [NSException raise:@"MLKReaderError" + format:@"Unexpectedly read a single dot."]; + } + } + if (!tail) { cons = tail = [MLKCons cons:item with:nil]; @@ -77,6 +105,8 @@ static unichar slurpWhitespaceAndPeek (MLKStream *stream, MLKReadtable *readtabl [tail setCdr:[MLKCons cons:item with:nil]]; tail = [tail cdr]; } + + RELEASE (dotMarker); } [stream readChar]; |