diff options
Diffstat (limited to 'MLKInterpreter.m')
-rw-r--r-- | MLKInterpreter.m | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/MLKInterpreter.m b/MLKInterpreter.m index 2f9aba3..cf12d6d 100644 --- a/MLKInterpreter.m +++ b/MLKInterpreter.m @@ -25,6 +25,7 @@ #import "MLKLexicalContext.h" #import "MLKLexicalEnvironment.h" #import "MLKPackage.h" +#import "MLKReader.h" #import "MLKRoot.h" #import "MLKSymbol.h" #import "runtime-compatibility.h" @@ -423,4 +424,41 @@ static MLKSymbol *_LAMBDA; } } } + + ++(BOOL) load:(MLKStream *)stream verbose:(BOOL)verbose print:(BOOL)print +{ + id eofValue = [[NSObject alloc] init]; + + while (YES) + { + id result; + id code = [MLKReader readFromStream:stream + eofError:NO + eofValue:eofValue + recursive:NO + preserveWhitespace:NO]; + + //NSLog (@"%@", code); + //NSLog (@"%@", stream); + //NSLog (@"..."); + + if (code == eofValue) + break; + + NSLog (@"; LOAD: Evaluating a top-level form."); + result = [MLKInterpreter + eval:code + inLexicalContext:[MLKLexicalContext globalContext] + withEnvironment:[MLKLexicalEnvironment globalEnvironment]]; + + if (print) + { + //FIXME + NSLog (@"; LOAD: Fnord. Primary value: %@", result); + } + } + + return YES; +} @end |