1#import <Cocoa/Cocoa.h> 2#import "antlr3.h" 3#import "TreeRewriteLexer.h" 4#import "TreeRewriteParser.h" 5//#import "stdio.h" 6//#include <unistd.h> 7 8int main() { 9 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 10 11 ANTLRStringStream *stream = [ANTLRStringStream newANTLRStringStream:@"23 42"]; 12 TreeRewriteLexer *lexer = [TreeRewriteLexer newTreeRewriteLexerWithCharStream:stream]; 13 14// id<ANTLRToken> currentToken; 15// while ((currentToken = [lexer nextToken]) && [currentToken type] != ANTLRTokenTypeEOF) { 16// NSLog(@"%@", currentToken); 17// } 18 19 ANTLRCommonTokenStream *tokenStream = [ANTLRCommonTokenStream newANTLRCommonTokenStreamWithTokenSource:lexer]; 20 TreeRewriteParser *parser = [[TreeRewriteParser alloc] initWithTokenStream:tokenStream]; 21 ANTLRCommonTree *rule_tree = [[parser rule] getTree]; 22 NSLog(@"tree: %@", [rule_tree treeDescription]); 23// ANTLRCommonTreeNodeStream *treeStream = [[ANTLRCommonTreeNodeStream alloc] initWithTree:program_tree]; 24// SimpleCTP *walker = [[SimpleCTP alloc] initWithTreeNodeStream:treeStream]; 25// [walker program]; 26 27 [lexer release]; 28 [stream release]; 29 [tokenStream release]; 30 [parser release]; 31// [treeStream release]; 32// [walker release]; 33 34 [pool release]; 35 // sleep for objectalloc 36 // while(1) sleep(60); 37 return 0; 38}