-
Notifications
You must be signed in to change notification settings - Fork 0
/
LangDemo.m
24 lines (21 loc) · 1.1 KB
/
LangDemo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#import "ConstLang.h"
#import "IOLang.h"
#import "RPNLang.h"
int main() {
ConstLang *constant = [ConstLang new];
NSLog(@"%d\n", (int)[constant performSelector:NSSelectorFromString(@"413")]);
NSLog(@"%d\n", (int)[constant performSelector:NSSelectorFromString(@"413")]);
NSLog(@"%d\n", (int)[constant performSelector:NSSelectorFromString(@"612")]);
RPNLang *rpn = [RPNLang new];
NSLog(@"%d\n", (int)[rpn performSelector:NSSelectorFromString(@"1 2 +")]);
NSLog(@"%d\n", (int)[rpn performSelector:NSSelectorFromString(@"1 2 +")]);
NSLog(@"%d\n", (int)[rpn performSelector:NSSelectorFromString(@"$0 $1 +")
withObject:@[ @413, @612 ]]);
IOLang *io = [IOLang new];
[io performSelector:NSSelectorFromString(@"writeln(\"hello world!\")")];
[io performSelector:NSSelectorFromString(@"for(i, 1, 10, \n"
@"if(i == 3, continue)\n"
@"if(i == 7, break)\n"
@"i print\n"
@")")];
}