1324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// [The "BSD licence"]
2324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// Copyright (c) 2006-2007 Kay Roepke 2010 Alan Condit
3324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// All rights reserved.
4324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//
5324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// Redistribution and use in source and binary forms, with or without
6324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// modification, are permitted provided that the following conditions
7324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// are met:
8324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// 1. Redistributions of source code must retain the above copyright
9324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//    notice, this list of conditions and the following disclaimer.
10324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// 2. Redistributions in binary form must reproduce the above copyright
11324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//    notice, this list of conditions and the following disclaimer in the
12324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//    documentation and/or other materials provided with the distribution.
13324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// 3. The name of the author may not be used to endorse or promote products
14324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//    derived from this software without specific prior written permission.
15324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//
16324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
27324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
28324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#import <Cocoa/Cocoa.h>
29324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
30324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#ifndef DEBUG_DEALLOC
31324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#define DEBUG_DEALLOC
32324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#endif
33324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
34324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruvertypedef enum {
35324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    ANTLRTokenTypeEOF = -1,
36324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    ANTLRTokenTypeInvalid,
37324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    ANTLRTokenTypeEOR,
38324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    ANTLRTokenTypeDOWN,
39324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    ANTLRTokenTypeUP,
40324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    ANTLRTokenTypeMIN
41324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver} ANTLRTokenType;
42324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
43324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruvertypedef enum {
44324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    ANTLRTokenChannelDefault = 0,
45324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    ANTLRTokenChannelHidden = 99
46324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver} ANTLRTokenChannel;
47324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
48324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#define HIDDEN 99
49324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
50324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver@protocol ANTLRToken < NSObject, NSCopying >
51324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
52324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver@property (retain, getter = text, setter = setText:) NSString *text;
53324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver@property (assign) NSInteger type;
54324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver@property (assign) NSUInteger line;
55324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver@property (assign) NSUInteger charPositionInLine;
56324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
57324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// The singleton eofToken instance.
58324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver+ (id<ANTLRToken>) eofToken;
59324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// The default channel for this class of Tokens
60324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver+ (ANTLRTokenChannel) defaultChannel;
61324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
62324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// provide hooks to explicitely set the text as opposed to use the indices into the CharStream
63324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver- (NSString *) text;
64324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver- (void) setText:(NSString *)theText;
65324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
66324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver- (NSInteger)type;
67324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver- (void) setType: (NSInteger) aType;
68324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
69324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// ANTLR v3 provides automatic line and position tracking. Subclasses do not need to
70324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// override these, if they do not want to store line/pos tracking information
71324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver- (NSUInteger)line;
72324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver- (void) setLine: (NSUInteger) aLine;
73324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
74324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver- (NSUInteger)charPositionInLine;
75324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver- (void) setCharPositionInLine:(NSUInteger)aCharPositionInLine;
76324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
77324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// explicitely change the channel this Token is on. The default parser implementation
78324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// just sees the defaultChannel
79324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// Common idiom is to put whitespace tokens on channel 99.
80324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver- (NSUInteger)channel;
81324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver- (void) setChannel: (NSUInteger) aChannel;
82324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
83324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// the index of this Token into the TokenStream
84324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver- (NSInteger) getTokenIndex;
85324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver- (void) setTokenIndex: (NSInteger) aTokenIndex;
86324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver- (NSString *)toString;
87324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
88324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver@end
89324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
90