forked from natikgadzhi/XNMaths
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGCMathParser.h
More file actions
49 lines (33 loc) · 1.1 KB
/
GCMathParser.h
File metadata and controls
49 lines (33 loc) · 1.1 KB
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
//
// GCMathParser.h
// GCDrawKit
//
// Created by graham on 28/08/2007.
// Copyright 2007 Apptree.net. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "ZExpParser.h"
@interface GCMathParser : NSObject
{
symbol* _st; // symbol table; singly linked list
NSString* _expr; // retained expression
double _result; // the result of the evaluation
}
+ (double) evaluate:(NSString*) expression;
+ (GCMathParser*) parser;
- (double) evaluate:(NSString*) expression;
- (NSString*) expression;
- (const char*) expressionCString;
- (void) setSymbolValue:(double) value forKey:(NSString*) key;
- (double) symbolValueForKey:(NSString*) key;
// private methods called internally:
- (symbol*) getSymbol:(NSString*) key;
- (symbol*) getSymbolForCString:(const char*) name;
- (symbol*) initSymbol:(const char*) name ofType:(int) type;
- (void) setResult:(double) result;
@end
// to simplify this even further for casual use (i.e. when you don't need variables), you can
// make use of this category on NSString:
@interface NSString (ExpressionParser)
- (double) evaluateMath;
@end