Changeset 92232e in git
- Timestamp:
- Oct 13, 2010, 3:11:15 PM (14 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
- Children:
- aa91cc2c1ce17bb7ec7a9da2f6d16258ac3c2b0f
- Parents:
- 2e937c0fa46c280da4f0ba745dc31ae45d2b5ecc
- Location:
- Singular
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/gentable.cc
r2e937c r92232e 451 451 { 452 452 id_nr++; 453 if(cmds[m].tokval==VRTIMER) fprintf(outfile,"#ifdef HAVE_ GETTIMEOFDAY\n");453 if(cmds[m].tokval==VRTIMER) fprintf(outfile,"#ifdef HAVE_RTIMER\n"); 454 454 fprintf(outfile," {\"%s\", %*d, %3d, ",cmds[m].name, 455 455 20-strlen(cmds[m].name), … … 530 530 " { NULL, 0, 0, 0}\n" 531 531 "};\n" 532 "#ifdef HAVE_ GETTIMEOFDAY\n"532 "#ifdef HAVE_RTIMER\n" 533 533 "#define LAST_IDENTIFIER %d\n" 534 534 "#else\n" … … 576 576 { 577 577 if(cmds[m].tokval>0) id_nr++; 578 if(cmds[m].tokval==VRTIMER) fprintf(outfile,"#ifdef HAVE_ GETTIMEOFDAY\n");578 if(cmds[m].tokval==VRTIMER) fprintf(outfile,"#ifdef HAVE_RTIMER\n"); 579 579 fprintf(outfile," iiArithAddCmd(\"%s\", %*d, %3d, ",cmds[m].name, 580 580 (int)(20-strlen(cmds[m].name)), … … 618 618 fprintf(outfile, "/* end of list marker */\n"); 619 619 fprintf(outfile, 620 "#ifdef HAVE_ GETTIMEOFDAY\n"620 "#ifdef HAVE_RTIMER\n" 621 621 " sArithBase.nLastIdentifier = %d;\n" 622 "#else /* HAVE_ GETTIMEOFDAY*/\n"622 "#else /* HAVE_RTIMER */\n" 623 623 " sArithBase.nLastIdentifier = %d;\n" 624 "#endif /* HAVE_ GETTIMEOFDAY*/\n",624 "#endif /* HAVE_RTIMER */\n", 625 625 id_nr,id_nr-1); 626 626 … … 628 628 fprintf(outfile, 629 629 "}\n" 630 "#ifdef HAVE_ GETTIMEOFDAY\n"630 "#ifdef HAVE_RTIMER\n" 631 631 "#define LAST_IDENTIFIER %d\n" 632 632 "#else\n" … … 886 886 } 887 887 888 #ifdef HAVE_MPSR 889 #include <Singular/mpsr.h> 890 #include <Singular/mpsr_Tok.h> 891 #define MAX_COP 256 // there may be at most 256 cops 892 893 // this is the main data struct for storing the relation 894 // Singular token <-> (Dict, OP) 895 typedef struct mpsr_cmd 896 { 897 898 short tok; // The Singular token encoding 899 900 // The MP Dict tag in which this token is defined, 901 MP_DictTag_t dict; 902 903 // The MP operator corresponding to this token 904 MP_Common_t cop; // operator 905 } mpsr_cmd; 906 907 #define MAX_SR_DICT 5 908 909 // this provides a mapping from MP dict tags to more useful (small) 910 // array indicies 911 inline short mpdict2srdict(MP_DictTag_t dict) 912 { 913 if (dict == MP_SingularDict) return 0; 914 else if (dict == MP_BasicDict) return 1; 915 else if (dict == MP_PolyDict) return 2; 916 else if (dict == MP_MatrixDict) return 3; 917 else if (dict == MP_NumberDict) return 4; 918 else return MAX_SR_DICT; 919 } 920 921 // This is the array which holds all mpsr_cmds 922 // It is initialized in mpsr_tok.inc 923 static mpsr_cmd mpsr_cmds[MAX_TOK]; 924 925 // This is the array which stores the mapping from token to an mpsr_cmd 926 // A value is either an index into mpsr_cmds, or MAX_TOK 927 static short tok2mp[MAX_TOK]; 928 929 // This is the array which stores the mapping from (dict, cop) to a 930 // mpsr_cmd. First index mpdict2srdict(dict), second is cop 931 static short mp2tok[MAX_SR_DICT][MAX_COP]; 932 933 // This the list of all tokens which have an MP representation as a 934 // cop in the Singular dictionary 935 short sr_cmds[] = 936 { 937 OPTION_CMD, 938 NAMES_CMD, 939 ATTRIB_CMD, 940 CHARSTR_CMD, 941 CLOSE_CMD, 942 DEF_CMD, 943 DEGREE_CMD, 944 DEFINED_CMD, 945 E_CMD, 946 EXECUTE_CMD, 947 FREEMODULE_CMD, 948 INT_CMD, 949 INTERRED_CMD, 950 INTMAT_CMD, 951 INTVEC_CMD, 952 IS_RINGVAR, 953 KILLATTR_CMD, 954 MAP_CMD, 955 MEMORY_CMD, 956 MONITOR_CMD, 957 NAMEOF_CMD, 958 NUMBER_CMD, 959 NPARS_CMD, 960 NVARS_CMD, 961 OPEN_CMD, 962 ORDSTR_CMD, 963 PAR_CMD, 964 PARSTR_CMD, 965 PARDEG_CMD, 966 POLY_CMD, 967 PRINT_CMD, 968 READ_CMD, 969 SORTVEC_CMD, 970 STRING_CMD, 971 SYSTEM_CMD, 972 TYPEOF_CMD, 973 VECTOR_CMD, 974 VAR_CMD, 975 VARSTR_CMD, 976 WEIGHT_CMD, 977 '(', 978 COEF_CMD, 979 DELETE_CMD, 980 FETCH_CMD, 981 FIND_CMD, 982 IMAP_CMD, 983 INSERT_CMD, 984 SIMPLIFY_CMD, 985 SRES_CMD, 986 DBPRINT_CMD, 987 TEST_CMD, 988 PROC_CMD, 989 MSTD_CMD, 990 RESERVEDNAME_CMD, 991 WRITE_CMD, 992 QRING_CMD, 993 FGLM_CMD, 994 FGLMQUOT_CMD, 995 DUMP_CMD, 996 GETDUMP_CMD, 997 STATUS_CMD, 998 LIB_CMD, 999 PACKAGE_CMD 1000 }; 1001 1002 // struct used for specifying the cmd <-> cop relations 1003 typedef struct cmd_cop 1004 { 1005 short cmd; 1006 MP_Common_t cop; 1007 } cmd_op; 1008 1009 typedef struct cmd_dictcop 1010 { 1011 MP_DictTag_t dict; 1012 cmd_op cmd_ops[255]; 1013 } cmd_dictcop; 1014 1015 cmd_dictcop cmd_dictcops[] = 1016 { 1017 { 1018 MP_PolyDict, 1019 // This is the list of all tokens which have an MP representation as a 1020 // cop in the Poly dictionary 1021 { 1022 {BETTI_CMD, MP_CopPolyBetti}, 1023 {CHARACTERISTIC_CMD, MP_CopPolyChar}, 1024 {CHAR_SERIES_CMD, MP_CopPolyCharSeries}, 1025 {CONTENT_CMD, MP_CopPolyClearDenom }, 1026 {DEG_CMD, MP_CopPolyDeg}, 1027 {DIM_CMD, MP_CopPolyDim}, 1028 {FAC_CMD, MP_CopPolyFactorize}, 1029 {FACSTD_CMD, MP_CopPolyFacStd}, 1030 {HILBERT_CMD, MP_CopPolyHilb}, 1031 {HOMOG_CMD, MP_CopPolyHomog}, 1032 {INDEPSET_CMD, MP_CopPolyInDepSet}, 1033 {IDEAL_CMD, MP_CopPolyIdeal}, 1034 {KBASE_CMD, MP_CopPolyKbase}, 1035 {LEAD_CMD, MP_CopPolyLead}, 1036 {LEADCOEF_CMD, MP_CopPolyLeadCoef}, 1037 {LEADEXP_CMD, MP_CopPolyLeadExp}, 1038 {MAXID_CMD, MP_CopPolyMaxIdeal}, 1039 {MINBASE_CMD, MP_CopPolyMinBase}, 1040 {MINRES_CMD, MP_CopPolyMinRes}, 1041 {MODUL_CMD, MP_CopPolyModule}, 1042 {MULTIPLICITY_CMD, MP_CopPolyMultiplicity}, 1043 {ORD_CMD, MP_CopPolyOrder}, 1044 {PRUNE_CMD, MP_CopPolyPrune}, 1045 {QHWEIGHT_CMD, MP_CopPolyQHWeight}, 1046 {REGULARITY_CMD, MP_CopPolyRegularity}, 1047 {RESULTANT_CMD, MP_CopPolyResultant}, 1048 {STD_CMD, MP_CopPolyStd}, 1049 {SYZYGY_CMD, MP_CopPolySyz}, 1050 {VDIM_CMD, MP_CopPolyVdim}, 1051 {COEFFS_CMD, MP_CopPolyCoeffs}, 1052 {CONTRACT_CMD, MP_CopPolyContract}, 1053 {ELIMINATION_CMD, MP_CopPolyEliminate}, 1054 {JET_CMD, MP_CopPolyJet}, 1055 {LIFT_CMD, MP_CopPolyLift}, 1056 {LIFTSTD_CMD, MP_CopPolyLiftstd}, 1057 {MODULO_CMD, MP_CopPolyModulo}, 1058 {MRES_CMD, MP_CopPolyMres}, 1059 {QUOTIENT_CMD, MP_CopPolyQuotient}, 1060 {REDUCE_CMD, MP_CopPolyReduce}, 1061 {PREIMAGE_CMD, MP_CopPolyPreimage}, 1062 {RES_CMD, MP_CopPolyRes}, 1063 {RING_CMD, MP_CopPolyRing}, 1064 {MAX_TOK, 0} 1065 } 1066 }, 1067 { 1068 MP_NumberDict, 1069 // This is the list of all tokens which have an MP representation as a 1070 // cop in the Number dictionary 1071 { 1072 {PRIME_CMD, MP_CopNumberPrime}, 1073 {EXTGCD_CMD, MP_CopNumberExtGcd}, 1074 {GCD_CMD, MP_CopNumberGcd}, 1075 {RANDOM_CMD, MP_CopNumberRandom}, 1076 {MAX_TOK, 0} 1077 } 1078 }, 1079 { 1080 MP_MatrixDict, 1081 // This is the list of all tokens which have an MP representation as a 1082 // cop in the Matrix dictionary 1083 { 1084 {BAREISS_CMD, MP_CopMatrixBareiss}, 1085 {COLS_CMD, MP_CopMatrixCols}, 1086 {DET_CMD, MP_CopMatrixDet}, 1087 {JACOB_CMD, MP_CopMatrixJacobi}, 1088 {MATRIX_CMD, MP_CopMatrixDenseMatrix}, 1089 {ROWS_CMD, MP_CopMatrixRows}, 1090 {TRACE_CMD, MP_CopMatrixTrace}, 1091 {TRANSPOSE_CMD, MP_CopMatrixTranspose}, 1092 {KOSZUL_CMD, MP_CopMatrixKoszul}, 1093 {MINOR_CMD, MP_CopMatrixMinor}, 1094 {WEDGE_CMD, MP_CopMatrixWedge}, 1095 {MAX_TOK, 0} 1096 } 1097 }, 1098 { 1099 MP_BasicDict, 1100 // This is the list of all tokens which have an MP representation as a 1101 // cop in the MP Basic dictionary 1102 { 1103 {PLUSPLUS, MP_CopBasicInc}, 1104 {MINUSMINUS, MP_CopBasicDec}, 1105 {COUNT_CMD, MP_CopBasicSize}, 1106 {LIST_CMD, MP_CopBasicList}, 1107 {'+', MP_CopBasicAdd}, 1108 {'-', MP_CopBasicMinus}, 1109 {'*', MP_CopBasicMult}, 1110 {'/', MP_CopBasicDiv}, 1111 {'%', MP_CopBasicMod}, 1112 {'^', MP_CopBasicPow}, 1113 {GE, MP_CopBasicGreaterEqual}, 1114 {'<', MP_CopBasicGreater}, 1115 {LE, MP_CopBasicLessEqual}, 1116 {'>', MP_CopBasicLess}, 1117 {'&', MP_CopBasicAnd}, 1118 {'|', MP_CopBasicOr}, 1119 {'=', MP_CopBasicAssign}, 1120 {EQUAL_EQUAL, MP_CopBasicEqual}, 1121 {NOTEQUAL, MP_CopBasicNotEqual}, 1122 {DOTDOT, MP_CopBasicRange}, 1123 {'[', MP_CopBasicIndex}, 1124 {DIFF_CMD, MP_CopBasicDiff}, 1125 {INTERSECT_CMD, MP_CopBasicInterSect}, 1126 {SUBST_CMD, MP_CopBasicSubst}, 1127 {NOT, MP_CopBasicNot}, 1128 {COLONCOLON, MP_CopBasicPackage}, 1129 {MAX_TOK, 0} 1130 } 1131 } 1132 }; 1133 1134 1135 // Given a Singular token, find matching (dict,op): Return 1 if one is 1136 // found, 0, otherwise 1137 static short GetMPDictTok(short tok, MP_DictTag_t *dict, MP_Common_t *cop) 1138 { 1139 short i, l, j; 1140 cmd_op *cmd_ops; 1141 1142 // first, look through Singular specific commands 1143 l = sizeof(sr_cmds)/sizeof(short); 1144 if (l > MAX_COP) 1145 { 1146 fprintf(stderr, 1147 "Error: There are more than 256 entries in MP_SingularDict\n"); 1148 exit(1); 1149 } 1150 for (i=0; i<l; i++) 1151 if (sr_cmds[i] == tok) 1152 { 1153 *dict = MP_SingularDict; 1154 *cop = i; 1155 return 1; 1156 } 1157 1158 // look through all the other dicts 1159 for (j=0; j<MAX_SR_DICT-1; j++) 1160 { 1161 cmd_ops = cmd_dictcops[j].cmd_ops; 1162 for (i=0; (cmd_ops[i]).cmd != MAX_TOK; i++) 1163 { 1164 if (i > MAX_COP) 1165 { 1166 fprintf(stderr, 1167 "Error: There are more than 256 entries in dict %d's\n",j); 1168 exit(1); 1169 } 1170 if (cmd_ops[i].cmd == tok) 1171 { 1172 *dict = cmd_dictcops[j].dict; 1173 *cop = cmd_ops[i].cop; 1174 return 1; 1175 } 1176 } 1177 } 1178 return 0; 1179 } 1180 1181 1182 // This actually generates the tables of mpsr_tok.inc 1183 char *mpsr_Tok_inc; 1184 void mpsr_ttGen() 1185 { 1186 mpsr_cmd mpsrcmds[MAX_TOK]; 1187 short tok2mp[MAX_TOK]; 1188 short mp2tok[MAX_SR_DICT][MAX_COP]; 1189 short max_cmd = 0, i, j; 1190 MP_Common_t cop; 1191 FILE *outfile; 1192 MP_DictTag_t dict; 1193 1194 1195 // init all arrays 1196 for (i=0; i<MAX_TOK; i++) 1197 { 1198 mpsrcmds[i].tok = MAX_TOK; 1199 tok2mp[i] = MAX_TOK; 1200 } 1201 for (i=0; i<MAX_SR_DICT; i++) 1202 for (j=0; j<MAX_COP; j++) 1203 mp2tok[i][j] = MAX_TOK; 1204 1205 // Now go through all the token and test them 1206 for (i=0; i<MAX_TOK; i++) 1207 { 1208 if (IsCmdToken(i)) 1209 { 1210 if (GetMPDictTok(i, &dict, &cop)) 1211 { 1212 mpsrcmds[max_cmd].tok = i; 1213 mpsrcmds[max_cmd].dict = dict; 1214 mpsrcmds[max_cmd].cop = cop; 1215 tok2mp[i] = max_cmd; 1216 mp2tok[mpdict2srdict(dict)][cop] = i; 1217 max_cmd++; 1218 } 1219 //else 1220 //{ 1221 // fprintf(stderr, "Warning: mpsr_ttGen: Unknown Cmd Token: %d(%s)\n", 1222 // i, iiTwoOps(i)); 1223 // } 1224 } 1225 } 1226 1227 // Generate the template file 1228 mpsr_Tok_inc=strdup("mpsr_Tok.xxxxxxxx"); 1229 int pid=getpid(); 1230 mpsr_Tok_inc[8]=(pid %10)+'0'; pid/=10; 1231 mpsr_Tok_inc[9]=(pid %10)+'0'; pid/=10; 1232 mpsr_Tok_inc[10]=(pid %10)+'0'; pid/=10; 1233 mpsr_Tok_inc[11]=(pid %10)+'0'; pid/=10; 1234 mpsr_Tok_inc[12]=(pid %10)+'0'; pid/=10; 1235 mpsr_Tok_inc[13]=(pid %10)+'0'; 1236 1237 outfile = myfopen(mpsr_Tok_inc, "w"); 1238 if (outfile == NULL) 1239 { 1240 fprintf(stderr, "Error: mpsr_ttGen: Cannot open file mpsr_Tok.inc\n"); 1241 exit(1); 1242 } 1243 1244 // header 1245 fprintf(outfile, 1246 "/***************************************************************\n" 1247 "*\n" 1248 "* File: mpsr_tok.inc\n" 1249 "* Purpose: tables for mapping Singular cmds to/from MP (dict, op)\n" 1250 "*\n" 1251 "* THIS FILE WAS AUTOMATICALLY GENERATED BY mpsr_ttGen(). DO NOT EDIT!\n" 1252 "*\n" 1253 "***************************************************************/\n" 1254 "#ifndef MPSR_STRING_TABLES\n" 1255 "mpsr_cmd mpsr_cmds[] =\n" 1256 "{\n" 1257 " { %d,\t %d,\t %d }", mpsrcmds[0].tok, mpsrcmds[0].dict, mpsrcmds[0].cop); 1258 1259 // mpsrcmds 1260 for (i=1; i<max_cmd; i++) 1261 { 1262 fprintf(outfile, ",\n { %d,\t %d,\t %d }", 1263 mpsrcmds[i].tok, mpsrcmds[i].dict, mpsrcmds[i].cop); 1264 } 1265 fprintf(outfile,"\n};\n\n"); 1266 1267 // tok2mp 1268 fprintf(outfile, "short tok2mp[] = { %d", tok2mp[0]); 1269 for (i=1; i<MAX_TOK; i++) 1270 fprintf(outfile, ", %d", tok2mp[i]); 1271 fprintf(outfile, "};\n\n"); 1272 1273 // mp2tok 1274 fprintf(outfile, "short mp2tok[MAX_SR_DICT][MAX_COP] = \n{"); 1275 for (i=0; i<MAX_SR_DICT; i++) 1276 { 1277 fprintf(outfile, "\n{\n"); 1278 for (j=0; j<MAX_COP; j++) 1279 { 1280 fprintf(outfile, " %d",mp2tok[i][j]); 1281 if (j!=MAX_COP-1) fprintf(outfile, ","); 1282 } 1283 if (i!=MAX_SR_DICT-1) fprintf(outfile, "},"); 1284 else fprintf(outfile, "}"); 1285 } 1286 fprintf(outfile,"\n};\n\n"); 1287 1288 fprintf(outfile, "#else /* MPSR_STRING_TABLE */\n" 1289 "mpsr_cmd mpsr_cmds[] =\n" 1290 "{\n" 1291 "{ \"%s\",\t %d,\t %d }", 1292 iiTwoOps(mpsrcmds[0].tok), mpsrcmds[0].dict, mpsrcmds[0].cop); 1293 1294 for (i=1; i<max_cmd; i++) 1295 { 1296 fprintf(outfile, ",\n { \"%s\",\t %d,\t %d }", 1297 iiTwoOps(mpsrcmds[i].tok), mpsrcmds[i].dict, mpsrcmds[i].cop); 1298 } 1299 fprintf(outfile, ",\n { NULL, \t 0, \t 0}"); 1300 fprintf(outfile,"\n};\n\n#endif /* ! MPSR_STRING_TABLE */"); 1301 1302 fclose(outfile); 1303 } // That's all 1304 1305 #else 1306 void mpsr_ttGen() 1307 { 1308 system("touch mpsr_Tok.xx"); 1309 } 1310 #endif 1311 888 1312 int main() 889 1313 { 1314 //mpsr_ttGen(); 890 1315 ttGen4(); 891 1316 ttGen1(); … … 893 1318 rename(iparith_inc,"iparith.inc"); 894 1319 rename("plural_cmd.xx","plural_cmd.inc"); 1320 #ifdef HAVE_MPSR 1321 //rename(mpsr_Tok_inc,"mpsr_Tok.inc"); 1322 #endif 895 1323 return 0; 896 1324 } -
Singular/gentable2.cc
r2e937c r92232e 16 16 17 17 #include <Singular/mod2.h> 18 19 #ifdef HAVE_MPSR20 18 #include <Singular/tok.h> 21 19 #include <Singular/grammar.h> 20 21 #define ALLOW_PLURAL 1 22 #define NO_PLURAL 0 23 #define COMM_PLURAL 2 24 #define PLURAL_MASK 3 25 26 #define ALLOW_RING 4 27 #define NO_RING 0 28 29 30 /*=============== types =====================*/ 31 struct _scmdnames 32 { 33 const char *name; 34 short alias; 35 short tokval; 36 short toktype; 37 }; 38 typedef struct _scmdnames cmdnames; 39 40 41 struct sValCmd2 42 { 43 int p; 44 short cmd; 45 short res; 46 short arg1; 47 short arg2; 48 short valid_for; 49 }; 50 struct sValCmd1 51 { 52 int p; 53 short cmd; 54 short res; 55 short arg; 56 short valid_for; 57 }; 58 struct sValCmd3 59 { 60 int p; 61 short cmd; 62 short res; 63 short arg1; 64 short arg2; 65 short arg3; 66 short valid_for; 67 }; 68 struct sValCmdM 69 { 70 int p; 71 short cmd; 72 short res; 73 short number_of_args; /* -1: any, -2: any >0, .. */ 74 short valid_for; 75 }; 76 struct sValAssign_sys 77 { 78 int p; 79 short res; 80 short arg; 81 }; 82 83 struct sValAssign 84 { 85 int p; 86 short res; 87 short arg; 88 }; 89 90 struct sConvertTypes 91 { 92 int i_typ; 93 int o_typ; 94 int p; 95 int pl; 96 }; 97 98 99 #define jjWRONG 1 100 #define jjWRONG2 1 101 #define jjWRONG3 1 102 #define XS(A) A 103 104 105 #define D(A) 2 106 #define IPARITH 107 #define GENTABLE 108 #define IPCONV 109 #define IPASSIGN 110 111 #include "table.h" 112 113 const char * Tok2Cmdname(int tok) 114 { 115 int i = 0; 116 if (tok < 0) 117 { 118 return cmds[0].name; 119 } 120 if (tok==COMMAND) return "command"; 121 if (tok==ANY_TYPE) return "any_type"; 122 if (tok==NONE) return "nothing"; 123 //if (tok==IFBREAK) return "if_break"; 124 //if (tok==VECTOR_FROM_POLYS) return "vector_from_polys"; 125 //if (tok==ORDER_VECTOR) return "ordering"; 126 //if (tok==REF_VAR) return "ref"; 127 //if (tok==OBJECT) return "object"; 128 //if (tok==PRINT_EXPR) return "print_expr"; 129 if (tok==IDHDL) return "identifier"; 130 while (cmds[i].tokval!=0) 131 { 132 if ((cmds[i].tokval == tok)&&(cmds[i].alias==0)) 133 { 134 return cmds[i].name; 135 } 136 i++; 137 } 138 return cmds[0].name; 139 } 140 /*---------------------------------------------------------------------*/ 141 /** 142 * @brief compares to entry of cmdsname-list 143 144 @param[in] a 145 @param[in] b 146 147 @return <ReturnValue> 148 **/ 149 /*---------------------------------------------------------------------*/ 150 static int _gentable_sort_cmds( const void *a, const void *b ) 151 { 152 cmdnames *pCmdL = (cmdnames*)a; 153 cmdnames *pCmdR = (cmdnames*)b; 154 155 if(a==NULL || b==NULL) return 0; 156 157 /* empty entries goes to the end of the list for later reuse */ 158 if(pCmdL->name==NULL) return 1; 159 if(pCmdR->name==NULL) return -1; 160 161 /* $INVALID$ must come first */ 162 if(strcmp(pCmdL->name, "$INVALID$")==0) return -1; 163 if(strcmp(pCmdR->name, "$INVALID$")==0) return 1; 164 165 /* tokval=-1 are reserved names at the end */ 166 if (pCmdL->tokval==-1) 167 { 168 if (pCmdR->tokval==-1) 169 return strcmp(pCmdL->name, pCmdR->name); 170 /* pCmdL->tokval==-1, pCmdL goes at the end */ 171 return 1; 172 } 173 /* pCmdR->tokval==-1, pCmdR goes at the end */ 174 if(pCmdR->tokval==-1) return -1; 175 176 return strcmp(pCmdL->name, pCmdR->name); 177 } 178 179 /*generic*/ 180 const char * iiTwoOps(int t) 181 { 182 if (t<127) 183 { 184 static char ch[2]; 185 switch (t) 186 { 187 case '&': 188 return "and"; 189 case '|': 190 return "or"; 191 default: 192 ch[0]=t; 193 ch[1]='\0'; 194 return ch; 195 } 196 } 197 switch (t) 198 { 199 case COLONCOLON: return "::"; 200 case DOTDOT: return ".."; 201 //case PLUSEQUAL: return "+="; 202 //case MINUSEQUAL: return "-="; 203 case MINUSMINUS: return "--"; 204 case PLUSPLUS: return "++"; 205 case EQUAL_EQUAL: return "=="; 206 case LE: return "<="; 207 case GE: return ">="; 208 case NOTEQUAL: return "<>"; 209 default: return Tok2Cmdname(t); 210 } 211 } 212 // 213 // automatic conversions: 214 // 215 /*2 216 * try to convert 'inputType' in 'outputType' 217 * return 0 on failure, an index (<>0) on success 218 */ 219 int iiTestConvert (int inputType, int outputType) 220 { 221 if ((inputType==outputType) 222 || (outputType==DEF_CMD) 223 || (outputType==IDHDL) 224 || (outputType==ANY_TYPE)) 225 { 226 return -1; 227 } 228 229 // search the list 230 int i=0; 231 while (dConvertTypes[i].i_typ!=0) 232 { 233 if((dConvertTypes[i].i_typ==inputType) 234 &&(dConvertTypes[i].o_typ==outputType)) 235 { 236 //Print("test convert %d to %d (%s -> %s):%d\n",inputType,outputType, 237 //Tok2Cmdname(inputType), Tok2Cmdname(outputType),i+1); 238 return i+1; 239 } 240 i++; 241 } 242 //Print("test convert %d to %d (%s -> %s):0\n",inputType,outputType, 243 // Tok2Cmdname(inputType), Tok2Cmdname(outputType)); 244 return 0; 245 } 246 char *iparith_inc; 247 void ttGen1() 248 { 249 iparith_inc=strdup("iparith.xxxxxx"); 250 int pid=getpid(); 251 iparith_inc[8]=(pid %10)+'0'; pid/=10; 252 iparith_inc[9]=(pid %10)+'0'; pid/=10; 253 iparith_inc[10]=(pid %10)+'0'; pid/=10; 254 iparith_inc[11]=(pid %10)+'0'; pid/=10; 255 iparith_inc[12]=(pid %10)+'0'; pid/=10; 256 iparith_inc[13]=(pid %10)+'0'; 257 FILE *outfile = fopen(iparith_inc,"w"); 258 int i,j,l1=0,l2=0; 259 fprintf(outfile, 260 "/****************************************\n" 261 "* Computer Algebra System SINGULAR *\n" 262 "****************************************/\n\n"); 263 /*-------------------------------------------------------------------*/ 264 fprintf(outfile,"// syntax table for Singular\n//\n"); 265 fprintf(outfile,"// - search for an exact match of the argument types\n"); 266 fprintf(outfile,"// - otherwise search for the first possibility\n"); 267 fprintf(outfile,"// with converted types of the arguments\n"); 268 fprintf(outfile,"// - otherwise report an error\n//\n"); 269 270 int op; 271 i=0; 272 while ((op=dArith1[i].cmd)!=0) 273 { 274 if (dArith1[i].p==jjWRONG) 275 fprintf(outfile,"// DUMMY "); 276 const char *s = iiTwoOps(op); 277 fprintf(outfile,"// operation: %s (%s) -> %s\n", 278 s, 279 Tok2Cmdname(dArith1[i].arg), 280 Tok2Cmdname(ABS(dArith1[i].res))); 281 i++; 282 } 283 fprintf(outfile,"/*---------------------------------------------*/\n"); 284 i=0; 285 while ((op=dArith2[i].cmd)!=0) 286 { 287 if (dArith2[i].p==jjWRONG2) 288 fprintf(outfile,"// DUMMY "); 289 const char *s = iiTwoOps(op); 290 fprintf(outfile,"// operation: %s (%s, %s) -> %s\n", 291 s, 292 Tok2Cmdname(dArith2[i].arg1), 293 Tok2Cmdname(dArith2[i].arg2), 294 Tok2Cmdname(dArith2[i].res)); 295 i++; 296 } 297 fprintf(outfile,"/*---------------------------------------------*/\n"); 298 i=0; 299 while ((op=dArith3[i].cmd)!=0) 300 { 301 const char *s = iiTwoOps(op); 302 if (dArith3[i].p==jjWRONG3) 303 fprintf(outfile,"// DUMMY "); 304 fprintf(outfile,"// operation: %s (%s, %s, %s) -> %s\n", 305 s, 306 Tok2Cmdname(dArith3[i].arg1), 307 Tok2Cmdname(dArith3[i].arg2), 308 Tok2Cmdname(dArith3[i].arg3), 309 Tok2Cmdname(dArith3[i].res)); 310 i++; 311 } 312 fprintf(outfile,"/*---------------------------------------------*/\n"); 313 i=0; 314 while ((op=dArithM[i].cmd)!=0) 315 { 316 const char *s = iiTwoOps(op); 317 fprintf(outfile,"// operation: %s (...) -> %s", 318 s, 319 Tok2Cmdname(dArithM[i].res)); 320 switch(dArithM[i].number_of_args) 321 { 322 case -2: 323 fprintf(outfile," ( number of arguments >0 )\n"); 324 break; 325 case -1: 326 fprintf(outfile," ( any number of arguments )\n"); 327 break; 328 default: 329 fprintf(outfile," ( %d arguments )\n",dArithM[i].number_of_args); 330 break; 331 } 332 i++; 333 } 334 fprintf(outfile,"/*---------------------------------------------*/\n"); 335 i=0; 336 while ((op=dAssign[i].res)!=0) 337 { 338 fprintf(outfile,"// assign: %s = %s\n", 339 Tok2Cmdname(op/*dAssign[i].res*/), 340 Tok2Cmdname(dAssign[i].arg)); 341 i++; 342 } 343 /*-------------------------------------------------------------------*/ 344 fprintf(outfile,"/*---------------------------------------------*/\n"); 345 for (j=257;j<=MAX_TOK+1;j++) 346 { 347 for(i=257;i<=MAX_TOK+1;i++) 348 { 349 if ((i!=j) && (j!=IDHDL) && (j!=DEF_CMD) && (j!=ANY_TYPE) 350 && iiTestConvert(i,j)) 351 { 352 fprintf(outfile,"// convert %s -> %s\n", 353 Tok2Cmdname(i), Tok2Cmdname(j)); 354 if (j==ANY_TYPE) break; 355 } 356 } 357 } 358 fprintf(outfile,"/*---------------------------------------------*/\n"); 359 char ops[]="=><+*/[.^,%(;"; 360 for(i=0;ops[i]!='\0';i++) 361 fprintf(outfile,"// token %d : %c\n", (int)ops[i], ops[i]); 362 for (i=257;i<=MAX_TOK;i++) 363 { 364 const char *s=iiTwoOps(i); 365 if (s[0]!='$') 366 { 367 fprintf(outfile,"// token %d : %s\n", i, s); 368 } 369 } 370 /*-------------------------------------------------------------------*/ 371 fprintf(outfile,"/*--max. token: %d, gr: %d --*/\n",MAX_TOK,UMINUS); 372 /*-------------------------------------------------------------------*/ 373 fprintf(outfile,"/*---------------------------------------------*/\n"); 374 fprintf(outfile, 375 "struct sValCmdTab dArithTab1[]=\n" 376 "{\n"); 377 for (j=1;j<=MAX_TOK+1;j++) 378 { 379 for(i=0;dArith1[i].cmd!=0;i++) 380 { 381 if (dArith1[i].cmd==j) 382 { 383 fprintf(outfile," { %d,%d },\n",j,i); 384 l1++; 385 break; 386 } 387 } 388 } 389 fprintf(outfile," { 10000,0 }\n};\n"); 390 fprintf(outfile,"#define JJTAB1LEN %d\n",l1); 391 /*-------------------------------------------------------------------*/ 392 fprintf(outfile, 393 "struct sValCmdTab dArithTab2[]=\n" 394 "{\n"); 395 for (j=1;j<=MAX_TOK+1;j++) 396 { 397 for(i=0;dArith2[i].cmd!=0;i++) 398 { 399 if (dArith2[i].cmd==j) 400 { 401 fprintf(outfile," { %d,%d },\n",j,i); 402 l2++; 403 break; 404 } 405 } 406 } 407 fprintf(outfile," { 10000,0 }\n};\n"); 408 fprintf(outfile,"#define JJTAB2LEN %d\n",l2); 409 fclose(outfile); 410 } 411 /*-------------------------------------------------------------------*/ 412 #if 0 413 void ttGen2() 414 { 415 FILE *outfile = fopen(iparith_inc,"a"); 416 fprintf(outfile, 417 "/****************************************\n" 418 "* Computer Algebra System SINGULAR *\n" 419 "****************************************/\n\n"); 420 /*-------------------------------------------------------------------*/ 421 fprintf(outfile,"// identifier table for Singular\n//\n"); 422 423 fprintf(outfile, 424 "cmdnames OLDcmds[] =\n" 425 "{ // name-string alias tokval toktype\n" 426 "{ \"$INVALID$\", 0, -1, 0},\n"); 427 int i=1; 428 int m=-1; 429 int id_nr=0; 430 BOOLEAN f=FALSE; 431 loop 432 { 433 while (cmds[i].tokval!=0) 434 { 435 if ((cmds[i].tokval!=-1)&&(cmds[i].name!=NULL)) 436 { 437 if(m==-1) 438 { 439 m=i; 440 f=TRUE; 441 } 442 else if(strcmp(cmds[m].name,cmds[i].name)>0) 443 { 444 m=i; 445 f=TRUE; 446 } 447 } 448 i++; 449 } 450 if(f) 451 { 452 id_nr++; 453 if(cmds[m].tokval==VRTIMER) fprintf(outfile,"#ifdef HAVE_RTIMER\n"); 454 fprintf(outfile," {\"%s\", %*d, %3d, ",cmds[m].name, 455 20-strlen(cmds[m].name), 456 cmds[m].alias, 457 cmds[m].tokval); 458 switch(cmds[m].toktype) 459 { 460 case CMD_1: fprintf(outfile,"CMD_1 },\n"); break; 461 case CMD_2: fprintf(outfile,"CMD_2 },\n"); break; 462 case CMD_3: fprintf(outfile,"CMD_3 },\n"); break; 463 case CMD_12: fprintf(outfile,"CMD_12 },\n"); break; 464 case CMD_123 : fprintf(outfile,"CMD_123 },\n"); break; 465 case CMD_23: fprintf(outfile,"CMD_23 },\n"); break; 466 case CMD_M: fprintf(outfile,"CMD_M },\n"); break; 467 case SYSVAR: fprintf(outfile,"SYSVAR },\n"); break; 468 case ROOT_DECL: fprintf(outfile,"ROOT_DECL },\n"); break; 469 case ROOT_DECL_LIST: fprintf(outfile,"ROOT_DECL_LIST },\n"); break; 470 case RING_DECL: fprintf(outfile,"RING_DECL },\n"); break; 471 case NONE: fprintf(outfile,"NONE },\n"); break; 472 default: if((cmds[m].toktype>' ') 473 &&(cmds[m].toktype<127)) 474 { 475 fprintf(outfile,"'%c' },\n",cmds[m].toktype); 476 } 477 else 478 { 479 fprintf(outfile,"%d },\n",cmds[m].toktype); 480 } 481 break; 482 } 483 if(cmds[m].tokval==VRTIMER) fprintf(outfile,"#endif\n"); 484 cmds[m].name=NULL; 485 m=-1; 486 i=1; 487 f=FALSE; 488 } 489 else break; 490 } 491 fprintf(outfile, 492 "/* list of scanner identifiers/only for feread/reservedName */\n"); 493 f=FALSE; 494 i=1;m=-1; 495 loop 496 { 497 while (cmds[i].tokval!=0) 498 { 499 if (cmds[i].name!=NULL) 500 { 501 if(m==-1) 502 { 503 m=i; 504 f=TRUE; 505 } 506 else if(strcmp(cmds[m].name,cmds[i].name)>0) 507 { 508 m=i; 509 f=TRUE; 510 } 511 } 512 i++; 513 } 514 if(f) 515 { 516 fprintf(outfile," {\"%s\", %*d, -1, 0 },\n",cmds[m].name, 517 20-strlen(cmds[m].name), 518 0/*cmds[m].alias*/ 519 /*-1 cmds[m].tokval*/ 520 /*0 cmds[m].toktype*/); 521 cmds[m].name=NULL; 522 m=-1; 523 i=1; 524 f=FALSE; 525 } 526 else break; 527 } 528 fprintf(outfile, 529 "/* end of list marker */\n" 530 " { NULL, 0, 0, 0}\n" 531 "};\n" 532 "#ifdef HAVE_RTIMER\n" 533 "#define LAST_IDENTIFIER %d\n" 534 "#else\n" 535 "#define LAST_IDENTIFIER %d\n" 536 "#endif\n",id_nr,id_nr-1); 537 fclose(outfile); 538 } 539 #endif 540 /*---------------------------------------------------------------------*/ 541 /** 542 * @brief generate cmds initialisation 543 **/ 544 /*---------------------------------------------------------------------*/ 545 546 void ttGen2b() 547 { 548 int cmd_size = (sizeof(cmds)/sizeof(cmdnames))-1; 549 550 FILE *outfile = fopen(iparith_inc,"a"); 551 fprintf(outfile, 552 "/****************************************\n" 553 "* Computer Algebra System SINGULAR *\n" 554 "****************************************/\n\n"); 555 /*-------------------------------------------------------------------*/ 556 fprintf(outfile,"// identifier table for Singular\n//\n"); 557 558 fprintf( 559 outfile, 560 "#ifdef MODULE_GENERATOR\n" 561 "#define omAlloc0(A) malloc(A)\n" 562 "#endif\n" 563 "void iiInitCmdName()\n{\n" 564 " sArithBase.nCmdUsed = 0;\n" 565 " sArithBase.nCmdAllocated = %d;\n" 566 " sArithBase.sCmds = (cmdnames*)omAlloc0(sArithBase.nCmdAllocated*sizeof(cmdnames));\n" 567 "\n" 568 " // name-string alias tokval toktype index\n", 569 cmd_size); 570 int m=0; 571 int id_nr=0; 572 573 qsort(&cmds, cmd_size, sizeof(cmdnames), (&_gentable_sort_cmds)); 574 575 for(m=0; m<cmd_size; m++) 576 { 577 if(cmds[m].tokval>0) id_nr++; 578 if(cmds[m].tokval==VRTIMER) fprintf(outfile,"#ifdef HAVE_RTIMER\n"); 579 fprintf(outfile," iiArithAddCmd(\"%s\", %*d, %3d, ",cmds[m].name, 580 (int)(20-strlen(cmds[m].name)), 581 cmds[m].alias, 582 cmds[m].tokval); 583 switch(cmds[m].toktype) 584 { 585 case CMD_1: fprintf(outfile,"CMD_1"); break; 586 case CMD_2: fprintf(outfile,"CMD_2"); break; 587 case CMD_3: fprintf(outfile,"CMD_3"); break; 588 case CMD_12: fprintf(outfile,"CMD_12"); break; 589 case CMD_123 : fprintf(outfile,"CMD_123"); break; 590 case CMD_23: fprintf(outfile,"CMD_23"); break; 591 case CMD_M: fprintf(outfile,"CMD_M"); break; 592 case SYSVAR: fprintf(outfile,"SYSVAR"); break; 593 case ROOT_DECL: fprintf(outfile,"ROOT_DECL"); break; 594 case ROOT_DECL_LIST: fprintf(outfile,"ROOT_DECL_LIST"); break; 595 case RING_DECL: fprintf(outfile,"RING_DECL"); break; 596 case NONE: fprintf(outfile,"NONE"); break; 597 default: 598 if((cmds[m].toktype>' ') &&(cmds[m].toktype<127)) 599 { 600 fprintf(outfile,"'%c'",cmds[m].toktype); 601 } 602 else 603 { 604 fprintf(outfile,"%d",cmds[m].toktype); 605 } 606 break; 607 #if 0 608 fprintf(outfile," iiArithAddCmd(\"%s\", %*d, -1, 0 );\n", 609 cmds[m].name, 20-strlen(cmds[m].name), 610 0/*cmds[m].alias*/ 611 /*-1 cmds[m].tokval*/ 612 /*0 cmds[m].toktype*/); 613 #endif 614 } 615 fprintf(outfile,", %d);\n", m); 616 if(cmds[m].tokval==VRTIMER) fprintf(outfile,"#endif\n"); 617 } 618 fprintf(outfile, "/* end of list marker */\n"); 619 fprintf(outfile, 620 "#ifdef HAVE_RTIMER\n" 621 " sArithBase.nLastIdentifier = %d;\n" 622 "#else /* HAVE_RTIMER */\n" 623 " sArithBase.nLastIdentifier = %d;\n" 624 "#endif /* HAVE_RTIMER */\n", 625 id_nr,id_nr-1); 626 627 628 fprintf(outfile, 629 "}\n" 630 "#ifdef HAVE_RTIMER\n" 631 "#define LAST_IDENTIFIER %d\n" 632 "#else\n" 633 "#define LAST_IDENTIFIER %d\n" 634 "#endif\n",id_nr,id_nr-1); 635 fclose(outfile); 636 } 637 /*-------------------------------------------------------------------*/ 638 #if 0 639 void ttGen3() 640 { 641 FILE *outfile = fopen("mpsr_tok.inc","w"); 642 fprintf(outfile, 643 "/****************************************\n" 644 "* Computer Algebra System SINGULAR *\n" 645 "****************************************/\n\n"); 646 /*-------------------------------------------------------------------*/ 647 fprintf(outfile,"// token table for Singular\n//\n"); 648 649 fprintf(outfile, 650 "short vtok[] =\n" 651 "{\n"); 652 // operations with 1 arg: =========================================== 653 int i=0; 654 while (dArith1[i].cmd!=0) 655 { 656 if ((dArith1[i].p!=jjWRONG) 657 &&((i==0)||(dArith1[i].cmd!=dArith1[i-1].cmd))) 658 { 659 fprintf(outfile," %d,\n",dArith1[i].cmd); 660 } 661 i++; 662 } 663 // operations with 2 args: =========================================== 664 i=0; 665 while (dArith2[i].cmd!=0) 666 { 667 if ((dArith2[i].p!=jjWRONG2) 668 &&((i==0)||(dArith2[i].cmd!=dArith2[i-1].cmd))) 669 { 670 fprintf(outfile," %d,\n",dArith2[i].cmd); 671 } 672 i++; 673 } 674 // operations with 3 args: =========================================== 675 i=0; 676 while (dArith3[i].cmd!=0) 677 { 678 if ( 679 ((i==0)||(dArith3[i].cmd!=dArith3[i-1].cmd))) 680 { 681 fprintf(outfile," %d,\n",dArith3[i].cmd); 682 } 683 i++; 684 } 685 // operations with many args: =========================================== 686 i=0; 687 while (dArithM[i].cmd!=0) 688 { 689 if ( 690 ((i==0)||(dArithM[i].cmd!=dArithM[i-1].cmd))) 691 { 692 fprintf(outfile," %d,\n",dArithM[i].cmd); 693 } 694 i++; 695 } 696 // ==================================================================== 697 fprintf(outfile, 698 "/* end of list marker */\n" 699 " %d };\n",MAX_TOK); 700 fclose(outfile); 701 } 702 #endif 703 void ttGen4() 704 { 705 FILE *outfile = fopen("plural_cmd.xx","w"); 706 int i; 707 const char *old_s=""; 708 fprintf(outfile, 709 "@c *****************************************\n" 710 "@c * Computer Algebra System SINGULAR *\n" 711 "@c *****************************************\n\n"); 712 /*-------------------------------------------------------------------*/ 713 fprintf(outfile,"@multicolumn .45 .45\n"); 714 int op; 715 i=0; 716 while ((op=dArith1[i].cmd)!=0) 717 { 718 if (dArith1[i].p!=jjWRONG) 719 { 720 const char *s = iiTwoOps(op); 721 if ((s!=NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0)) 722 { 723 old_s=s; 724 #ifdef HAVE_PLURAL 725 switch (dArith1[i].valid_for & PLURAL_MASK) 726 { 727 case NO_PLURAL: 728 fprintf(outfile,"@item @ref{%s} @tab @code{---}\n",s); 729 break; 730 case ALLOW_PLURAL: 731 fprintf(outfile,"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s); 732 break; 733 case COMM_PLURAL: 734 fprintf(outfile,"@item @ref{%s} @tab %s\n",s,s); 735 break; 736 } 737 #endif 738 #ifdef HAVE_RINGS 739 #endif 740 } 741 } 742 i++; 743 } 744 fprintf(outfile,"@c ---------------------------------------------\n"); 745 i=0; 746 while ((op=dArith2[i].cmd)!=0) 747 { 748 if (dArith2[i].p!=jjWRONG2) 749 { 750 const char *s = iiTwoOps(op); 751 if ((s!=NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0)) 752 { 753 old_s=s; 754 #ifdef HAVE_PLURAL 755 switch (dArith2[i].valid_for & PLURAL_MASK) 756 { 757 case NO_PLURAL: 758 fprintf(outfile,"@item @ref{%s} @tab @code{---}\n",s); 759 break; 760 case ALLOW_PLURAL: 761 fprintf(outfile,"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s); 762 break; 763 case COMM_PLURAL: 764 fprintf(outfile,"@item @ref{%s} @tab %s\n",s,s); 765 break; 766 } 767 #endif 768 #ifdef HAVE_RINGS 769 #endif 770 } 771 } 772 i++; 773 } 774 fprintf(outfile,"@c ---------------------------------------------\n"); 775 i=0; 776 while ((op=dArith3[i].cmd)!=0) 777 { 778 const char *s = iiTwoOps(op); 779 if (dArith3[i].p!=jjWRONG3) 780 { 781 if ((s!=NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0)) 782 { 783 old_s=s; 784 #ifdef HAVE_PLURAL 785 switch (dArith3[i].valid_for & PLURAL_MASK) 786 { 787 case NO_PLURAL: 788 fprintf(outfile,"@item @ref{%s} @tab @code{---}\n",s); 789 break; 790 case ALLOW_PLURAL: 791 fprintf(outfile,"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s); 792 break; 793 case COMM_PLURAL: 794 fprintf(outfile,"@item @ref{%s} @tab %s\n",s,s); 795 break; 796 } 797 #endif 798 #ifdef HAVE_RINGS 799 #endif 800 } 801 } 802 i++; 803 } 804 fprintf(outfile,"@c ---------------------------------------------\n"); 805 i=0; 806 while ((op=dArithM[i].cmd)!=0) 807 { 808 const char *s = iiTwoOps(op); 809 if ((s!=NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0)) 810 { 811 old_s=s; 812 #ifdef HAVE_PLURAL 813 switch (dArithM[i].valid_for & PLURAL_MASK) 814 { 815 case NO_PLURAL: 816 fprintf(outfile,"@item @ref{%s} @tab @code{---}\n",s); 817 break; 818 case ALLOW_PLURAL: 819 fprintf(outfile,"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s); 820 break; 821 case COMM_PLURAL: 822 fprintf(outfile,"@item @ref{%s} @tab %s\n",s,s); 823 break; 824 } 825 #endif 826 #ifdef HAVE_RINGS 827 #endif 828 } 829 i++; 830 } 831 fprintf(outfile,"@c ---------------------------------------------\n"); 832 fprintf(outfile,"@end table\n"); 833 fclose(outfile); 834 } 835 /*-------------------------------------------------------------------*/ 836 837 // some special cmds which do not fit in with the others, and 838 // nevertheless need to be transmitted 839 short ExtraCmds[] = 840 { 841 OPTION_CMD, 842 NAMES_CMD, 843 // RESERVEDNAME_CMD, 844 PROC_CMD, 845 MAP_CMD, 846 PACKAGE_CMD, 847 '=', 848 0 849 }; 850 851 // This returns 1 if tok is a token which can appear in a Singular 852 // (quoted) command, and 0 otherwise 853 short IsCmdToken(short tok) 854 { 855 int i = 0; 856 // cmds with one arg 857 while (dArith1[i].cmd != 0) 858 if (dArith1[i].cmd == tok) return 1; 859 else i++; 860 861 // cmds with two args 862 i=0; 863 while (dArith2[i].cmd != 0) 864 if (dArith2[i].cmd == tok) return 1; 865 else i++; 866 867 // cmds with three args 868 i=0; 869 while (dArith3[i].cmd != 0) 870 if (dArith3[i].cmd == tok) return 1; 871 else i++; 872 873 // cmds with many args 874 i=0; 875 while (dArithM[i].cmd != 0) 876 if (dArithM[i].cmd == tok) return 1; 877 else i++; 878 879 // cmds which are somewhat special (like those having 0 args) 880 i=0; 881 while (ExtraCmds[i] != 0) 882 if (ExtraCmds[i] == tok) return 1; 883 else i++; 884 885 return 0; 886 } 887 888 #ifdef HAVE_MPSR 22 889 #include <Singular/mpsr.h> 23 890 #include <Singular/mpsr_Tok.h> … … 446 1313 { 447 1314 mpsr_ttGen(); 1315 //ttGen4(); 1316 //ttGen1(); 1317 //ttGen2b(); 1318 //rename(iparith_inc,"iparith.inc"); 1319 //rename("plural_cmd.xx","plural_cmd.inc"); 448 1320 #ifdef HAVE_MPSR 449 1321 rename(mpsr_Tok_inc,"mpsr_Tok.inc");
Note: See TracChangeset
for help on using the changeset viewer.