diff options
author | Matthias Andreas Benkard <matthias@benkard.de> | 2008-07-01 17:40:34 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <matthias@benkard.de> | 2008-07-01 17:40:34 +0200 |
commit | e97d47a664131b5c80f35265f33e82eefb04f1d0 (patch) | |
tree | ebf4e251add7474062fbf7cbba2696f1e64e6cc4 /MLKInterpreter.m | |
parent | 2ce5b7ded1c689548e9becb6fb39284ea68a1941 (diff) |
Implement a raw version of LOAD.
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 |