diff options
-rw-r--r-- | MLKReader.m | 40 | ||||
-rw-r--r-- | MLKSymbol.m | 2 |
2 files changed, 29 insertions, 13 deletions
diff --git a/MLKReader.m b/MLKReader.m index 282db60..7343c64 100644 --- a/MLKReader.m +++ b/MLKReader.m @@ -448,13 +448,19 @@ } else { - package = [MLKPackage - findPackage:[token substringToIndex:packageMarker]]; + NSString *packageName = [token substringToIndex:packageMarker]; - if (!package) - [NSException raise:@"MLKReaderError" - format:@"Can't find package %@.", - [token substringToIndex:packageMarker]]; + if ([packageName isEqualToString:@"#"]) + package = nil; + else + { + package = [MLKPackage findPackage:packageName]; + + if (!package) + [NSException raise:@"MLKReaderError" + format:@"Can't find package %@.", + [token substringToIndex:packageMarker]]; + } if ([readtable isPackageMarker:[token characterAtIndex:(i+1)]]) symbolName = [token substringFromIndex:(packageMarker+2)]; @@ -463,16 +469,24 @@ // A single package marker means we have to check whether // the symbol is external in the package. symbolName = [token substringFromIndex:(packageMarker+1)]; - symbol = [package intern:symbolName]; - if (![[package exportedSymbols] containsObject:symbol]) - [NSException raise:@"MLKReaderError" - format:@"Package %@ does not export symbol %@.", - [package name], [symbol descriptionForLisp]]; + + if (package) + { + symbol = [package intern:symbolName]; + if (![[package exportedSymbols] containsObject:symbol]) + [NSException raise:@"MLKReaderError" + format:@"Package %@ does not export symbol %@.", + [package name], + [symbol descriptionForLisp]]; + } } } - symbol = [package intern:symbolName]; - + if (package) + symbol = [package intern:symbolName]; + else + symbol = [MLKSymbol symbolWithName:symbolName package:nil]; + if (packageMarker == 0) { // Make keyword symbols self-evaluate. diff --git a/MLKSymbol.m b/MLKSymbol.m index fead7be..d84dc18 100644 --- a/MLKSymbol.m +++ b/MLKSymbol.m @@ -137,6 +137,8 @@ if (homePackage == [MLKPackage findPackage:@"KEYWORD"]) packagePrefix = @":"; + else if (!homePackage) + packagePrefix = @"#:"; else if (accessible) packagePrefix = [NSString string]; else |