summaryrefslogtreecommitdiff
path: root/MLKRoot.m
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-07-03 20:17:10 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-07-03 20:17:10 +0200
commit475dd63b41774c96289df54c7987de95faa55099 (patch)
tree40f99273fbc0c4ca431ce6dfc875a510a4505d4f /MLKRoot.m
parent107dee15d5422f327ce55625a0a321b98693394e (diff)
Implement MACROEXPAND-1.
Diffstat (limited to 'MLKRoot.m')
-rw-r--r--MLKRoot.m18
1 files changed, 18 insertions, 0 deletions
diff --git a/MLKRoot.m b/MLKRoot.m
index cafafe1..a9e15d3 100644
--- a/MLKRoot.m
+++ b/MLKRoot.m
@@ -209,4 +209,22 @@ static id truify (BOOL value)
{
RETURN_VALUE ([MLKCons listWithArray:args]);
}
+
++(NSArray *) macroexpand_1:(NSArray *)args
+{
+ id form = [args objectAtIndex:0];
+ id env = [args count] > 1 ? [args objectAtIndex:1] : nil;
+ MLKLexicalContext *context = env ? (id)env : (id)[MLKLexicalContext globalContext];
+
+ if ([context symbolNamesMacro:[form car]])
+ {
+ id <MLKFuncallable> macrofun = [context macroForSymbol:[form car]];
+ form = denullify ([[macrofun applyToArray:
+ [NSArray arrayWithObjects:
+ form, context, nil]]
+ objectAtIndex:0]);
+ }
+
+ RETURN_VALUE (form);
+}
@end