-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.c
More file actions
executable file
·66 lines (54 loc) · 1.42 KB
/
Copy pathparser.c
File metadata and controls
executable file
·66 lines (54 loc) · 1.42 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
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include "src/mparse.h"
void elem_free(void * obj){
free(obj);
}
void elem_print(void * obj){
printf("%s \n",(char*)obj);
}
#define INIT_TIMERS() struct timeval start,stop, result
#define MEASURE_TIME(x) do{\
gettimeofday(&start, NULL);\
x;\
gettimeofday(&stop, NULL);\
timersub(&stop, &start, &result);\
printf("TIME = %i,%05i\n", (int) result.tv_sec, (int) result.tv_usec);\
}while(0)
//Time meeasuring
//
// gettimeofday(&start, NULL);
// gettimeofday(&stop, NULL);
// timersub(&stop, &start, &result);
// printf("Expanding time = %i,%05i\n", (int) result.tv_sec, (int) result.tv_usec);
int main(int args, char *argv[])
{
//Parser tree generation test
if(args-1==1)
{
// INIT_TIMERS();
mparser_t *p = new mparser_t();
p->function((char *)"f(a)",(char *)"cos(a)");
p->expression(argv[1]);
p->variable((char *) "x", 3);
p->variable((char *) "y", 7);
parser_val_t res = p->calculate();
printf("result = %f\n", res);
p->variable((char *) "x", 11);
p->variable((char *) "y", 13);
res = p->calculate();
printf("result = %f\n", res);
p->variable((char *) "x", 2);
p->variable((char *) "y", 3);
res = p->calculate();
printf("result = %f\n", res);
p->variable((char *) "x", 2);
p->variable((char *) "y", 3);
res = p->calculate();
printf("result = %f\n", res);
// delete p;
}
return 0;
}