language

Some fools attempt at an interpreted language
Log | Files | Refs

test.c (748B)


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
#include <stdio.h>

#include "fh.h"
#include "is.h"
#include "bc.h"

int main(int argc, char** argv)
{
	if (argc < 2) return -1;
	init();

	// start testing
	bc_cont* bc = bc_read(argv[1]);
	bc_cont* ptr;
	
	for (ptr = bc; ptr->next != NULL; ptr = ptr->next)
	{
		if (ptr->op == 1)
		{
			printf("%x:\n", ptr->op);
		}
		if (ptr->op == 2)
		{
			printf("%x: %x\n", ptr->op, ptr->args[0][0]);
		}
		if (ptr->op == 3)
		{
			printf("%x: %x, %x %x\n",
			       ptr->op, ptr->args[0][0], ptr->args[1][0], ptr->args[1][1]);
		}
		if (ptr->op == 4)
		{
			printf("%x: ", ptr->op);
			int len = sizeof(ptr->args[0]);
			for (int i = 0; i < len; i++) printf("%x ", ptr->args[0][i]);
			printf("\n");
		}
	}

	bc_cont_del(bc);
	// end testing
	return 0;
}