Improved Evaluation
This commit is contained in:
60
MathPad/MPToken.h
Normal file
60
MathPad/MPToken.h
Normal 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
|
||||
Reference in New Issue
Block a user