Commit | Line | Data |
---|---|---|
57350ed7 JM |
1 | #import <Foundation/Foundation.h> |
2 | ||
3 | #import "mal_readline.h" | |
4 | ||
5 | NSString *READ(NSString *str) { | |
6 | return str; | |
7 | } | |
8 | ||
9 | NSString *EVAL(NSString *ast, NSString *env) { | |
10 | return ast; | |
11 | } | |
12 | ||
13 | NSString *PRINT(NSString *exp) { | |
14 | return exp; | |
15 | } | |
16 | ||
17 | NSString *REP(NSString *line) { | |
18 | return PRINT(EVAL(READ(line), @"")); | |
19 | } | |
20 | ||
7cae6e6f | 21 | int main () { |
57350ed7 JM |
22 | // Create an autorelease pool to manage the memory into the program |
23 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | |
24 | // If using automatic reference counting (ARC), use @autoreleasepool instead: | |
25 | // @autoreleasepool { | |
26 | ||
27 | while (true) { | |
28 | char *rawline = _readline("user> "); | |
29 | if (!rawline) { break; } | |
30 | NSString *line = [NSString stringWithUTF8String:rawline]; | |
31 | if ([line length] == 0) { continue; } | |
32 | printf("%s\n", [[REP(line) description] UTF8String]); | |
33 | } | |
34 | ||
35 | [pool drain]; | |
36 | ||
37 | // } | |
38 | } |