1 // [The "BSD licence"] 2 // Copyright (c) 2006-2007 Kay Roepke 2010 Alan Condit 3 // All rights reserved. 4 // 5 // Redistribution and use in source and binary forms, with or without 6 // modification, are permitted provided that the following conditions 7 // are met: 8 // 1. Redistributions of source code must retain the above copyright 9 // notice, this list of conditions and the following disclaimer. 10 // 2. Redistributions in binary form must reproduce the above copyright 11 // notice, this list of conditions and the following disclaimer in the 12 // documentation and/or other materials provided with the distribution. 13 // 3. The name of the author may not be used to endorse or promote products 14 // derived from this software without specific prior written permission. 15 // 16 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 27 #import <Foundation/Foundation.h> 28 #import "CommonToken.h" 29 #import "BaseTree.h" 30 31 @interface CommonTree : BaseTree <Tree> { 32 __strong CommonToken *token; 33 NSInteger startIndex; 34 NSInteger stopIndex; 35 __strong CommonTree *parent; 36 NSInteger childIndex; 37 } 38 39 + (CommonTree *) invalidNode; 40 + (CommonTree *) newTree; 41 + (CommonTree *) newTreeWithTree:(CommonTree *)aTree; 42 + (CommonTree *) newTreeWithToken:(CommonToken *)aToken; 43 + (CommonTree *) newTreeWithTokenType:(NSInteger)tokenType; 44 + (CommonTree *) newTreeWithTokenType:(NSInteger)aTType Text:(NSString *)theText; 45 46 - (id) init; 47 - (id) initWithTreeNode:(CommonTree *)aNode; 48 - (id) initWithToken:(CommonToken *)aToken; 49 - (id) initWithTokenType:(NSInteger)aTokenType; 50 - (id) initWithTokenType:(NSInteger)aTokenType Text:(NSString *)theText; 51 52 - (id<BaseTree>) copyWithZone:(NSZone *)aZone; 53 54 - (BOOL) isNil; 55 56 - (CommonToken *) getToken; 57 - (void) setToken:(CommonToken *)aToken; 58 - (CommonToken *) dupNode; 59 - (NSInteger)type; 60 - (NSString *)text; 61 - (NSUInteger)line; 62 - (void) setLine:(NSUInteger)aLine; 63 - (NSUInteger)charPositionInLine; 64 - (void) setCharPositionInLine:(NSUInteger)pos; 65 - (CommonTree *) getParent; 66 - (void) setParent:(CommonTree *) t; 67 68 #ifdef DONTUSENOMO 69 - (NSString *) treeDescription; 70 #endif 71 - (NSString *) description; 72 - (void) setUnknownTokenBoundaries; 73 - (NSInteger) getTokenStartIndex; 74 - (void) setTokenStartIndex: (NSInteger) aStartIndex; 75 - (NSInteger) getTokenStopIndex; 76 - (void) setTokenStopIndex: (NSInteger) aStopIndex; 77 78 /* 79 @property (retain, getter=getCommonToken, setter=setCommonToken:) CommonToken *token; 80 @property (assign, getter=getTokenStartIndex, setter=setTokenStartIndex:) NSInteger startIndex; 81 @property (assign, getter=getTokenStopIndex, setter=setTokenStopIndex:) NSInteger stopIndex; 82 @property (retain, getter=getParent, setter=setParent:) id<BaseTree> parentparent; 83 @property (assign, getter=getChildIndex, setter=setChildIndex:) NSInteger childIndex; 84 */ 85 86 @property (retain) CommonToken *token; 87 @property (assign) NSInteger startIndex; 88 @property (assign) NSInteger stopIndex; 89 @property (retain) CommonTree *parent; 90 @property (assign) NSInteger childIndex; 91 92 @end 93