Пример #1
0
bool ADLSearch::matchesFile(const string& f, const string& fp, int64_t size) {
    // Check status
    if(!isActive) {
        return false;
    }

    // Check size for files
    if(size >= 0 && (sourceType == OnlyFile || sourceType == FullPath)) {
        if(minFileSize >= 0 && size < minFileSize * GetSizeBase()) {
            // Too small
            return false;
        }
        if(maxFileSize >= 0 && size > maxFileSize * GetSizeBase()) {
            // Too large
            return false;
        }
    }

    // Do search
    switch(sourceType) {
    default:
    case OnlyDirectory: return false;
    case OnlyFile:      return searchAll(f);
    case FullPath:      return searchAll(fp);
    }
}
Пример #2
0
DictBrowserSearch::DictBrowserSearch(QWidget *parent) :
    QWidget(parent)
{
    setupUi(this);

    connect(searchEdit, SIGNAL(textEdited(QString)), this, SLOT(searchAll()));
    connect(caseSensitiveCheckBox, SIGNAL(clicked()), this, SLOT(searchAll()));
    connect(wholeWordsCheckBox, SIGNAL(clicked()), this, SLOT(searchAll()));
}
Пример #3
0
void DictBrowserSearch::showEvent(QShowEvent * event)
{
    QWidget::showEvent(event);
    searchEdit->setFocus(Qt::OtherFocusReason);
    if (searchEdit->text().length())
        searchAll();
}
Пример #4
0
bool ADLSearch::matchesDirectory(const string& d) {
    // Check status
    if(!isActive) {
        return false;
    }
    if(sourceType != OnlyDirectory) {
        return false;
    }

    // Do search
    return searchAll(d);
}
Пример #5
0
Type doStructSpecifier(TreeNode *p) {	//待完成
	//printf("doStructSpecifier\n");
	//printf("production rule:%d\n", p->productionRule);
	switch (p->productionRule) {
		case 1: {
					TreeNode *p2 = p->firstChild->rightBrother;
					TreeNode *p4 = p2->rightBrother->rightBrother;
					char *tagname = doOptTag(p2);
					if (tagname != NULL) {	//有标签名,把它加入结构体表中
						if (searchStruct(tagname) != NULL || searchAll(tagname) != NULL) {
							printf("Error type 16 at line %d: struct tag %s is same as other struct tag or variable name\n", p->line, tagname);					
							return NULL;
						}
						structTableElement *str = (structTableElement *)malloc(sizeof(structTableElement));
						str->name = tagname;
						str->type = (Type)malloc(sizeof(struct Type_));
						str->type->kind = STRUCTURE;
						str->type->u.var = doDefList(p4, 1);
						insertStruct(str);
						return str->type;
					} else {
						Type temptype = (Type)malloc(sizeof(struct Type_));
						temptype->kind = STRUCTURE;
						temptype->u.var = doDefList(p4, 1);
						//showStructMember(temptype);
						return temptype;
					}
					break;
				}
		case 2: {
					//Tag要在之前定义过才能有效,去结构体表中查找
					TreeNode *p2 = p->firstChild->rightBrother;
					char *tagname = doTag(p2);
					structTableElement *str = searchStruct(tagname);
					if (str == NULL) {
						printf("Error type 17 at line %d: struct tag %s undefined\n", p->line, tagname);
						return NULL;
					} else {	//查找到,就将表中的type返回
						//showStructMember(str->type);
						return str->type;
					}
					break;
				}
	}
}
Пример #6
0
 void SpellingTrie::searchAll(Trie *trieRoot, char *s)
 {
     Trie *p = trieRoot;
     int i;
     if(p->isStr == true)
     {
     	if(position < Choice_Max_Num)
     	{
     		int j;
     		for(j=0; *(s+j)!='\0'; j++)
     		{
     			choice_list[position][j] = *(s+j);
     		}
     		choice_list[position][j] = '\0';
     		position ++;
     	}
     }
     for(i = 0;i < MAX;i++)
     {
         int len = strlen(s);
         char *q;
         char ch[Str_Max_Len];
         int j;
         for(j=0; *(s+j)!='\0'; j++)
         {
         	ch[j] = *(s+j);
         }
         ch[j] = (char)(i+'a');
         ch[j+1] = '\0';
         q = ch;
         if(p->next[i] != NULL)
         {
             searchAll(p->next[i],q);
         }
     }
 }
