From 172fe17e991e5cdff87a0d794bcb7272e4824c95 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 3 Aug 2008 18:58:42 +0200 Subject: Make MACROEXPAND-1 aware of symbol macros. --- MLKReadEvalPrintLoop.m | 4 ++-- MLKRoot.m | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/MLKReadEvalPrintLoop.m b/MLKReadEvalPrintLoop.m index 092c6bd..f2a7803 100644 --- a/MLKReadEvalPrintLoop.m +++ b/MLKReadEvalPrintLoop.m @@ -99,8 +99,6 @@ static const char *prompt (EditLine *e) { } NS_ENDHANDLER; - RELEASE (pool); - printf ("Done.\n\n"); printf ("This is Toilet Lisp, version 0.0.1.\n"); @@ -112,6 +110,8 @@ static const char *prompt (EditLine *e) { forSymbol:[[MLKPackage findPackage:@"TOILET-SYSTEM"] intern:@"*SYSTEM-INITIALISED-P*"]]; + RELEASE (pool); + while (1) { const char *line; diff --git a/MLKRoot.m b/MLKRoot.m index f155733..e3680f3 100644 --- a/MLKRoot.m +++ b/MLKRoot.m @@ -229,12 +229,22 @@ static id truify (BOOL value) id form = [args objectAtIndex:0]; id env = [args count] > 1 ? denullify([args objectAtIndex:1]) : nil; MLKLexicalContext *context = env ? (id)env : (id)[MLKLexicalContext globalContext]; + id macrofun = nil; if ([form isKindOfClass:[MLKCons class]] && (![form car] || [[form car] isKindOfClass:[MLKSymbol class]]) && [context symbolNamesMacro:[form car]]) { - id macrofun = [context macroForSymbol:[form car]]; + macrofun = [context macroForSymbol:[form car]]; + } + else if ([form isKindOfClass:[MLKSymbol class]] + && [context symbolNamesSymbolMacro:form]) + { + macrofun = [context symbolMacroForSymbol:[form car]]; + } + + if (macrofun) + { form = denullify ([[macrofun applyToArray: [NSArray arrayWithObjects: form, context, nil]] -- cgit v1.2.3