Home | History | Annotate | Download | only in Headers
      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 
     28 #import <Cocoa/Cocoa.h>
     29 #import "ANTLRToken.h"
     30 #import "ANTLRCharStream.h"
     31 
     32 @interface ANTLRCommonToken : NSObject < ANTLRToken > {
     33 	NSString *text;
     34 	NSInteger type;
     35 	// information about the Token's position in the input stream
     36 	NSUInteger line;
     37 	NSUInteger charPositionInLine;
     38 	NSUInteger channel;
     39 	// this token's position in the TokenStream
     40 	NSUInteger index;
     41 
     42 	// indices into the CharStream to avoid copying the text
     43 	// can manually override the text by using -setText:
     44 	NSUInteger startIndex;
     45 	NSUInteger stopIndex;
     46 	// the actual input stream this token was found in
     47 	id<ANTLRCharStream> input;
     48 }
     49 
     50 @property (retain, getter=getText, setter=setText:) NSString *text;
     51 @property (assign, getter=getType, setter=setType:) NSInteger type;
     52 @property (assign, getter=getLine, setter=setLine:) NSUInteger line;
     53 @property (assign, getter=getCharPositionInLine, setter=setCharPositionInLine:) NSUInteger charPositionInLine;
     54 @property (assign, getter=getChannel, setter=setChannel:) NSUInteger channel;
     55 @property (assign, getter=getTokenIndex, setter=setTokenIndex:) NSUInteger index;
     56 @property (assign, getter=getStart, setter=setStart:) NSUInteger startIndex;
     57 @property (assign, getter=getStop, setter=setStop:) NSUInteger stopIndex;
     58 @property (retain, getter=getInput, setter=setInput:) id<ANTLRCharStream> input;
     59 
     60 + (void) initialize;
     61 + (ANTLRCommonToken *) newANTLRCommonToken;
     62 + (ANTLRCommonToken *) newANTLRCommonToken:(id<ANTLRCharStream>)anInput
     63                                       Type:(NSInteger)aTType
     64                                    Channel:(NSInteger)aChannel
     65                                      Start:(NSInteger)aStart
     66                                       Stop:(NSInteger)aStop;
     67 + (ANTLRCommonToken *) newANTLRCommonToken:(ANTLRTokenType)aType;
     68 + (id<ANTLRToken>) newANTLRCommonToken:(NSInteger)tokenType Text:(NSString *)tokenText;
     69 + (id<ANTLRToken>) newANTLRCommonTokenWithToken:(id<ANTLRToken>)fromToken;
     70 + (id<ANTLRToken>) eofToken;
     71 + (id<ANTLRToken>) skipToken;
     72 + (id<ANTLRToken>) invalidToken;
     73 + (ANTLRTokenChannel) defaultChannel;
     74 
     75 // designated initializer. This is used as the default way to initialize a Token in the generated code.
     76 - (ANTLRCommonToken *) init;
     77 - (ANTLRCommonToken *) initWithInput:(id<ANTLRCharStream>)anInput
     78                                 Type:(NSInteger)aTType
     79                              Channel:(NSInteger)aChannel
     80                                Start:(NSInteger)theStart
     81                                 Stop:(NSInteger)theStop;
     82 - (ANTLRCommonToken *) initWithToken:(ANTLRCommonToken *)aToken;
     83 - (ANTLRCommonToken *) initWithType:(ANTLRTokenType)aType;
     84 - (ANTLRCommonToken *) initWithType:(ANTLRTokenType)aTType Text:(NSString *)tokenText;
     85 
     86 - (id<ANTLRCharStream>) getInput;
     87 - (void) setInput: (id<ANTLRCharStream>) anInput;
     88 
     89 - (NSUInteger) getStart;
     90 - (void) setStart: (NSUInteger) aStart;
     91 
     92 - (NSUInteger) getStop;
     93 - (void) setStop: (NSUInteger) aStop;
     94 
     95 // the index of this Token into the TokenStream
     96 - (NSUInteger) getTokenIndex;
     97 - (void) setTokenIndex: (NSUInteger) aTokenIndex;
     98 
     99 // conform to NSCopying
    100 - (id) copyWithZone:(NSZone *)theZone;
    101 
    102 - (NSString *) description;
    103 - (NSString *) toString;
    104 
    105 @end
    106