summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-06-15 13:37:26 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-06-15 13:37:26 +0200
commita3f2ee06ee4892f0a6b6d4595e3fdef43bbecdde (patch)
tree5cfb1693ccef4fa098e22db1a8f51999638af4cd
parent4097b345be721795492243c00cb7446d8ff161c8 (diff)
MLKReader: Read symbols.
-rw-r--r--MLKReader.m47
1 files changed, 46 insertions, 1 deletions
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