Beispiel #1
0
void deal_with_declarator(){
	//Check if array/func exist
	switch(currToken.mType){
	case '[': 
		deal_with_arrays();
		break;
	case '(':
		deal_with_function_args();
	}

	deal_with_pointers();
	
	while(top >= 0 ){
		if(tokenStack[top].mType == '('){
			pop;
			getToken();	
			deal_with_declarator();
		}else{
			printf("%s ",pop.mStr);
		}
	}
}
Beispiel #2
0
deal_with_declarator(){
	/*处理标识符之后可能存在的数组/函数 */
	switch(cur.type){
		case '[':
			deal_with_arrays();
			break;
		case '(':
			deal_with_function_args();
	}

	deal_with_pointers();

	/* 处理在读入到标识符之前压入到堆栈中的符号 */
	while(top >= 0){
		if(stack[top].type == '('){
			pop;
			gettoken();
			deal_with_declarator();
		}else{
			printf("%s ", pop.string);
		}
	}
}
Beispiel #3
0
void deal_with_declarator() {
	if(curr_token.type == '[')
		deal_with_arrays();
	if(curr_token.type == '(')
		deal_with_function_args();

	deal_with_any_pointers();

	while(stack_top > -1) {
		if(token_stack[stack_top].type == '(') {
			if(curr_token.type != ')') {
				printf("Bad Syntax! Expected ')', got %s\n", curr_token.string);
				done();
			}
			get_token();
			stack_top--;
			deal_with_declarator();
		}
		else {
			printf("%s ", token_stack[stack_top].string);
			stack_top--;
		}
	}
}