int Tracks::move_tracks_down()
{
	Track *track, *previous_track;
	int result = 0;
	
	for(track = last;
		track; 
		track = previous_track)
	{
		previous_track = track->previous;

		if(track->record)
		{
			if(track->next)
			{
				change_modules(number_of(track), number_of(track->next), 1);

				swap(track, track->next);
				result = 1;
			}
		}
	}
	
	return result;
}
Exemple #2
0
Fichier : real.c Projet : mRasey/C
int real() {
    char input[20];
    scanf("%s", input);
    char now = input[0];
    if(now == '+' || now == '-') {
        if(!judge(sub_string(input, 1, strlen(input)))) {
            printf("Wrong!");
            return 0;
        }
        if(number_of(input, 'E'))
            printf("Format2");
        else
            printf("Format1");
        return 0;
    }
    else if(isdigit(now)) {
        if(!judge(input)) {
            printf("Wrong!");
            return 0;
        }
        if(number_of(input, 'E'))
            printf("Format2");
        else
            printf("Format1");
        return 0;
    }
    else {
        printf("Wrong!");
        return 0;
    }
}
int Tracks::move_tracks_up()
{
	Track *track, *next_track;
	int result = 0;

	for(track = first;
		track; 
		track = next_track)
	{
		next_track = track->next;

		if(track->record)
		{
			if(track->previous)
			{
				change_modules(number_of(track->previous), number_of(track), 1);

				swap(track->previous, track);
				result = 1;
			}
		}
	}

	return result;
}
int Tracks::move_track_down(Track *track)
{
	Track *next_track = track->next;
	if(!next_track) next_track = first;

	change_modules(number_of(track), number_of(next_track), 1);
	swap(track, next_track);
	return 0;
}
Exemple #5
0
static
 NoWantGkEnd(gk_string *skipend, gk_string *haveend, int strict)
{

	if( dialect_of(skipend) ) {
		if( ! dialect_of(haveend) ) return(0);
		if( AndDialect(dialect_of(skipend),dialect_of(haveend)) > 0 )
			return(1);
	}
	if( ! gkstring_of(skipend)[0] &&
		! mood_of(forminfo_of(skipend)) &&
		! tense_of(forminfo_of(skipend)) &&
		! voice_of(forminfo_of(skipend)) &&
		! number_of(forminfo_of(skipend)) &&
		! person_of(forminfo_of(skipend)) &&
		! gender_of(forminfo_of(skipend)) &&
		! case_of(forminfo_of(skipend)) &&
/*		! dialect_of(skipend) &&*/
		! stemtype_of(skipend) &&
		 no_morphflags(skipend))
			return(0);

	return( WantGkEnd(skipend,haveend,NO,strict) <= 0 ? 0 : 1 );

}
Exemple #6
0
Fichier : real.c Projet : mRasey/C
bool judge(char* s) {
    int i = 0;
    if(number_of(s, '.') > 1 || number_of(s, 'E') > 1 || s[0] == '0' || !isdigit(s[strlen(s) - 1])) {
        return false;
    }
    for(i = 0; i < strlen(s); i++) {
        if(!isdigit(s[i])) {
            if(s[i] == '.' && i == 0) {
                return false;
            }
            else if((s[i] == '+' || s[i] == '-') && s[i-1] != 'E') {
                return false;
            }
        }
    }
    return true;
}
Exemple #7
0
Key
AperyBook::book_key(const Position &pos) 
{
  Key key = 0;
  BitBoard bb = pos.occupied();

  while (bb.test()) 
  {
    Square sq = bb.pop_bit();
    key ^= zob_piece_[pos.square(sq)][sq];
  }

  Hand hand = pos.hand(pos.side_to_move());
  key ^= zob_hand_[0][number_of(hand, kPawn)];
  key ^= zob_hand_[1][number_of(hand, kLance)];
  key ^= zob_hand_[2][number_of(hand, kKnight)];
  key ^= zob_hand_[3][number_of(hand, kSilver)];
  key ^= zob_hand_[4][number_of(hand, kGold)];
  key ^= zob_hand_[5][number_of(hand, kBishop)];
  key ^= zob_hand_[6][number_of(hand, kRook)];

  if (pos.side_to_move() == kWhite)
    key ^= zob_turn_;
  return key;
}
Exemple #8
0
penult_form(gk_string *gstring, word_form form_info)
{
	Stemtype stemtype;

	stemtype = stemtype_of(gstring);

	if( case_of(form_info) == VOCATIVE && 
		number_of(form_info) == SINGULAR &&
		(stemtype & DECL3) &&
		Is_pers_name(morphflags_of(gstring)) ) {
			return(0);
	}

	if( Is_penult_accent(morphflags_of(gstring)) ) {
		return(1);
	}

	/* special case: certain infinitives with acc on penult, not antep. */
	if ( (voice_of(form_info) == ACTIVE && 
			mood_of(form_info) == PARTICIPLE &&
			gender_of(form_info) == NEUTER &&
			number_of(form_info) == SINGULAR &&
			(case_of(form_info) == NOMINATIVE || case_of(form_info)==ACCUSATIVE))
			/* neuter active participles */
	    
	    /*|| (stemtype == AOR1_REG && 
			voice_of(form_info) == ACTIVE && 
			mood_of(form_info) == INFINITIVE) 
		       	/* 1st aorist active inf *
	    || (stemtype == AOR2_REG && 
			voice_of(form_info) == MIDDLE && 
			mood_of(form_info) == INFINITIVE) 
		       	/* 2nd aorist middle inf */
		       	
	    || (voice_of(form_info) & MEDIO_PASS && 
			mood_of(form_info) == INFINITIVE && 
			tense_of(form_info) == PERFECT ) )
			/* perfect m/p inf */ 
				return(1);
	return(0);
}
int Tracks::move_track_up(Track *track)
{
	Track *next_track = track->previous;
	if(!next_track) next_track = last;

	change_modules(number_of(track), number_of(next_track), 1);

// printf("Tracks::move_track_up 1 %p %p\n", track, next_track);
// int count = 0;
// for(Track *current = first; current && count < 5; current = NEXT, count++)
// 	printf("Tracks::move_track_up %p %p %p\n", current->previous, current, current->next);
// printf("Tracks::move_track_up 2\n");
// 
	swap(track, next_track);

// count = 0;
// for(Track *current = first; current && count < 5; current = NEXT, count++)
// 	printf("Tracks::move_track_up %p %p %p\n", current->previous, current, current->next);
// printf("Tracks::move_track_up 3\n");

	return 0;
}
Exemple #10
0
/*static*/
 WantGkEnd(gk_string *wantend, gk_string *haveend, bool writeflag, int strict)
{
	int compval;

	word_form wform, hform;
/*
	Dialect wdial = dialect_of(wantend);
	Dialect hdial = dialect_of(haveend);
*/
	Dialect wdial;
	Dialect hdial;

	Dialect d/*, AndDialect()*/;

	int wmood = mood_of( forminfo_of(wantend) );
	int hmood = mood_of( forminfo_of(haveend) );

	int wvoice = voice_of( forminfo_of(wantend) );
	int hvoice = voice_of( forminfo_of(haveend) );

	int wtense = tense_of( forminfo_of(wantend) );
	int htense = tense_of( forminfo_of(haveend) );

	int wgender = gender_of( forminfo_of(wantend) );
	int hgender = gender_of( forminfo_of(haveend) );

	int wdegree = degree_of( forminfo_of(wantend) );
	int hdegree = degree_of( forminfo_of(haveend) );

	int wcase = case_of( forminfo_of(wantend) );
	int hcase = case_of( forminfo_of(haveend) );

	int wperson = person_of( forminfo_of(wantend) );
	int hperson = person_of( forminfo_of(haveend) );

	int wnumber = number_of( forminfo_of(wantend) );
	int hnumber = number_of( forminfo_of(haveend) );

	char wendstr[MAXWORDSIZE];
	char * hendstr = gkstring_of(haveend);

	wform = forminfo_of(wantend);
	hform = forminfo_of(haveend);
	
/*
 * basically, we check to see if any particular form has been requested
 * and check each ending against this. if nothing is asked for (e.g. no
 * mood or voice is specified) then we just take the ending (i.e. we take
 * subjunctive, optative, indicative etc. rather than just the optatives or
 * subjunctives or whatever...
 */
	setwendstr(wendstr,gkstring_of(wantend));
	if( wmood && hmood != wmood ) {
		if( hmood || (!hmood && strict) ) {
#ifdef SHOWFAIL
printf("failing on wmood %o hmood %o\n", wmood, hmood );
#endif
			return(0);
		}
	}

/*
 *
 *  perfect actives are, by definition, always active in form
 */


   	if( (stemtype_of(wantend) & PPARTMASK ) == PP_PF ) {
   		wvoice = ACTIVE;
   		voice_of(wform) = ACTIVE;
   	}

   	if( (stemtype_of(wantend) & PPARTMASK ) == PP_SU && 
	     cur_lang() == LATIN && wvoice == DEPONENT ) {
			set_voice(forminfo_of(haveend), wvoice);
   	}

	if( cur_lang() == LATIN && wvoice == DEPONENT ) {
		if( hvoice == ACTIVE && hmood != PARTICIPLE && hmood != GERUNDIVE ) return(0);
	} else if( wvoice ) {
		if( ! Want_Voice( wform , hform )) {
		   if( hvoice || (!hvoice && strict)) {
#ifdef SHOWFAIL
printf("have [%s] failing on wvoice %o hvoice %o\n",hendstr, wvoice, hvoice );
#endif
				return(0);
			}
		} else {
/*
 * note that an ending may generally be either middle or passive, but
 * if the stem in hand is strictly middle or strictly passive,
 * then the ending inherits that limitation.
 */

			if( writeflag == YES )
			   set_voice(forminfo_of(haveend), wvoice);
		}
	}

	if( wtense && htense != wtense )
		if( htense || (!htense && strict) ) {
#ifdef SHOWFAIL
printf("failing on wtense %o htense %o\n", wtense, htense );
#endif
			return(0);
		}

/*
 * note that here you only fail if the gender is set in the
 * ending as well as in the stem.
 * 
 * if we follow the normal algorithm, a masculine stem would 
 * not match a set of endings that had no gender specified.
 *
 * likewise, we need to match either masculine or feminine against
 * an ending that is common to both (but not, for example, to a neuter
 * stem, e.g. -es in nom pl for masc and fem, but -a for neuter)
 */
/*

/*
 * only fail if gender set for both.
 * 	e.g., dwr- from dw=ron will want to find 
 * endings such as -on, or -a that are specifically flagged
 * as neuter, but will also want to find other endings
 * that can attach themselves to any gender
 */
	if( wgender ) {
		if( hgender ) {
			if( ! Want_Gender(wform, hform)) {
#ifdef SHOWFAIL
printf("failing with hgender %o and wgender %o\n", hgender , wgender );
#endif
				return(0);
			}
		}
		if( writeflag )
			if( Want_Gender(wform,hform) )
				set_gender(forminfo_of(haveend), Want_Gender(wform, hform));
			else
			   	set_gender(forminfo_of(haveend), wgender );
	}

	if( wcase ) {
		if( ! Want_Case(wform, hform))
			if( hcase || (!hcase && strict) ) {
#ifdef SHOWFAIL
printf("failing with hcase %o wcase %o\n", hcase , wcase );
#endif
				return(0);
			}
if( writeflag ) {
#ifdef SHOWFAIL
printf("[%s] hcase %o wcase %o anded %o\n", gkstring_of(haveend), hcase, wcase, hcase & wcase );
#endif
		set_case(forminfo_of(haveend) , wcase&hcase );
}
	}

	if( wperson && hperson != wperson ) {
		if( hperson || (!hperson && strict) ) {
#ifdef SHOWFAIL
printf("failing with hperson %o wperson %o\n", hperson , wperson );
#endif
			return(0);
		}
	}

	if( wnumber && hnumber != wnumber )
		if( hnumber || (!hnumber && strict) ) {
#ifdef SHOWFAIL
printf("failing on wnumber %o hnumber %o\n", wnumber , hnumber );
#endif
			return(0);
		}

	if( *wendstr && strict ) {
	
		if( (compval=endstrcmp(wendstr,hendstr))){
	/*
	 * this expects that you have a sorted list of endings and that you
	 * don't want to look for endings that are alphabetically larger
	 * than the ending that you want 
	 */
			if( compval < 0 && noaccstrcmp(wendstr,hendstr) ) {

#ifdef SHOWFAIL
#endif

				return(compval);
			}
#ifdef SHOWFAIL
printf("failing on wendsrr\n");
#endif
		/*
		 * don't fail if you did not specifically ask for a long vowel.
		 *
		 * do fail if you specifically ask for a long vowel and this ending is not 
		 * marked as long.
		 */
		if( has_quantacc(hendstr) != has_quantacc(wendstr) ) {
			char tmp[MAXWORDSIZE];
			
			Xstrncpy(tmp,hendstr,MAXWORDSIZE);
			stripquantacc(tmp);
			compval=endstrcmp(wendstr,tmp);
/*
			compval=dictstrcmp(wendstr,tmp);
*/
			if( compval  ) 				
						return(0);
		}  else
						return(0);
		} else {
			/*
			 * if you ask for "w=", then match only "w=" and not "w".
			 *
			 * if you ask for "w", however, then match both "w=" and "w".
			 */

			if( hasaccent(wendstr)  ) {
				char tmp1[MAXWORDSIZE];
				char tmp2[MAXWORDSIZE];
				
				Xstrncpy(tmp1,wendstr,(int)sizeof tmp1);
				stripquant(tmp1);
				
				Xstrncpy(tmp2,hendstr,(int)sizeof tmp2);
				stripquant(tmp2);
				if( strcmp(tmp1,tmp2) )
						return(0);
			}
		}
	}

	if(  ! EuphEnd(wantend,haveend,strict) ) {
#ifdef SHOWFAIL
printf("[%s] failing on euph end\n", gkstring_of(haveend) );
#endif
		return(0);
	}
	wdial = dialect_of(wantend);
	hdial = dialect_of(haveend);

/*
 * note that we are checking not for equality, but to see if
 * we want any of the dialect bits set for the current ending
 */
	if( (d=AndDialect(hdial,wdial)) < 0 )
		return(0);
/*
	else if( writeflag ) {
		set_dialect(haveend,d);
	}
*/
/*
 * we currently mark a)/ristos as "os_h_on superl". 
 * we thus want a)rist- to have all the normal endings (-os,-h,-on,-ou,-hs,-ou)
 * but not to have endings such as "-o/tatos" or "-w/teros" tacked onto it.
 */
 
/*
 * grc 6/5/89
 *
 * this system prevents morphology formulas from generating any actual endings.  the
 * formula has the flag "comp" or "superl", but none of the endings in the basic
 * paradigms are so marked, so they are all skipped.  i added the requirement that this
 * rule only be active if strict is non zero to get around this (this is much the same
 * strategy that we took with iteratives.
 */
	if( wdegree ) {
		if(  hdegree && wdegree != hdegree /* grc 6/5/89 */ && strict /* end mod*/) {
			if( hdegree || (!hdegree && strict) )
				return(0);
		}
		if( wdegree && writeflag ) set_degree(forminfo_of(haveend),wdegree);
	}

	if( ! RightMorphflags(wantend,haveend)) {
#ifdef SHOWFAIL
printf("[%s] failing on rightmorphflags\n", gkstring_of(haveend) );
#endif
		return(0);
	}
	return(1);
}
Exemple #11
0
gk_string *
 chckendings(char *endstr, char *restricts, char *stemstr, char *prevbstr, Dialect dial, int *nends)
{
	gk_string * gstring;
	char stemkeys[BUFSIZ];
	Dialect OrDialect;
	gk_string * tmpgstr;
	gk_word  * BlnkGkword;


	Xstrncpy(stemkeys,restricts,(int)sizeof stemkeys);

/*
 * ok, we want to process the restrictions associated with this stem, and then
 * use this information to get appropriate endings (e.g., if the stem
 * is deponent, we don't want to get any active endings ).
 */

	WantEnd = BlankGkend;
	AvoidEnd = BlankGkend;

	tmpgstr = &WantEnd;

	BlnkGkword = CreatGkword(1);
	
	ScanAsciiKeys(stemkeys,BlnkGkword,&WantEnd,&AvoidEnd);
	FreeGkword(BlnkGkword);
	
/*
printf("\nstemkeys [%s]\n", stemkeys );
printf("WantEnd:"); PrntAGstr(&WantEnd,stdout); printf("\n");
printf("AvoidEnd:"); PrntAGstr(&AvoidEnd,stdout); printf("\n");
*/
	if( ! stemtype_of(&WantEnd) ) {
		printf("could not find a stemtype for [%s] with restricts [%s]\n", 
			restricts );
		return(NULL);
	}

	if( endstr )
		set_gkstring(&WantEnd,endstr );
	if( stemstr ) {
		markstem(stemstr,&WantEnd);
	}

	OrDialect = dialect_of(&WantEnd);

	if( dial ) 
		add_dialect(&WantEnd,dial);
	else
		set_dialect(&WantEnd,dial);
		
	if( prevbstr ) {
		if( * prevbstr )
			add_morphflag(morphflags_of(tmpgstr),HAS_PREVERB);
	}

	if( /*Is_geog_name(morphflags_of(&WantEnd)) || */Is_pers_name(morphflags_of(tmpgstr))) {
		if( ! number_of(forminfo_of(&WantEnd)) ) 
			set_number(forminfo_of(&WantEnd),SINGULAR);
	}

	if( Is_group_name(morphflags_of(&WantEnd)) ) {
		if( ! number_of(forminfo_of(&WantEnd)) ) 
			set_number(forminfo_of(&WantEnd),PLURAL);
	}

/*
	if( !(gstring = RetrCompEnds(&WantEnd,&AvoidEnd,nends,OrDialect))) {
		return(NULL);
	}
*/
	gstring = RetrCompEnds(&WantEnd,&AvoidEnd,nends,OrDialect);
	return(gstring);
}
Exemple #12
0
 EndingOk(char *keys, gk_string *gstr, gk_string *avoidgstr, int wantderiv)
{
	int good = 0;
	gk_word * BlnkGkword;
	
	Cur_gkend = BlankGkend;
	BlnkGkword = CreatGkword(1);
	ScanAsciiKeys(keys,BlnkGkword,&Cur_gkend,avoidgstr);
	FreeGkword(BlnkGkword);
	
	if( wantderiv ) {
		if( ! derivtype_of(gstr) || derivtype_of(gstr) < 0 ) return(0);
		
		if( derivtype_of(gstr) != derivtype_of(&Cur_gkend)) 
			return(0);
	}
	
	good =  (WantGkEnd(gstr,&Cur_gkend,NO,0) > 0) &&
	  (NoWantGkEnd(avoidgstr,&Cur_gkend,1) == 0 );
/*
if( ! good ) {
printf("gstr [%s] [%s] want %o nowant %o\n",gkstring_of(gstr), gkstring_of(&Cur_gkend), WantGkEnd(gstr,&Cur_gkend,NO,0) ,
NoWantGkEnd(avoidgstr,&Cur_gkend,1)  );
LPrntGstr(gstr,stdout);
LPrntGstr(&Cur_gkend,stdout);

}
*/
	if( good ) {
		int case1, case2;
		int gend1, gend2;
		int num2, pers2;
		int voice1, voice2;
		Dialect dial1, dial2;

		voice1 = voice_of(forminfo_of(&Cur_gkend));
		voice2 = voice_of(forminfo_of(gstr));
		
		if( voice1 ) set_voice(forminfo_of(gstr),voice1);
		
		case1 = case_of(forminfo_of(&Cur_gkend));
		case2 = case_of(forminfo_of(gstr));
		if( case1 & case2 )
			set_case(forminfo_of(gstr), (case1 & case2) );
		else if( case1 && ! case2 )
			set_case(forminfo_of(gstr), case1 );
	
		num2 = number_of(forminfo_of(&Cur_gkend));
		if( num2 )
			set_number(forminfo_of(gstr), number_of(forminfo_of(&Cur_gkend)) );

		pers2 = person_of(forminfo_of(&Cur_gkend));
		if( pers2 )
			set_person(forminfo_of(gstr), person_of(forminfo_of(&Cur_gkend)) );

		gend1 = gender_of(forminfo_of(&Cur_gkend));
		gend2 = gender_of(forminfo_of(gstr));
		if( gend1 & gend2 )
			set_gender(forminfo_of(gstr), (gend1 & gend2) );
		else if( gend1 && ! gend2 )
			set_gender(forminfo_of(gstr), gend1 );

		dial1 = dialect_of(&Cur_gkend);
		dial2 = dialect_of(gstr);
		if( dial1 & dial2 ) 
			set_dialect(gstr,(dial1 & dial2) );
		else if( dial1 && (! dial2) )
			set_dialect(gstr,dial1);
			
		add_morphflags(gstr,morphflags_of(&Cur_gkend));
	}
	return( good );
}