Archived
1

Cleaned Code by Removing Location Tracking for Errors

This commit is contained in:
Kim Wittenburg
2014-11-07 19:50:28 +01:00
parent 91e7dbe9f2
commit 139a75f816
59 changed files with 355 additions and 532 deletions

View File

@@ -8,9 +8,7 @@
#import "MPOperatorChain.h"
@implementation MPOperatorChain {
NSRange _range;
}
@implementation MPOperatorChain
- (id)init
{
@@ -26,11 +24,12 @@
if (self) {
[tokenStream beginIgnoringWhitespaceTokens];
MPToken *currentToken = tokenStream.currentToken;
if (currentToken.tokenType != MPOperatorListToken) {
@throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Expected Operators" userInfo:nil];
}
NSString *operatorString = currentToken.stringValue;
_range = currentToken.range;
operatorString = [[operatorString componentsSeparatedByString:@" "] componentsJoinedByString:@""];
_negating = NO;
_numberOfOperators = operatorString.length;
@@ -39,18 +38,14 @@
_negating = !_negating;
}
}
[tokenStream currentTokenConsumed];
[tokenStream endIgnoringOrAcceptingWhitespaceTokens];
}
return self;
}
- (NSRange)range
{
return _range;
}
- (BOOL)validate:(MPParseError *__autoreleasing *)error
- (BOOL)validate:(NSError *__autoreleasing *)error
{
return YES;
}
@@ -60,16 +55,4 @@
return self.negating ? [[NSDecimalNumber alloc] initWithInteger:-1] : [NSDecimalNumber one];
}
- (NSArray *)expressionElements
{
NSMutableString *text = [[NSMutableString alloc] init];
for (NSUInteger index = 1; index < self.numberOfOperators; index++) {
[text appendString:@"+"];
}
if (self.negating) {
[text appendString:@"-"];
}
return @[text.copy];
}
@end