Archived
1

Improved Evaluation

This commit is contained in:
Kim Wittenburg
2014-09-28 23:50:18 +02:00
parent 43b6f78afb
commit d67a1949e9
19 changed files with 841 additions and 89 deletions

60
MathPad/MPToken.h Normal file
View File

@@ -0,0 +1,60 @@
//
// MPToken.h
// MathPad
//
// Created by Kim Wittenburg on 19.09.14.
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSUInteger, MPTokenType) {
MPEOFToken = 0,
MPMultiplicationSymbolToken,
MPOperatorListToken,
MPSinToken,
MPCosToken,
MPTanToken,
MPNumberToken,
MPVariableToken,
MPEqualsToken,
MPGenericFunctionToken,
MPWhitespaceToken,
MPUnidentifiedToken,
MPCompoundToken
};
@protocol MPToken <NSObject>
- (MPTokenType)tokenType;
- (NSRange)range;
- (NSString *)stringValue;
@end
@interface MPToken : NSObject <MPToken>
- (instancetype)initEOFTokenAtLocation:(NSUInteger)eofLocation;
- (instancetype)initWithRange:(NSRange)range inString:(NSString *)input;
- (instancetype)initWithTokenType:(MPTokenType)tokenType
range:(NSRange)range
inString:(NSString *)input;
@end
@interface MPToken (MPTokenExtension)
// Methods are only available for respective token type
- (NSUInteger)numberOfOperators;
- (NSDecimalNumber *)operatorValue;
- (NSDecimalNumber *)number;
- (NSString *)variable;
@end