From ca17649dab6d0d1ed49a3e072827e8324629aa64 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Thu, 31 Jul 2008 11:48:46 +0200 Subject: Reader: Add support for dispatching macro characters. --- MLKReader.m | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'MLKReader.m') diff --git a/MLKReader.m b/MLKReader.m index 7db9670..a6f11c1 100644 --- a/MLKReader.m +++ b/MLKReader.m @@ -50,15 +50,17 @@ eofValue:eofValue recursive:recursive preserveWhitespace:preserveWhitespace - singleDotMarker:nil]; + singleDotMarker:nil + readingUninternedSymbol:NO]; } -+(id) readFromStream:(MLKStream *)stream - eofError:(BOOL)eofError - eofValue:(id)eofValue - recursive:(BOOL)recursive - preserveWhitespace:(BOOL)preserveWhitespace - singleDotMarker:(id)dotMarker ++(id) readFromStream:(MLKStream *)stream + eofError:(BOOL)eofError + eofValue:(id)eofValue + recursive:(BOOL)recursive + preserveWhitespace:(BOOL)preserveWhitespace + singleDotMarker:(id)dotMarker +readingUninternedSymbol:(BOOL)readingUninternedSymbol { unichar ch; NSMutableString *token; @@ -72,6 +74,13 @@ valueForSymbol:[[MLKPackage findPackage:@"COMMON-LISP"] intern:@"*READTABLE*"]]; + if (readingUninternedSymbol) + { + token = [NSMutableString stringWithString:@"#:"]; + escaped = NO; + goto read_token; + } + start: if ([stream isEOF]) { @@ -89,7 +98,7 @@ if ([readtable isMacroCharacter:ch]) { NSArray *returnValues; - MLKFuncallable *macrofun = [readtable macroFunctionForCharacter:ch]; + id macrofun = [readtable macroFunctionForCharacter:ch]; NSArray *args = [NSArray arrayWithObjects: stream, [MLKCharacter characterWithUnichar:ch], @@ -135,6 +144,7 @@ [token appendFormat:@"%C", [readtable charWithReadtableCase:ch]]; } + read_token: while (![stream isEOF]) { //NSLog (@"..."); @@ -260,7 +270,7 @@ escaped:(BOOL)escaped { int base; - + base = [[[MLKDynamicContext currentContext] valueForSymbol:[[MLKPackage findPackage:@"COMMON-LISP"] intern:@"*READ-BASE*"]] -- cgit v1.2.3