diff options
author | Matthias Andreas Benkard <matthias@benkard.de> | 2008-06-23 16:36:00 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <matthias@benkard.de> | 2008-06-23 16:36:00 +0200 |
commit | 1c181e7b07ee551d6f76416972fe38ff411ffc40 (patch) | |
tree | 869375a2a9c7d716c03d3fe94bf93e31ed952c25 | |
parent | 8ee081ba24c1fdbce25f7d8a7f3c452369f25209 (diff) |
MLKInterpreter: Support symbol macros.
-rw-r--r-- | MLKInterpreter.m | 19 |
1 files changed, 18 insertions, 1 deletions
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: ... |