main.c 2.7 KB
Newer Older
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
1
2

#include <stdio.h>
3
#include <string.h>
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
4

5
#include "desc.h"
6
#include "prim.h"
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
7
#include "parse.h"
8
#include "code.h"
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
9
#include "mem.h"
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
10
11
12
13

int main()
{   
	init_mem();
14
	init_desc();
15
	init_prim();
16
	
17
	//char* funstream = "40 R10 example._R2 1 9 example.a9 example.b37 F12 example.g_482 3 AF3 add2 VA0 VA1 39 C9 example.fAF12 example.g_482 LI1 LI2 55 F13 example.Start0 0 AF10 example._R2 LI1 VF9 example.f29 F4 main0 0 VF13 example.Start";
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
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
	
	// OK char* funstream = "25 F13 example.Start0 0 LI1 29 F4 main0 0 VF13 example.Start";
	// 1
	// OK char* funstream = "20 F9 example.c1 1 VA0 40 F13 example.Start0 0 AF9 example.c1 LI1 29 F4 main0 0 VF13 example.Start";
	// 1
	// OK char* funstream = "20 F9 example.c2 1 VA0 44 F13 example.Start0 0 AF9 example.c2 LI2 LI1 29 F4 main0 0 VF13 example.Start";
	// 1	
	// OK char* funstream = "20 F9 example.c2 2 VA1 44 F13 example.Start0 0 AF9 example.c2 LI2 LI1 29 F4 main0 0 VF13 example.Start";
	// 2
	// OK char* funstream = "20 F9 example.c2 2 VA1 40 F13 example.Start0 0 AF9 example.c1 LI2 29 F4 main0 0 VF13 example.Start";
	// example.c 2
	// OK char* funstream = "20 F9 example.c3 7 VA1 40 F13 example.Start0 0 AF9 example.c1 LI1 29 F4 main0 0 VF13 example.Start";
	// example.c 1	
	// OK char* funstream = "20 F9 example.c3 7 VA1 40 F13 example.Start0 0 AF9 example.c1 LI1 29 F4 main0 0 VF13 example.Start";
	// example.c 1
	// OK char* funstream = "20 F9 example.c3 7 VA1 44 F13 example.Start0 0 AF9 example.c2 LI1 LI2 29 F4 main0 0 VF13 example.Start";
	// example.c 1 2
	// OK char* funstream = "20 F9 example.c3 7 VA1 49 F13 example.Start0 0 AF9 example.c3 LI1 LI33 LI2 29 F4 main0 0 VF13 example.Start";
	// 33
	// OK char* funstream = "33 A2 9 example.A2 2 9 example.B0 0 34 F13 example.Start0 0 VF9 example.B29 F4 main0 0 VF13 example.Start";
	// example.B
	// char* funstream = "33 A2 9 example.A2 2 9 example.B0 0 40 F13 example.Start0 0 AF9 example.A1 LI5 29 F4 main0 0 VF13 example.Start";
	// example.A 5
	// OK char* funstream = "33 A2 9 example.A2 2 9 example.B0 0 44 F13 example.Start0 0 AF9 example.A2 LI5 LI6 29 F4 main0 0 VF13 example.Start";
	// example.A 5 6
	// char* funstream = "40 R10 example._R2 1 9 example.a9 example.b46 F13 example.Start0 0 AF10 example._R2 LI6 LI7 29 F4 main0 0 VF13 example.Start";
	// example._R 6 7
	
	int nrfuns = parse(&funstream, strlen(funstream));		
47
48
49
50
	printf("Number of functions parsed: %d\n", nrfuns);	
		
	// TODO: put it into a special "expression" space, instead of "code"

51
	char *exprstream = "VF13 example.Start";
52
53
	
	Code* expr = parseTerm(&exprstream);	
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
54
55
56
	Thunk* res = exec(expr, stack_top);
		
	print(eval(res));
57
	
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
58
//   add_fun("jimbo", (Desc*) "artist");
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
59
60
61
//   char *tval = (char*) find_fun("jimbo");
//   printf ("shortcut tval for jimbo = %s\n", tval);   
}