static char *PrintConstant(char *s, uint32 n, uint flags)
{

	char *q;
	char buf[40];

	
	if (flags & PF_EA && (q = get_name(BADADDR, n, charbuf, sizeof(charbuf))) != NULL) {
		// check if we don't need to write the type explicitly

		if (flags & PF_TYPEMASK && DontNeedExplicitType( GetTypeOf(n),(flags & PF_TYPEMASK) - 1, !!(flags & PF_EA_STORE))) {
			flags &= ~PF_TYPEMASK;
		}
		
	} else {
		q = buf;
		if (flags & PF_NEGCONST) {
			uint32 tmp_n = (~n) & _typemask_size_masks[flags & PF_TYPEMASK];
			if (CountBits(tmp_n) <= 2) {
				*q++ = '~';
				n = tmp_n;
			}
		}

		if (n < 10) {
			sprintf(q, "%d", n);
		} else {
			sprintf(q, "0x%X", n);
		}
		q = buf;
	}

	if (flags & PF_EA && flags & PF_TYPEMASK) { s = strcpy_e(s, TypeNames[(flags & PF_TYPEMASK) - 1]); }
	s = strcpy_e(s, q);
	if (flags & PF_EA && flags & PF_TYPEMASK ) { s = strcpy_e(s, ">"); }

	return s;
}
Exemplo n.º 2
0
int Parser::TagControl(string thecontent, int oldindex)
{
	int tage;
	for(tage = oldindex; 
		tage<oldindex+MAX_TAG_LEN && tage<(int)thecontent.length(); tage++)
		if(thecontent[tage] == TAGEND)
			break;

	if(tage == MAX_TAG_LEN || tage == thecontent.length())
	{
		if(DEBUG_0) cout<<"sonda bulamadi"<<endl;
		return oldindex;
	}

	string tolook = Tolower(thecontent.substr(oldindex+1,tage-1-oldindex));

	int index = 0;
	bool tagend = FALSE;
	// tAG Close!! therefore return tagend as new index
	if(thecontent[oldindex+1] == TAGCLOSE)
	{ 
		index++; 
		tagend = TRUE; 
	}

	int begin = index;	
	while(tolook[index] != NULL && GetTypeOf(tolook[index]) == ALPHA) index++;
	int end = index;
	string rulename = tolook.substr(begin,end-begin);

	int i;
	for(i=0; i<NO_OF_TAGS; i++)
		if(TAGS[i] == rulename)
			break;

	// If sable is not enabled, do not consider any rule
	if(i != 6 && !rules->sableOn) return oldindex;

	ruleUpdate * ruleupdate = (ruleUpdate *) malloc(sizeof(ruleUpdate));
	ruleupdate->valid = TRUE;

	if(tagend)
	{
		switch(i)
		{
		case 0:		rules->RuleEmphC(ruleupdate);		break;
		case 2: 	rules->RulePitchC(ruleupdate);		break;
		case 3: 	rules->RuleRateC(ruleupdate);		break;
		case 4: 	rules->RuleVolumeC(ruleupdate);		break;
		case 5: 	rules->RuleEngineC(ruleupdate);		break;
		case 6: 	rules->RuleSableC();				break;
		case 8: 	rules->RuleSayasC(ruleupdate);		break;
		case 9: 	rules->RuleLangC(ruleupdate);		break;
		case 10: 	rules->RuleSpeakerC(ruleupdate);	break;
		case 11: 	rules->RulePronClosableC();			break;
		case 12: 	rules->RuleAudioC(ruleupdate);		break;
		case 13: 	rules->RuleMarkerC(ruleupdate);		break;
		case 14: 	rules->RuleDivC(ruleupdate);		break;
		case 15:	puncEnabled = true;					break;
		default:
			if(DEBUG_0) cout<<"NOn recognized tag"<<endl;
			return oldindex;
		}
		switch(i)
		{
		case 0:
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
		case 9:
		case 10:
		case 12:
		case 13:
			if(ruleupdate->valid)
			{
				Word * tmpWord = new Word(" ");
				tmpWord->type = INFO;
				tmpWord->rule = ruleupdate;
				InsertWord(tmpWord);
			}
			else
				if(DEBUG_0) cout<<"--* Non valid rule or not implemented..."<<endl;
			break;
		}
		// we are done with the tag
		return tage+1;
	}
	else
	{
		switch(i)
		{
		case 0:		rules->RuleEmph(ruleupdate,tolook);		break;
		case 1: 	rules->RuleBreak(ruleupdate,tolook);	break;
		case 2: 	rules->RulePitch(ruleupdate,tolook);	break;
		case 3: 	rules->RuleRate(ruleupdate,tolook);		break;
		case 4: 	rules->RuleVolume(ruleupdate,tolook);	break;
		case 5: 	rules->RuleEngine(ruleupdate,tolook);	break;
		case 6: 	rules->RuleSable();						break;
		case 7: 	rules->RulePron(ruleupdate,tolook);		break;
		case 8: 	rules->RuleSayas(ruleupdate,tolook);	break;
		case 9: 	rules->RuleLang(ruleupdate,tolook);		break;
		case 10: 	rules->RuleSpeaker(ruleupdate,tolook);	break;
		case 11: 
			{

				Word * tmpWord = rules->RulePronClosable(tolook);	
				while(tmpWord != NULL)
				{
					tmpWord->Update(this);
					InsertWord(tmpWord);
					tmpWord = tmpWord->next;
				}

				break;
			}
		case 12: 	rules->RuleAudio(ruleupdate,tolook);	break;
		case 13: 	rules->RuleMarker(ruleupdate,tolook);	break;
		case 14: 	rules->RuleDiv(ruleupdate,tolook);		break;
		case 15:	puncEnabled = false;					break;

		default:
			if(DEBUG_0) cout<<"Non recognized tag"<<endl;
			return oldindex;
		}
		switch(i)
		{
		case 0:
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
		case 9:
		case 10:

		case 12:
		case 13:
		case 14:
			if(ruleupdate->valid)
			{
				Word * tmpWord = new Word(" ");
				tmpWord->type = INFO;
				tmpWord->rule = ruleupdate;
				InsertWord(tmpWord);
			}
			else
				if(DEBUG_0) cout<<"--* Non valid rule or not implemented..."<<endl;

			break;
		}
		return tage+1;
	}
}
Exemplo n.º 3
0
void Parser::Parse()
{
	string thecontent = content;
	int index=0, pos = 0, size = 0;
	int len = (int)thecontent.length();
	Word * tmpWord;
	isBusy = TRUE;
	CString sItem;
	double dNumber;
	char sNumber[256];


	while(index <len)
	{
		//
		//	KELIMELER
		if(GetTypeOf(thecontent[index]) == ALPHA)
		{
			int begin = index;
			index++;
			while(index<len && 
				GetTypeOf(thecontent[index]) == ALPHA) index++;

			tmpWord = new Word(thecontent.substr(begin,(index-begin)));
			tmpWord->type = CUMLE;

			if(rules->pronounce.size() !=0)
			{
				tmpWord->Split(rules->pronounce);
				rules->pronounce.erase();
				while(tmpWord != NULL)
				{
					tmpWord->Update(this);
					InsertWord(tmpWord);
					tmpWord = tmpWord->next;
				}
			}
			else if(rules->pronouncec.size() != 0)
			{
				//
				continue;
			}
			else
			{
				tmpWord->Update(this);
				InsertWord(tmpWord); 
			}
		}
		//
		//	SAYILAR
		else if(GetTypeOf(thecontent[index]) == NUMERIC)
		{
			int begin = index;

			if (thecontent[index] == '0') {
				tmpWord = new Word(thecontent.substr(index,1));
				tmpWord->type = SAYI;
				index++;			
			} else {

				/*
				//index++;
				pos = index;

				size = 0;
				memset(sNumber,0,256*sizeof(char));
				while(pos<len && ((GetTypeOf(thecontent[pos]) == NUMERIC) || 
					(thecontent[pos] == '.') ) ) 
				{
					if (thecontent[pos] == '.'){
						pos++;
						continue;
					}
					 sNumber[size++] = thecontent[pos];
					 pos++;

				}

				dNumber = atof(sNumber);
				if (dNumber != 0) {
					index = pos;
					sItem.Format("%f",dNumber);
					tmpWord = new Word(sItem.GetString());

				} else {
				
					pos = index;
					while(pos<len && GetTypeOf(thecontent[pos]) == NUMERIC)
						index++;
	
					tmpWord = new Word(thecontent.substr(begin,(index-begin)));
				}

				tmpWord->type = SAYI;

				if(rules->pronouncec.size() != 0)
				{
					// skip these word(s)
					continue;
				}

				int isdot = index;
				bool rankingnumber = FALSE;
				if(thecontent[isdot]=='.')
				{
					isdot++;
					while(thecontent[isdot]==' ') isdot++;
					if(thecontent[isdot] >'a' && thecontent[isdot] <'z')
					{
						if(DEBUG_0) cout<<"Ranking number"<<endl;
						rankingnumber = TRUE;
						tmpWord->type = DERECELISAYI;
						index++;
					}				
				}

				*/
				while(index<len && 
					GetTypeOf(thecontent[index]) == NUMERIC) index++;

				tmpWord = new Word(thecontent.substr(begin,(index-begin)));
				tmpWord->type = SAYI;

				if(rules->pronouncec.size() != 0)
				{
					// skip these word(s)
					continue;
				}

				int isdot = index;
				bool rankingnumber = FALSE;
				if(thecontent[isdot]=='.')
				{
					isdot++;
					while(thecontent[isdot]==' ') isdot++;
					if(thecontent[isdot] >'a' && thecontent[isdot] <'z')
					{
						if(DEBUG_0) cout<<"Ranking number"<<endl;
						rankingnumber = TRUE;
						tmpWord->type = DERECELISAYI;
						index++;
					}				
				}
			
			}
			tmpWord->Update(this);
			while(tmpWord != NULL)
			{
				InsertWord(tmpWord);
				tmpWord = tmpWord->next;
			}
		}
		//
		//	SEMBOLLER
		else if(GetTypeOf(thecontent[index]) == SYMBOLIC)
		{
			int begin = index;
			// control tags
			if(thecontent[begin] == ' ')
			{
				index++;
				continue;
			}

			if(ruleEnabled)
				if(thecontent[begin] == TAGSTART)
				{
					int newin = TagControl(thecontent,index);
					if(begin != newin) 
					{
						index = newin;
						continue;
					}
				}
				index++;
				// capture ...'s
				while(GetTypeOf(thecontent[index]) == SYMBOLIC &&
					thecontent[index] == '.' ) index++;

				if(rules->pronouncec.size() != 0)
				{
					// skip these word(s)
					continue;
				}

				tmpWord = new Word(thecontent.substr(begin,(index-begin)));
				tmpWord->type = SEMBOL;
				tmpWord->Update(this);

				if(tmpWord->GetType() == SEMBOL && puncEnabled)
				{
					while(tmpWord != NULL)
					{
						InsertWord(tmpWord);
						tmpWord = tmpWord->next;
					}
				}
		}
	} /* End of while ... */

	isBusy = FALSE;
}