From 85762b55bf85437e981ebbf162e9af2255236330 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Thu, 19 Jun 2008 21:16:13 +0200 Subject: Make the list reader work for simple lists. --- MLKReader.m | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'MLKReader.m') diff --git a/MLKReader.m b/MLKReader.m index da5e743..fd6daa3 100644 --- a/MLKReader.m +++ b/MLKReader.m @@ -55,7 +55,7 @@ readtable = [[MLKDynamicContext currentContext] valueForBinding:[[MLKPackage findPackage:@"COMMON-LISP"] intern:@"*READTABLE*"]]; - + start: if ([stream isEOF]) { @@ -86,7 +86,9 @@ } returnValues = [macrofun applyToArray:args]; if ([returnValues count]) - return [returnValues objectAtIndex:0]; + return ([returnValues objectAtIndex:0] == [NSNull null] + ? nil + : [returnValues objectAtIndex:0]); else goto start; } @@ -123,7 +125,8 @@ ch = [stream readChar]; if ([readtable isConstituentCharacter:ch] || [readtable isNonTerminatingMacroCharacter:ch] || - (escaped && [readtable isWhitespaceCharacter:ch])) + (escaped && (![readtable isMultipleEscapeCharacter:ch] + && ![readtable isSingleEscapeCharacter:ch]))) { if (escaped) [token appendFormat:@"%C", ch]; @@ -148,9 +151,12 @@ [stream unreadChar:ch]; break; } - else if ([readtable isInvalid:ch]) + else if ([readtable isConstituentCharacter:ch] + && [readtable isInvalid:ch]) { - [[[MLKReaderError alloc] initWithStream:stream] raise]; + //[[[MLKReaderError alloc] initWithStream:stream] raise]; + [NSException raise:@"MLKReaderError" + format:@"'%c' is an invalid constituent character.", ch]; } else if ([readtable isWhitespaceCharacter:ch]) { -- cgit v1.2.3