Home | History | Annotate | Download | only in Framework
      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 "ANTLRUnbufferedCommonTreeNodeStreamState.h"
     28 
     29 
     30 @implementation ANTLRUnbufferedCommonTreeNodeStreamState
     31 
     32 - (id) init
     33 {
     34 	if ((self = [super init]) != nil) {
     35 		lookahead = [[NSMutableArray alloc] init];
     36 	}
     37 	return self;
     38 }
     39 
     40 - (void) dealloc
     41 {
     42 	[self setLookahead:nil];
     43 	[self setCurrentNode:nil];
     44 	[self setPreviousNode:nil];
     45 	[super dealloc];
     46 }
     47 
     48 - (ANTLRCommonTree *) currentNode
     49 {
     50     return currentNode; 
     51 }
     52 
     53 - (void) setCurrentNode: (ANTLRCommonTree *) aCurrentNode
     54 {
     55     if (currentNode != aCurrentNode) {
     56         [aCurrentNode retain];
     57         [currentNode release];
     58         currentNode = aCurrentNode;
     59     }
     60 }
     61 
     62 - (ANTLRCommonTree *) previousNode
     63 {
     64     return previousNode; 
     65 }
     66 
     67 - (void) setPreviousNode: (ANTLRCommonTree *) aPreviousNode
     68 {
     69     if (previousNode != aPreviousNode) {
     70         [aPreviousNode retain];
     71         [previousNode release];
     72         previousNode = aPreviousNode;
     73     }
     74 }
     75 
     76 - (NSInteger) currentChildIndex
     77 {
     78     return currentChildIndex;
     79 }
     80 
     81 - (void) setCurrentChildIndex: (NSInteger) aCurrentChildIndex
     82 {
     83     currentChildIndex = aCurrentChildIndex;
     84 }
     85 
     86 - (NSInteger) absoluteNodeIndex
     87 {
     88     return absoluteNodeIndex;
     89 }
     90 
     91 - (void) setAbsoluteNodeIndex: (NSInteger) anAbsoluteNodeIndex
     92 {
     93     absoluteNodeIndex = anAbsoluteNodeIndex;
     94 }
     95 
     96 - (NSUInteger) nodeStackSize
     97 {
     98     return nodeStackSize;
     99 }
    100 
    101 - (void) setNodeStackSize: (NSUInteger) aNodeStackSize
    102 {
    103     nodeStackSize = aNodeStackSize;
    104 }
    105 
    106 - (NSUInteger) indexStackSize
    107 {
    108     return indexStackSize;
    109 }
    110 
    111 - (void) setIndexStackSize: (NSUInteger) anIndexStackSize
    112 {
    113     indexStackSize = anIndexStackSize;
    114 }
    115 
    116 - (NSMutableArray *) lookahead
    117 {
    118     return lookahead; 
    119 }
    120 
    121 - (void) setLookahead: (NSMutableArray *) aLookahead
    122 {
    123     if (lookahead != aLookahead) {
    124         [aLookahead retain];
    125         [lookahead release];
    126         lookahead = aLookahead;
    127     }
    128 }
    129 
    130 - (void) addToLookahead: (id)lookaheadObject
    131 {
    132     [[self lookahead] addObject: lookaheadObject];
    133 }
    134 - (void) removeFromLookahead: (id)lookaheadObject
    135 {
    136     [[self lookahead] removeObject: lookaheadObject];
    137 }
    138 
    139 
    140 @end
    141