Radicalc  Diff

Differences From Artifact [cec9092081]:

  • File bootstrap/main.c — part of check-in [bc1494a7d4] at 2017-07-05 01:41:48 on branch trunk — var use (user: athaudia size: 9961)

To Artifact [3a600d8d3c]:

  • File bootstrap/main.c — part of check-in [29ec2b46a7] at 2017-07-05 01:47:15 on branch trunk — restructured data type printing (user: athaudia size: 10080)

372
373
374
375
376
377
378







379
380
381
382
383
384
385
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392







+
+
+
+
+
+
+







	for(int i = 0; i < token_len; ++i)
		printf("TOKEN %d %s\n", tokens[i].type, tokens[i].str);
}

void print_indent(int num) {
	for(int i = 0; i < num; ++i) printf("  ");
}

void print_data_type(struct data_type* data_type) {
	if(data_type->name)
		printf("%s", data_type->name);
	else
		printf("void");
}

void print_tree(struct node* node, int indent) {
	switch(node->type) {
		case NODE_ROOT:
			for(int j = 0; j < node->child_count; ++j) {
				print_tree(node->childs[j], 0);
				printf("\n");
410
411
412
413
414
415
416
417
418
419


420

421

422
423
424
425
426
427
428
417
418
419
420
421
422
423



424
425
426
427

428
429
430
431
432
433
434
435







-
-
-
+
+

+
-
+







			printf("(UNKNOWN TOKEN)");
	}
}

void print_functions() {
	for(int i = 0; i < function_count; ++i) {
		struct function* fun = functions[i];
		printf("%s %s(",
			   fun->return_type.name?fun->return_type.name:"void",
			   fun->name);
		print_data_type(&fun->return_type);
		printf(" %s(", fun->name);
		for(int i = 0; i < fun->param_count; ++i) {
			print_data_type(&fun->params[i].data_type);
			printf("%s %s", fun->params[i].data_type.name, fun->params[i].name);
			printf(" %s", fun->params[i].name);
			if(i < fun->param_count-1)
				printf(", ");
		}
		printf(")\n");
		for(int j = 0; j < fun->body->child_count; ++j) {
			print_tree(fun->body->childs[j], 1);
			printf(";\n");