-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParser.h
More file actions
54 lines (39 loc) · 1.05 KB
/
Copy pathParser.h
File metadata and controls
54 lines (39 loc) · 1.05 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
50
51
52
53
#pragma once
#include<cstring>
#include<vector>
#include<list>
#include<string>
#include<fstream>
#include<cmath>
#include<functional>
#include<cstdlib>
typedef std::vector<const char*>::iterator t_dlmt_iter;
typedef std::list<char*>::iterator t_char_iter;
template<class T>
struct Operator{
Operator(const char *s, std::function<T(T,T)> f, unsigned short arity):_symbol(s),_function(f),_arity(arity){}
T Fire(T a,T b){return _function(a,b);}
const char* _symbol;
std::function<T(T,T)> _function;
unsigned short _arity;
};
struct ExpressionInterval{
ExpressionInterval(unsigned i, unsigned j):_start(i),_end(j){}
void Set(unsigned i, unsigned j){_start=i;_end=j;}
unsigned _start;
unsigned _end;
};
class Parser
{
public:
Parser(void);
~Parser(void);
float ParseInput(char *in);
bool StrCompare(char *one, const char *two, unsigned numberOfChars);
private:
void NewInput(char *input);
float BuildSubTree(ExpressionInterval ei,int delimiter);
float Leaf(ExpressionInterval ei);
std::vector<Operator<float>* > _operators;
char *_inputString;
};