summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-07-07 20:22:52 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-07-07 20:22:52 +0200
commitdc2ec73e0293f926d97c472dc86eab7adcaa9c2c (patch)
treedf6ef4703d647137bd7ecb83554e1207cb533ff3
parentf47f28ae81b71049496fa96e6f27b3e2794fc9cb (diff)
Reader: Support uninterned symbols.
-rw-r--r--MLKReader.m40
-rw-r--r--MLKSymbol.m2
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