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 <Cocoa/Cocoa.h> 28#import "ANTLRCommonToken.h" 29#import "ANTLRBaseTree.h" 30 31@interface ANTLRCommonTree : ANTLRBaseTree <ANTLRTree> { 32 __strong ANTLRCommonToken *token; 33 NSInteger startIndex; 34 NSInteger stopIndex; 35 __strong ANTLRCommonTree *parent; 36 NSInteger childIndex; 37} 38 39+ (ANTLRCommonTree *) invalidNode; 40+ (ANTLRCommonTree *) newTree; 41+ (ANTLRCommonTree *) newTreeWithTree:(ANTLRCommonTree *)aTree; 42+ (ANTLRCommonTree *) newTreeWithToken:(ANTLRCommonToken *)aToken; 43+ (ANTLRCommonTree *) newTreeWithTokenType:(NSInteger)tokenType; 44+ (ANTLRCommonTree *) newTreeWithTokenType:(NSInteger)aTType Text:(NSString *)theText; 45 46- (id) init; 47- (id) initWithTreeNode:(ANTLRCommonTree *)aNode; 48- (id) initWithToken:(ANTLRCommonToken *)aToken; 49- (id) initWithTokenType:(NSInteger)aTokenType; 50- (id) initWithTokenType:(NSInteger)aTokenType Text:(NSString *)theText; 51 52- (id<ANTLRBaseTree>) copyWithZone:(NSZone *)aZone; 53 54- (BOOL) isNil; 55 56- (ANTLRCommonToken *) getToken; 57- (void) setToken:(ANTLRCommonToken *)aToken; 58- (ANTLRCommonToken *) dupNode; 59- (NSInteger)type; 60- (NSString *)text; 61- (NSUInteger)line; 62- (void) setLine:(NSUInteger)aLine; 63- (NSUInteger)charPositionInLine; 64- (void) setCharPositionInLine:(NSUInteger)pos; 65- (ANTLRCommonTree *) getParent; 66- (void) setParent:(ANTLRCommonTree *) 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=getANTLRCommonToken, setter=setANTLRCommonToken:) ANTLRCommonToken *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<ANTLRBaseTree> parentparent; 83 @property (assign, getter=getChildIndex, setter=setChildIndex:) NSInteger childIndex; 84 */ 85 86@property (retain) ANTLRCommonToken *token; 87@property (assign) NSInteger startIndex; 88@property (assign) NSInteger stopIndex; 89@property (retain) ANTLRCommonTree *parent; 90@property (assign) NSInteger childIndex; 91 92@end 93