mirror of
https://github.com/kanaka/mal.git
synced 2024-11-10 02:45:44 +03:00
8a19f60386
- Reorder README to have implementation list after "learning tool" bullet. - This also moves tests/ and libs/ into impls. It would be preferrable to have these directories at the top level. However, this causes difficulties with the wasm implementations which need pre-open directories and have trouble with paths starting with "../../". So in lieu of that, symlink those directories to the top-level. - Move the run_argv_test.sh script into the tests directory for general hygiene.
39 lines
872 B
Objective-C
39 lines
872 B
Objective-C
#import <Foundation/Foundation.h>
|
|
|
|
#import "mal_readline.h"
|
|
|
|
NSString *READ(NSString *str) {
|
|
return str;
|
|
}
|
|
|
|
NSString *EVAL(NSString *ast, NSString *env) {
|
|
return ast;
|
|
}
|
|
|
|
NSString *PRINT(NSString *exp) {
|
|
return exp;
|
|
}
|
|
|
|
NSString *REP(NSString *line) {
|
|
return PRINT(EVAL(READ(line), @""));
|
|
}
|
|
|
|
int main () {
|
|
// Create an autorelease pool to manage the memory into the program
|
|
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
|
// If using automatic reference counting (ARC), use @autoreleasepool instead:
|
|
// @autoreleasepool {
|
|
|
|
while (true) {
|
|
char *rawline = _readline("user> ");
|
|
if (!rawline) { break; }
|
|
NSString *line = [NSString stringWithUTF8String:rawline];
|
|
if ([line length] == 0) { continue; }
|
|
printf("%s\n", [[REP(line) description] UTF8String]);
|
|
}
|
|
|
|
[pool drain];
|
|
|
|
// }
|
|
}
|