--- capa/capa51/pProj/capaFunction.c 1999/09/28 21:26:20 1.1.1.1 +++ capa/capa51/pProj/capaFunction.c 2000/02/09 22:10:24 1.4 @@ -14,13 +14,13 @@ #include "capaCommon.h" #include "ranlib.h" - char Parse_class[QUARTER_K]; int Parse_set; int Parse_section; char Parse_student_number[MAX_STUDENT_NUMBER+1]; char Parse_name[MAX_NAME_CHAR+1]; long capaid_plus_gen; +int managermode; extern int Parsemode_f; @@ -37,6 +37,9 @@ int match_function(func, argc) char *func; int argc; { if( !strcmp(func,"random") ) return (((argc==2 || argc==3)? RANDOM_F : MIS_ARG_COUNT)); + if( !strcmp(func,"random_normal") ) return (((argc==2 || argc==3)? RANDOM_NORMAL_F : MIS_ARG_COUNT)); + if( !strcmp(func,"random_exponential") ) return (((argc==2 || argc==3)? RANDOM_EXPONENTIAL_F : MIS_ARG_COUNT)); + if( !strcmp(func,"random_beta") ) return (((argc==2 || argc==3)? RANDOM_BETA_F : MIS_ARG_COUNT)); if( !strcmp(func,"choose") ) return (CHOOSE_F); if( !strcmp(func,"tex") ) return (((argc==2)? TEX_F: MIS_ARG_COUNT)); if( !strcmp(func,"var_in_tex") ) return (VAR_IN_TEX_F); @@ -59,6 +62,7 @@ match_function(func, argc) char *func; i if( !strcmp(func,"strlen") ) return (((argc==1)? STRLEN_F: MIS_ARG_COUNT)); if( !strcmp(func,"get_seed") ) return (((argc==0)? GET_SEED_F: MIS_ARG_COUNT)); if( !strcmp(func,"set_seed") ) return (((argc==1)? SET_SEED_F: MIS_ARG_COUNT)); + if( !strcmp(func,"init_array") ) return (((argc==1)? INIT_ARRAY_F: MIS_ARG_COUNT)); if( !strcmp(func,"array_index") ) return (((argc==1)? ARRAY_INDEX_F: MIS_ARG_COUNT)); if( !strcmp(func,"array_sorted_index") ) return (((argc==2)? ARRAY_SORTED_INDEX_F: MIS_ARG_COUNT)); if( !strcmp(func,"array_max") ) return (((argc==1)? ARRAY_MAX_F: MIS_ARG_COUNT)); @@ -113,6 +117,10 @@ match_function(func, argc) char *func; i if( !strcmp(func,"is_open") ) return (((argc <2)? IS_OPEN_F: MIS_ARG_COUNT)); if( !strcmp(func,"is_due") ) return (((argc <2)? IS_DUE_F: MIS_ARG_COUNT)); if( !strcmp(func,"is_answer") ) return (((argc <2)? IS_ANSWER_F: MIS_ARG_COUNT)); + if( !strcmp(func,"correct") ) return (((argc <3)? CORRECT_F: MIS_ARG_COUNT)); + if( !strcmp(func,"grade") ) return (((argc <3)? GRADE_F: MIS_ARG_COUNT)); + if( !strcmp(func,"tries") ) return (((argc <3)? TRIES_F: MIS_ARG_COUNT)); + if( !strcmp(func,"managermode")) return (((argc==0)? MANAGERMODE_F:MIS_ARG_COUNT)); return (UNKNOWN_F); } @@ -180,8 +188,8 @@ ArgNode_t *argp; int slots, noError, errCode, mo, yy, dd, hh, mm, tmpInt; long rout; char *wday[9] = {"Sat,", "Sun,", "Mon,", "Tue,", "Wed,", "Thr,", "Fri,", "Sat,", "\0"}; - char *month[SIXTEEN] = { "UNKNOWN", "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "UNKNOWN", "UNKNOWN", "\0"}; + char *month[14] = { "UNKNOWN", "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "\0"}; resultp = (Symbol *)capa_malloc(1,sizeof(Symbol)); @@ -814,6 +822,29 @@ ArgNode_t *argp; resultp->s_str = strsave("NOT YET"); } break; + case INIT_ARRAY_F: + { int rr; + + switch( FIRST_ARGTYPE(argp) ) { + case I_VAR: case I_CONSTANT: + case R_VAR: case R_CONSTANT: + resultp->s_type = S_CONSTANT; + resultp->s_str = strsave("<>"); + sprintf(tmpS,"init_array()'s arg. must be a name of an array.\n"); + capa_msg(MESSAGE_ERROR,tmpS); + break; + case S_VAR: case S_CONSTANT: /* allows the use of init_array(array[1]) which array[1]="another" */ + rr = free_array(FIRST_ARGSTR(argp)); + resultp->s_type = I_CONSTANT; + resultp->s_int = rr; + break; + case IDENTIFIER: + rr = free_array(FIRST_ARGNAME(argp)); + resultp->s_type = I_CONSTANT; + resultp->s_int = rr; + break; + } + } break; case ARRAY_MAX_F: case ARRAY_MIN_F: { int min; @@ -1499,10 +1530,26 @@ ArgNode_t *argp; resultp->s_int=capa_get_duration(Parse_student_number, Parse_section,Parse_set); } break; + case MANAGERMODE_F: { resultp->s_type = I_CONSTANT; + resultp->s_int=managermode; + }break; + case CORRECT_F: { + + }break; + + case TRIES_F: { + + }break; + + case GRADE_F: { + + }break; + case MIS_ARG_COUNT: { resultp->s_type = S_CONSTANT; resultp->s_str = strsave("<>"); - sprintf(tmpS,"%s()'s arg. count is not correct.\n",FuncStack[Func_idx].s_name); + sprintf(tmpS,"%s()'s arg. count is not correct.\n", + FuncStack[Func_idx].s_name); capa_msg(MESSAGE_ERROR,tmpS); } break; case UNKNOWN_F: