summaryrefslogtreecommitdiff
path: root/MLKReadEvalPrintLoop.m
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-06-27 15:01:07 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-06-27 15:01:07 +0200
commitefad95ec36837acdcc1aa4012675aabf0b72c756 (patch)
tree28a1877f6dfa7f4106ab0663a6fb841e8fd9598f /MLKReadEvalPrintLoop.m
parent189d02b12aa33fc18eaff9558675d9fa9d6ba668 (diff)
MLKInterpreter: Correctly handle multiple values.
Diffstat (limited to 'MLKReadEvalPrintLoop.m')
-rw-r--r--MLKReadEvalPrintLoop.m30
1 files changed, 19 insertions, 11 deletions
diff --git a/MLKReadEvalPrintLoop.m b/MLKReadEvalPrintLoop.m
index 4ccc339..e9e90db 100644
--- a/MLKReadEvalPrintLoop.m
+++ b/MLKReadEvalPrintLoop.m
@@ -27,6 +27,7 @@
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSException.h>
+#import <Foundation/NSNull.h>
#import <Foundation/NSString.h>
#import <editline/history.h>
@@ -87,7 +88,7 @@ static const char *prompt (EditLine *e) {
if (line_length > 1)
{
NSAutoreleasePool *pool;
- id result;
+ NSArray *results;
id code;
pool = [[NSAutoreleasePool alloc] init];
@@ -96,18 +97,25 @@ static const char *prompt (EditLine *e) {
NS_DURING
{
+ int i;
+
code = [MLKReader readFromString:[NSString stringWithUTF8String:line]];
- result = [MLKInterpreter eval:code
- inLexicalContext:[MLKLexicalContext
- globalContext]
- withEnvironment:[MLKLexicalEnvironment
- globalEnvironment]];
-
- if (result)
- printf ("%s\n", [[result descriptionForLisp] UTF8String]);
- else
- printf ("()\n");
+ results = [MLKInterpreter eval:code
+ inLexicalContext:[MLKLexicalContext
+ globalContext]
+ withEnvironment:[MLKLexicalEnvironment
+ globalEnvironment]];
+
+ for (i = 0; i < [results count]; i++)
+ {
+ id result = [results objectAtIndex:i];
+ if (result != [NSNull null])
+ printf ("%s\n", [[result descriptionForLisp] UTF8String]);
+ else
+ printf ("()\n");
+ }
+
}
NS_HANDLER
{