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 ANTLRCommonToken *token; 33 NSInteger startIndex; 34 NSInteger stopIndex; 35 ANTLRCommonTree *parent; 36 NSInteger childIndex; 37} 38 39@property (retain, getter=getANTLRCommonToken, setter=setANTLRCommonToken) ANTLRCommonToken *token; 40@property (assign, getter=getTokenStartIndex, setter=setTokenStartIndex) NSInteger startIndex; 41@property (assign, getter=getTokenStopIndex, setter=setTokenStopIndex) NSInteger stopIndex; 42@property (retain, getter=getParent, setter=setParent:) ANTLRCommonTree *parent; 43@property (assign, getter=getChildIndex, setter=setChildIndex) NSInteger childIndex; 44 45+ (ANTLRCommonTree *) invalidNode; 46+ (ANTLRCommonTree *) newANTLRCommonTree; 47+ (ANTLRCommonTree *) newANTLRCommonTreeWithTree:(ANTLRCommonTree *)aTree; 48+ (ANTLRCommonTree *) newANTLRCommonTreeWithToken:(ANTLRCommonToken *)aToken; 49+ (ANTLRCommonTree *) newANTLRCommonTreeWithTokenType:(NSInteger)tokenType; 50+ (ANTLRCommonTree *) newANTLRCommonTreeWithTokenType:(NSInteger)aTType Text:(NSString *)theText; 51#ifdef DONTUSEYET 52+ (id<ANTLRTree>) newANTLRCommonTreeWithTokenType:(NSInteger)tokenType; 53+ (id<ANTLRTree>) newANTLRCommonTreeWithToken:(id<ANTLRToken>)fromToken TokenType:(NSInteger)tokenType; 54+ (id<ANTLRTree>) newANTLRCommonTreeWithToken:(id<ANTLRToken>)fromToken TokenType:(NSInteger)tokenType Text:(NSString *)tokenText; 55+ (id<ANTLRTree>) newANTLRCommonTreeWithToken:(id<ANTLRToken>)fromToken Text:(NSString *)tokenText; 56#endif 57 58- (id) init; 59- (id) initWithTreeNode:(ANTLRCommonTree *)aNode; 60- (id) initWithToken:(ANTLRCommonToken *)aToken; 61- (id) initWithTokenType:(NSInteger)aTokenType; 62- (id) initWithTokenType:(NSInteger)aTokenType Text:(NSString *)theText; 63 64- (id<ANTLRTree>) copyWithZone:(NSZone *)aZone; 65 66- (BOOL) isNil; 67 68- (ANTLRCommonToken *) getToken; 69- (void) setToken:(ANTLRCommonToken *)aToken; 70- (id<ANTLRTree>) dupNode; 71- (NSInteger) getType; 72- (NSString *) getText; 73- (NSUInteger) getLine; 74- (NSUInteger) getCharPositionInLine; 75- (ANTLRCommonTree *) getParent; 76- (void) setParent:(ANTLRCommonTree *) t; 77 78#ifdef DONTUSENOMO 79- (NSString *) treeDescription; 80#endif 81- (NSString *) description; 82- (void) setUnknownTokenBoundaries; 83- (NSInteger) getTokenStartIndex; 84- (void) setTokenStartIndex: (NSInteger) aStartIndex; 85- (NSInteger) getTokenStopIndex; 86- (void) setTokenStopIndex: (NSInteger) aStopIndex; 87 88@end 89