Пример #7
0
Type doExp(TreeNode *p) {
//	printf("doExp\n");
//	printf("TreeNode->state:%s\n", p->state);
//	printf("TreeNode->productionRule: %d\n", p->productionRule);
	if(strcmp(p->state, "Exp") == 0) {
		TreeNode *tempNode = p->firstChild;//产生式右边第一个符号
		switch (p->productionRule) {
			case 1:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   //Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);	
				   if (tempNode->productionRule > 16 || tempNode->productionRule < 14) {	//不符合唯一的三个能当右值的产生式
					   printf("Error type 6 at line %d: left expression illegal for assign\n", p->line);
				   }
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
//						   printf("Exp ASSIGNOP Exp\n");
//						   printf("tempNode->firstChild->addr_sp: %d\n", tempNode->firstChild->addr_sp);
						   fprintf(out_fp, "\tlw $t0, %d($sp)\n", temp2Node->firstChild->addr_sp - ADDR);
						   fprintf(out_fp, "\tsw $t0, %d($sp)\n", tempNode->firstChild->addr_sp - ADDR);
						   return t1;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 7 at line %d '=' type mismatch\n", p->line);//类型不匹配
						   OUT = false;//表示语义分析错误,删除已生成的目标文件
					   }
				   }
				break;
				   //exp = exp
				   }
			case 2:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;
						   ADDR -= 4;
						   p->firstChild->addr_sp = ADDR;//将表达式结果存在该地址处
						   fprintf(out_fp, "\taddi $sp, $sp, -4\n");
						   fprintf(out_fp, "\tlw $t0, %d($sp)\n", tempNode->firstChild->addr_sp);
						   fprintf(out_fp, "\tlw $t1, %d($sp)\n", temp2Node->firstChild->addr_sp);
						   fprintf(out_fp, "\tand $t0, $t0, $t1\n");
						   fprintf(out_fp, "\tsw $t0, 0($sp)\n"); 
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 7 at line %d '&&' type mismatch\n", p->line);//类型不匹配
						   OUT = false;
					   }
				   }
				break;
				//Exp AND Exp
				   }
			case 3:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;
						   ADDR -= 4;
						   p->firstChild->addr_sp = ADDR;//将表达式结果存在该地址处
						   fprintf(out_fp, "\taddi $sp, $sp, -4\n");
						   fprintf(out_fp, "\tlw $t0, %d($sp)\n", tempNode->firstChild->addr_sp);
						   fprintf(out_fp, "\tlw $t1, %d($sp)\n", temp2Node->firstChild->addr_sp);
						   fprintf(out_fp, "\tor $t0, $t0, $t1\n");
						   fprintf(out_fp, "\tsw $t0, 0($sp)\n"); 
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 7 at line %d '||' type mismatch\n", p->line);//类型不匹配
						   OUT = false;
					   }
				   }
				break;
				//Exp OR Exp
				   }
			case 4:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 7 at line %d 'RELOP' type mismatch\n", p->line);//类型不匹配
					   }
				   }
				break;
				//Exp RELOP Exp
				   }
			case 5:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;
