aboutsummaryrefslogtreecommitdiff
path: root/runtime/ObjC/ANTLR.framework/Headers/ANTLRRecognizerSharedState.h
blob: 0430b797df060c6c53404224f851dad5abb25b40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// [The "BSD licence"]
// Copyright (c) 2007 Kay Roepke 2010 Alan Condit
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
//    derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#import <Cocoa/Cocoa.h>
#import "ANTLRToken.h"
#import "ANTLRBitSet.h"
#import "ANTLRRuleStack.h"

@interface ANTLRRecognizerSharedState : NSObject {
	NSMutableArray *following;          // a stack of FOLLOW bitsets used for context sensitive prediction and recovery
    NSInteger _fsp;                     // Follow stack pointer
	BOOL errorRecovery;                 // are we recovering?
	NSInteger lastErrorIndex;
	BOOL failed;                        // indicate that some match failed
    NSInteger syntaxErrors;
	NSInteger backtracking;             // the level of backtracking
	ANTLRRuleStack *ruleMemo;			// store previous results of matching rules so we don't have to do it again. Hook in incremental stuff here, too.

	id<ANTLRToken> token;
	NSInteger  tokenStartCharIndex;
	NSUInteger tokenStartLine;
	NSUInteger tokenStartCharPositionInLine;
	NSUInteger channel;
	NSUInteger type;
	NSString   *text;
}

@property (retain, getter=getFollowing, setter=setFollowing:) NSMutableArray *following;
@property (assign) NSInteger _fsp;
@property (assign) BOOL errorRecovery;
@property (assign) NSInteger lastErrorIndex;
@property (assign, getter=getFailed, setter=setFailed:) BOOL failed;
@property (assign) NSInteger syntaxErrors;
@property (assign, getter=getBacktracking, setter=setBacktracking) NSInteger backtracking;
@property (retain, getter=getRuleMemo, setter=setRuleMemo:) ANTLRRuleStack *ruleMemo;
@property (copy, getter=getToken, setter=setToken) id<ANTLRToken> token;
@property (getter=getType,setter=setType:) NSUInteger type;
@property (getter=getChannel,setter=setChannel:) NSUInteger channel;
@property (getter=getTokenStartLine,setter=setTokenStartLine:) NSUInteger tokenStartLine;
@property (getter=getCharPositionInLine,setter=setCharPositionInLine:) NSUInteger tokenStartCharPositionInLine;
@property (getter=getTokenStartCharIndex,setter=setTokenStartCharIndex:) NSInteger tokenStartCharIndex;
@property (retain, getter=getText, setter=setText) NSString *text;

+ (ANTLRRecognizerSharedState *) newANTLRRecognizerSharedState;
+ (ANTLRRecognizerSharedState *) newANTLRRecognizerSharedStateWithRuleLen:(NSInteger)aLen;
+ (ANTLRRecognizerSharedState *) newANTLRRecognizerSharedState:(ANTLRRecognizerSharedState *)aState;

- (id) init;
- (id) initWithRuleLen:(NSInteger)aLen;
- (id) initWithState:(ANTLRRecognizerSharedState *)state;

- (id<ANTLRToken>) getToken;
- (void) setToken:(id<ANTLRToken>) theToken;

- (NSUInteger) getType;
- (void) setType:(NSUInteger) theTokenType;

- (NSUInteger) getChannel;
- (void) setChannel:(NSUInteger) theChannel;

- (NSUInteger) getTokenStartLine;
- (void) setTokenStartLine:(NSUInteger) theTokenStartLine;

- (NSUInteger) getCharPositionInLine;
- (void) setCharPositionInLine:(NSUInteger) theCharPosition;

- (NSInteger) getTokenStartCharIndex;
- (void) setTokenStartCharIndex:(NSInteger) theTokenStartCharIndex;

- (NSString *) getText;
- (void) setText:(NSString *) theText;


- (NSMutableArray *) getFollowing;
- (void)setFollowing:(NSMutableArray *)aFollow;
- (ANTLRRuleStack *) getRuleMemo;
- (void)setRuleMemo:(ANTLRRuleStack *)aRuleMemo;
- (BOOL) isErrorRecovery;
- (void) setIsErrorRecovery: (BOOL) flag;

- (BOOL) getFailed;
- (void) setFailed: (BOOL) flag;

- (NSInteger)  getBacktracking;
- (void) setBacktracking:(NSInteger) value;
- (void) increaseBacktracking;
- (void) decreaseBacktracking;
- (BOOL) isBacktracking;

- (NSInteger) lastErrorIndex;
- (void) setLastErrorIndex:(NSInteger) value;

@end