From a3f2ee06ee4892f0a6b6d4595e3fdef43bbecdde Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 15 Jun 2008 13:37:26 +0200 Subject: MLKReader: Read symbols. --- MLKReader.m | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/MLKReader.m b/MLKReader.m index 72d9c62..1002ca3 100644 --- a/MLKReader.m +++ b/MLKReader.m @@ -152,7 +152,7 @@ // Check whether the token is a potential number. // // See CLHS 2.3.1.1. - int i; + unsigned long i; unichar first; // 1. Does it consist solely of characters allowed in a potential @@ -209,7 +209,52 @@ } else { + unsigned long i, packageMarker; + MLKPackage *package; + NSString *symbolName; + MLKSymbol *symbol; + + // Look for the package marker. + packageMarker = -1; + for (i = 0; i < [token length]; i++) + { + if ([readtable isPackageMarker:[token characterAtIndex:i]]) + { + packageMarker = i; + break; + } + } + // Extract the package and symbol name. + if (packageMarker == -1) + { + package = [[MLKDynamicContext currentContext] + valueForBinding:[[MLKPackage + findPackage:@"COMMON-LISP"] + intern:@"*PACKAGE*"]]; + symbolName = token; + } + else if (packageMarker == 0) + { + package = [MLKPackage findPackage:@"KEYWORD"]; + symbolName = [token substringFromIndex:1]; + } + else + { + package = [MLKPackage + findPackage:[token substringToIndex:packageMarker]]; + symbolName = [token substringFromIndex:(packageMarker+1)]; + } + + symbol = [package intern:token]; + + if (packageMarker == 0) + { + // Make keyword symbols self-evaluate. + [[MLKDynamicContext currentContext] setValue:symbol forBinding:symbol]; + } + + return symbol; } } @end -- cgit v1.2.3