From 1c181e7b07ee551d6f76416972fe38ff411ffc40 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Mon, 23 Jun 2008 16:36:00 +0200 Subject: MLKInterpreter: Support symbol macros. --- MLKInterpreter.m | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/MLKInterpreter.m b/MLKInterpreter.m index 1c011d2..35d73cf 100644 --- a/MLKInterpreter.m +++ b/MLKInterpreter.m @@ -47,6 +47,7 @@ static MLKSymbol *APPLY; static MLKSymbol *FUNCALL; static MLKSymbol *EVAL; static MLKSymbol *QUOTE; +static MLKSymbol *SETQ; static MLKSymbol *_DEFMACRO; @@ -67,6 +68,7 @@ static MLKSymbol *_DEFMACRO; APPLY = [cl intern:@"APPLY"]; EVAL = [cl intern:@"EVAL"]; QUOTE = [cl intern:@"QUOTE"]; + SETQ = [cl intern:@"SETQ"]; _DEFMACRO = [sys intern:@"%DEFMACRO"]; } @@ -79,7 +81,17 @@ static MLKSymbol *_DEFMACRO; if (!program || [program isKindOfClass:[MLKSymbol class]]) { - if ([context variableIsLexical:program]) + if ([context symbolNamesSymbolMacro:program]) + { + id macrofun = [context macroForSymbol:program]; + id expansion = [macrofun applyToArray: + [NSArray arrayWithObjects: + program, context, nil]]; + return [self eval:expansion + inLexicalContext:context + withEnvironment:lexenv]; + } + else if ([context variableIsLexical:program]) { return [lexenv valueForSymbol:program]; } @@ -135,6 +147,11 @@ static MLKSymbol *_DEFMACRO; { return [[program cdr] car]; } + else if (car == SETQ) + { + //FIXME: ... + //FIXME: Don't forget handling symbol macros correctly. + } else if (car == TAGBODY) { //FIXME: ... -- cgit v1.2.3