//						   printf("t1->u.basic: %d\n", t1->u.basic);
						   ADDR -= 4;
						   p->firstChild->addr_sp = ADDR;
						   fprintf(out_fp, "\taddi $sp, $sp, -4\n");
						   fprintf(out_fp, "\tlw $t0, %d($sp)\n", tempNode->firstChild->addr_sp - ADDR);
						   fprintf(out_fp, "\tlw $t1, %d($sp)\n", temp2Node->firstChild->addr_sp - ADDR);
						   fprintf(out_fp, "\tadd $t0, $t0, $t1\n");
						   fprintf(out_fp, "\tsw $t0, 0($sp)\n"); 
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 7 at line %d '+' type mismatch\n", p->line);//类型不匹配
						   OUT = false;
					   }
				   }
				break;
				//Exp PLUS Exp
				   }
			case 6:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;

						   ADDR -= 4;
						   p->firstChild->addr_sp = ADDR;
						   fprintf(out_fp, "\taddi $sp, $sp, -4\n");
						   fprintf(out_fp, "\tlw $t0, %d($sp)\n", tempNode->firstChild->addr_sp - ADDR);
						   fprintf(out_fp, "\tlw $t1, %d($sp)\n", temp2Node->firstChild->addr_sp - ADDR);
						   fprintf(out_fp, "\tsub $t0, $t0, $t1\n");
						   fprintf(out_fp, "\tsw $t0, 0($sp)\n"); 
		
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 7 at line %d '-' type mismatch\n", p->line);//类型不匹配
					   }
				   }
				break;
				//Exp MINUS Exp
				   }
			case 7:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;

						   ADDR -= 4;
						   p->firstChild->addr_sp = ADDR;
						   fprintf(out_fp, "\taddi $sp, $sp, -4\n");
						   fprintf(out_fp, "\tlw $t0, %d($sp)\n", tempNode->firstChild->addr_sp - ADDR);
						   fprintf(out_fp, "\tlw $t1, %d($sp)\n", temp2Node->firstChild->addr_sp - ADDR);
						   fprintf(out_fp, "\tmul $t0, $t0, $t1\n");
						   fprintf(out_fp, "\tsw $t0, 0($sp)\n"); 
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 7 at line %d '*' type mismatch\n", p->line);//类型不匹配
					   }
				   }
				break;
				//Exp STAR Exp
				   }
			case 8:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;
						   ADDR -= 4;
						   p->firstChild->addr_sp = ADDR;
						   fprintf(out_fp, "\taddi $sp, $sp, -4\n");
						   fprintf(out_fp, "\tlw $t0, %d($sp)\n", tempNode->firstChild->addr_sp - ADDR);
						   fprintf(out_fp, "\tlw $t1, %d($sp)\n", temp2Node->firstChild->addr_sp - ADDR);
						   fprintf(out_fp, "\tdiv $t0, $t0, $t1\n");
						   fprintf(out_fp, "\tsw $t0, 0($sp)\n"); 
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 7 at line %d '/' type mismatch\n", p->line);//类型不匹配
					   }
				   }
				break;
				//Exp DIV Exp
				   }
			case 9:return doExp(tempNode->rightBrother);
				   //LP Exp RP
			case 10:return doExp(tempNode->rightBrother);
					//MINUS Exp
			case 11:return doExp(tempNode->rightBrother);
					//NOT Exp
				
			case 12:{funcTableElement *func = searchFunc(tempNode->value.idValue);
					if(func == NULL) {
						varElement *var = searchAll(tempNode->value.idValue);
						if (var != NULL) {
							printf("Error type 11 at line %d: normal variable %s uses '()'\n", p->line, tempNode->value.idValue);
						} else
							printf("Error type 4 at line %d: undefined function %s\n", p->line, tempNode->value.idValue);
						return NULL;
					}
					TreeNode *argNode = tempNode->rightBrother->rightBrother;
					argElement *args = doArgs(argNode);
					if (compareArgs(func->argListHeader, args) == 0) {	//参数匹配有问题
						printf("Error type 9 at line %d: function var list not matched %s\n", p->line, tempNode->value.idValue);
						return func->type;
					}
					break;
					//ID LP Args RP
				}
			case 13:{funcTableElement *func = searchFunc(tempNode->value.idValue);
					if(func == NULL) {
						varElement *var = searchAll(tempNode->value.idValue);
						if (var != NULL) {
							printf("Error type 11 at line %d: normal variable %s uses '()'\n", p->line, tempNode->value.idValue);
							OUT = false;
						} else {
							printf("Error type 4 at line %d:undefined function %s\n", p->line, tempNode->value.idValue);
							OUT = false;
						}
						return NULL;
					}
					else if (func->argListHeader != NULL) {	//函数定义中有参数而调用没有
						printf("Error type 9 at line %d:function var list not matched %s\n", p->line, tempNode->value.idValue);
						OUT = false;
						return func->type;
					}
					break;
					//ID LP RP
				}
			case 14:{Type type = (Type)malloc(sizeof(struct Type_));
					TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
					Type t1 = doExp(tempNode);
					Type t2 = doExp(temp2Node);
					if(tempNode != NULL && temp2Node != NULL) {
						if(t1->kind != ARRAY) {
							printf("Error type 10 at line %d: normal variable uses '[]'\n", p->line);
							OUT = false;
						}
						else if(t2->u.basic != 0) {
							printf("Error type 12 at line %d:int required\n", p->line);
							OUT = false;
						}
						else {
							type = doExp(tempNode)->u.array.elem;
//							printf("tempNode->firstChild->addr_sp: %d\n", tempNode->firstChild->addr_sp);
							tempNode->addr_sp = tempNode->firstChild->addr_sp - temp2Node->firstChild->value.intValue * 4;
							return type;
						}
					}
					break;
					//Exp LB Exp RB
					}
			case 15:{
					TreeNode *p3 = tempNode->rightBrother->rightBrother;
					Type t = doExp(tempNode);
					if(t != NULL) {
						if(t->kind != STRUCTURE) {
							printf("Error type 13 at line %d: error use of operator '.'\n", p->line);
						}
						else {
							//showStructMember(t);
;							varElement *field = t->u.var;
							while(field != NULL) {
								if(strcmp(field->name, p3->value.idValue) == 0) {
									return field->type;
								}
								field = field->next;
							}
							printf("Error type 14 at line %d:struct member %s undefined\n", p->line, tempNode->rightBrother->rightBrother->value.idValue);
							//结构体成员未定义
						}
					}
					break;
					//Exp DOT ID
					}
			case 16:{Type type = (Type)malloc(sizeof(struct Type_));
					varElement *id = searchAll(tempNode->value.idValue);
					//在符号表中寻找是否定义
					if(id == NULL) {
						printf("Error type 1 at line %d:undefined variable %s\n", p->line, tempNode->value.idValue);
						OUT = false;
					}
					else {
						type = id->type;
						tempNode->addr_sp = id->addr_sp;
						printf("tempNode->addr_sp: %d\n", id->addr_sp);
						return type;
					}
					break;
				//ID
					}
			case 17:{Type type = (Type)malloc(sizeof(struct Type_));
					type->kind = BASIC;
					type->u.basic = 0;
					ADDR -= 4;
					tempNode->addr_sp = ADDR;
					fprintf(out_fp, "\taddi $sp, $sp, -4\n");
					fprintf(out_fp, "\tli $t0, %d\n", tempNode->value.intValue);
					fprintf(out_fp, "\tsw $t0, 0($sp)\n");
					return type;
					//INT
					}
			case 18:{Type type = (Type)malloc(sizeof(struct Type_));
					type->kind = BASIC;
					type->u.basic = 1;
					ADDR -= 4;
					tempNode->addr_sp = ADDR;
					fprintf(out_fp, "\taddi $sp, $sp, -4\n");
					fprintf(out_fp, "\tli $t0, %f\n", tempNode->value.floatValue);
					fprintf(out_fp, "\tsw $t0, 0($sp)\n");
					return type;
					//FLOAT
					}
		}
	}
	return NULL;
}
Пример #8
0
Type doExp(TreeNode *p) {
	//printf("doExp\n");
	//printf("TreeNode->state:%s\n", p->state);
	//printf("TreeNode->productionRule: %d\n", p->productionRule);
	if(strcmp(p->state, "Exp") == 0) {
		TreeNode *tempNode = p->firstChild;//产生式右边第一个符号
		switch (p->productionRule) {
			case 1:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;//?这里不是只赋了地址吗
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 3 at line %d '=' type mismatch\n", p->line);//类型不匹配
					   }
				   }
				break;
				   //exp = exp
				   }
			case 2:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 3 at line %d '&&' type mismatch\n", p->line);//类型不匹配
					   }
				   }
				break;
				//Exp AND Exp
				   }
			case 3:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 3 at line %d '||' type mismatch\n", p->line);//类型不匹配
					   }
				   }
				break;
				//Exp OR Exp
				   }
			case 4:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 3 at line %d 'RELOP' type mismatch\n", p->line);//类型不匹配
					   }
				   }
				break;
				//Exp RELOP Exp
				   }
			case 5:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 3 at line %d '+' type mismatch\n", p->line);//类型不匹配
					   }
				   }
				break;
				//Exp PLUS Exp
				   }
			case 6:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 3 at line %d '-' type mismatch\n", p->line);//类型不匹配
					   }
				   }
				break;
				//Exp MINUS Exp
				   }
			case 7:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 3 at line %d '*' type mismatch\n", p->line);//类型不匹配
					   }
				   }
				break;
				//Exp STAR Exp
				   }
			case 8:{TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
				   Type type = (Type)malloc(sizeof(struct Type_));
				   Type t1 = doExp(tempNode);
				   Type t2 = doExp(temp2Node);
				   if(t1 != NULL && t2 != NULL) {
					   if(type_equal(t1, t2)) {
						   type = t1;
						   return type;//类型匹配
					   }
					   else if(!type_equal(t1, t2)) {
						   printf("Error type 3 at line %d '/' type mismatch\n", p->line);//类型不匹配
					   }
				   }
				break;
				//Exp DIV Exp
				   }
			case 9:return doExp(tempNode->rightBrother);
				   //LP Exp RP
			case 10:return doExp(tempNode->rightBrother);
					//MINUS Exp
			case 11:return doExp(tempNode->rightBrother);
					//NOT Exp
				
			case 12:{Type type = (Type)malloc(sizeof(struct Type_));
					varElement *id = searchAll(tempNode->value.idValue);
					if(id == NULL) {
						printf("Error type 4 at line %d:undefined function %s\n", p->line, tempNode->value.idValue);
					}
					else if(id->type->kind == FUNCTION) {//FUNCTION
						printf("Error type 4 at line %d:undefined function %s\n", p->line, tempNode->value.idValue);
					}
					//else if(){}//函数参数类型不匹配
					else {
						type = id->type;
						return type;
					}
					break;
					//ID LP Args RP
					}
			case 13:{Type type = (Type)malloc(sizeof(struct Type_));
					varElement *id =searchAll(tempNode->value.idValue);
					//在符号表中寻找
					if(id == NULL) {
						printf("Error type 4 at line %d:undefined function %s\n", p->line, tempNode->value.idValue);
					}
					else if(id->type->kind == FUNCTION) {//FUNCTION
						printf("Error type 4 at line %d:undefined function %s\n", p->line, tempNode->value.idValue);
					}
					//else if(){}//函数参数数量类型不匹配
					else {
						type = id->type;
						return type;
					}
					break;
					//ID LP RP
					}
			case 14:{Type type = (Type)malloc(sizeof(struct Type_));
					TreeNode *temp2Node = tempNode->rightBrother->rightBrother;
					Type t1 = doExp(tempNode);
					Type t2 = doExp(temp2Node);
					if(tempNode != NULL && temp2Node != NULL) {
						if(t1->kind != ARRAY)
							printf("Error type 5 at line %d:'[]' unexcepted\n", p->line);
						else if(t2->u.basic != 0)
							printf("Error type 6 at line %d:int required\n", p->line);
						else {
							type = doExp(tempNode)->u.array.elem;
							return type;
						}
					}
					break;
					//Exp LB Exp RB
					}
			case 15:{Type type = (Type)malloc(sizeof(struct Type_));
					Type t = doExp(tempNode);
					FieldList field = t->u.structure;
					if(t != NULL) {
						if(t->kind != STRUCTURE) {
							printf("Error type 7 at line %d:'.'before %s unexpected\n", p->line, tempNode->value.idValue);
						}
						else {
							while(field != NULL) {
								if(strcmp(field->name, tempNode->rightBrother->rightBrother->value.idValue)) {
									type = field->type;
									return type;
								}
								field = field->tail;
							}
							printf("Error type 8 at line %d:struct item %s undefined\n", p->line, tempNode->rightBrother->rightBrother->value.idValue);
							//结构体成员未定义
						}
					}
					break;
					//Exp DOT ID
					}
			case 16:{Type type = (Type)malloc(sizeof(struct Type_));
					varElement *id =searchAll(tempNode->value.idValue);
					//在符号表中寻找是否定义
					if(id == NULL) {
						printf("Error type 4 at line %d:undefined variable %s\n", p->line, tempNode->value.idValue);
					}
					else if(id->type->kind == FUNCTION) {//FUNCTION
						printf("Error type 4 at line %d:undefined variable %s\n", p->line, tempNode->value.idValue);
					}//若为函数名则也错
					else {
						type = id->type;
						return type;
					}
				break;
				//ID
					}
			case 17:{Type type = (Type)malloc(sizeof(struct Type_));
					type->kind = BASIC;
					type->u.basic = 0;
					return type;
					//INT
					}
			case 18:{Type type = (Type)malloc(sizeof(struct Type_));
					type->kind = BASIC;
					type->u.basic = 1;
					return type;
					//FLOAT
					}
		}
	}
	return NULL;
}
Пример #9
0
void FindReplaceDialog::replaceAll()
{
    searchAll(/* replace */ true);
}
Пример #10
0
void FindReplaceDialog::findAll()
{
    searchAll(/* replace */ false);
}
Пример #11
0
void MainWindow::makeMenu()
{
    QToolBar *toolBar = new QToolBar( this );
    QToolBar *searchBar = new QToolBar(this);
    QMenuBar *menuBar = new QMenuBar( toolBar );
    QPopupMenu *searchMenu = new QPopupMenu( menuBar );
//    QPopupMenu *viewMenu = new QPopupMenu( menuBar );
    QPopupMenu *cfgMenu = new QPopupMenu( menuBar );
    QPopupMenu *searchOptions = new QPopupMenu( cfgMenu );

    setToolBarsMovable( false );
    toolBar->setHorizontalStretchable( true );
    menuBar->insertItem( tr( "Search" ), searchMenu );
    menuBar->insertItem( tr( "Settings" ), cfgMenu );

    //SETTINGS MENU
    cfgMenu->insertItem( tr( "Search" ), searchOptions );
    QPopupMenu *pop;
    for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
        pop = s->popupMenu();
        if (pop){
            cfgMenu->insertItem( s->text(0), pop );
        }
    }


    //SEARCH
    SearchAllAction = new QAction( tr("Search all"),QString::null,  0, this, 0 );
    SearchAllAction->setIconSet( Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ) );
