Archived
1

Fundamental Redesign of Evaluation

This commit is contained in:
Kim Wittenburg
2014-11-24 22:42:44 +01:00
parent 10f0e73ad3
commit 7a32e3b0b6
45 changed files with 1398 additions and 350 deletions

View File

@@ -18,7 +18,7 @@
@property (nonatomic) NSUInteger currentTokenIndex;
@property (nonatomic) NSUInteger eofLocation;
@property (nonatomic) BOOL *whitespaceIgnores;
@property (nonatomic) BOOL *whitespaceStates;
@property (nonatomic) NSUInteger maxWhitespaceIgnores;
@property (nonatomic) NSUInteger currentWhitespaceIgnoreState;
@@ -34,7 +34,7 @@
self = [super init];
if (self) {
self.tokens = tokens;
self.whitespaceIgnores = malloc(10 * sizeof(BOOL));
self.whitespaceStates = malloc(10 * sizeof(BOOL));
self.maxWhitespaceIgnores = 10;
self.currentWhitespaceIgnoreState = 0;
[self beginAcceptingWhitespaceTokens];
@@ -66,14 +66,14 @@
self.currentWhitespaceIgnoreState++;
if (self.currentWhitespaceIgnoreState >= self.maxWhitespaceIgnores) {
self.maxWhitespaceIgnores += 10;
BOOL *reallocatedWhitespaceIgnores = realloc(self.whitespaceIgnores, self.maxWhitespaceIgnores);
BOOL *reallocatedWhitespaceIgnores = realloc(self.whitespaceStates, self.maxWhitespaceIgnores);
if (reallocatedWhitespaceIgnores) {
self.whitespaceIgnores = reallocatedWhitespaceIgnores;
self.whitespaceStates = reallocatedWhitespaceIgnores;
} else {
@throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Realloc Failed" userInfo:nil];
}
}
self.whitespaceIgnores[self.currentWhitespaceIgnoreState] = state;
self.whitespaceStates[self.currentWhitespaceIgnoreState] = state;
}
@@ -85,7 +85,7 @@
- (void)skipWhitespaces
{
if (self.whitespaceIgnores[self.currentWhitespaceIgnoreState]) {
if (self.whitespaceStates[self.currentWhitespaceIgnoreState]) {
return;
}
while (_currentTokenIndex < self.tokens.count) {
@@ -93,7 +93,7 @@
if (token.tokenType != MPWhitespaceToken) {
return;
}
[self currentTokenConsumed];
_currentTokenIndex++;
}
}
@@ -134,7 +134,7 @@
- (void)dealloc
{
free(self.whitespaceIgnores);
free(self.whitespaceStates);
}
@end