Radicalc  Diff

Differences From Artifact [a79b110e8a]:

  • File bootstrap/main.c — part of check-in [550a1e44bb] at 2017-07-05 01:31:41 on branch trunk — function parameters (user: athaudia size: 9787)

To 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)

165
166
167
168
169
170
171
172

173
174
175
176
177
178
179
/*                                                                            */
/*   PARSER                                                                   */
/*                                                                            */
/******************************************************************************/

int parse_pos;

enum node_type { NODE_ROOT, NODE_FUNBODY, NODE_FUNDEF, NODE_FUNCALL, NODE_LITERAL_INT };


struct data_type {
	char* name;
};


struct node {







|
>







165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*                                                                            */
/*   PARSER                                                                   */
/*                                                                            */
/******************************************************************************/

int parse_pos;

enum node_type { NODE_ROOT, NODE_FUNBODY, NODE_FUNDEF, NODE_FUNCALL,
	NODE_VAR_USE, NODE_LITERAL_INT };

struct data_type {
	char* name;
};


struct node {
266
267
268
269
270
271
272


273
274
275
276
277
278
279
280
		}
	}
	expect(TOK_PAREN_CLOSE);
	return node;
}

struct node* p_var_use() {


	/* todo: implement */
}

struct node* p_expr() {
	switch(tokens[parse_pos].type) {
		case TOK_IDENT:
			if(tokens[parse_pos+1].type == TOK_PAREN_OPEN)
				return p_func_call();







>
>
|







267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
		}
	}
	expect(TOK_PAREN_CLOSE);
	return node;
}

struct node* p_var_use() {
	struct node* node = node_new(NODE_VAR_USE);
	node->name = expect(TOK_IDENT)->str;
	return node;
}

struct node* p_expr() {
	switch(tokens[parse_pos].type) {
		case TOK_IDENT:
			if(tokens[parse_pos+1].type == TOK_PAREN_OPEN)
				return p_func_call();
391
392
393
394
395
396
397




398
399
400
401
402
403
404
					printf(",\n");
				else
					printf("\n");
			}
			print_indent(indent);
			printf(")");
			break;




		case NODE_LITERAL_INT:
			print_indent(indent);
			printf("%s", node->val);
			break;
		default:
			printf("(UNKNOWN TOKEN)");
	}







>
>
>
>







394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
					printf(",\n");
				else
					printf("\n");
			}
			print_indent(indent);
			printf(")");
			break;
		case NODE_VAR_USE:
			print_indent(indent);
			printf("%s", node->name);
			break;
		case NODE_LITERAL_INT:
			print_indent(indent);
			printf("%s", node->val);
			break;
		default:
			printf("(UNKNOWN TOKEN)");
	}