//    QWhatsThis::add( SearchAllAction, tr("Search everything...") );
    connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) );
    SearchAllAction->addTo( searchMenu );
    searchMenu->insertItem( tr( "Options" ), searchOptions );

    //SEARCH OPTIONS
    //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null,  0, this, 0, true );
    //actionWholeWordsOnly->addTo( searchOptions );
    actionCaseSensitiv = new QAction( tr("Case sensitive"),QString::null,  0, this, 0, true );
    actionCaseSensitiv->addTo( searchOptions );
    actionWildcards = new QAction( tr("Use wildcards"),QString::null,  0, this, 0, true );
    actionWildcards->addTo( searchOptions );

    //SEARCH BAR
    LabelEnterText = new QLabel( searchBar, "Label" );
    LabelEnterText->setAutoMask( FALSE );
    LabelEnterText->setText( tr( "Search for: " ) );
    LabelEnterText->setFrameStyle( QFrame::NoFrame );
    LabelEnterText->setBackgroundMode( PaletteButton );

    addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
    QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" );
    QWhatsThis::add( searchEdit, tr("Enter your search terms here") );
    searchEdit->setFocus();
    searchBar->setHorizontalStretchable( TRUE );
    searchBar->setStretchableWidget( searchEdit );

    //Search button
    SearchAllAction->addTo( searchBar );

    //Clear text
    ClearSearchText = new QToolButton( searchBar, "ClearSearchText");
    ClearSearchText->setText( "" );
    ClearSearchText->setPixmap( Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ) );

    connect( searchEdit, SIGNAL( textChanged(const QString&) ),this, SLOT( setSearch(const QString&) ) );
    connect( ClearSearchText, SIGNAL( clicked() ), searchEdit, SLOT( clear() ) );
}