Пример #1
0
void doDefList(TreeNode *p) {
	//printf("doDefList\n");
	//printf("TreeNode->state:%s\n", p->state);
	switch (p->productionRule) {
		case 1:{
			TreeNode *p1 = p->firstChild;
			TreeNode *p2 = p1->rightBrother;
			doDef(p1);
			doDefList(p2);
			break;
			   }
		case 2:
			break;
	}
}
Пример #2
0
varElement* doDefList(TreeNode *p, int ifStruct) {
	//printf("doDefList\n");
	//printf("TreeNode->state:%s\n", p->state);
	switch (p->productionRule) {
		case 1:{
			TreeNode *p1 = p->firstChild;
			TreeNode *p2 = p1->rightBrother;
			varElement *ele1 = doDef(p1, ifStruct);
			varElement *ele2 = doDefList(p2, ifStruct);
			if (ifStruct == 1) { 	//是结构体的成员处理
				while (ele1->next != NULL) {	//找到这个Def定义出的的最后一个varElement
					ele1 = ele1->next;				
				}
				ele1->next = ele2;	//和DefList的varElement链串联起来,返回
				return ele1;
			}
			break;
		}
		case 2:{
			return NULL;
			break;
		}
	}
}