1025{
1026 noeudPtr l1 = NULL, l2 = NULL, l3 = NULL, res = NULL;
1027 Symbol thesym;
1028 ident *theid = NULL;
1029 float thecst;
1030 char *thechaine;
1031
1032 switch (cursym)
1033 {
1034 case si:
1035 nextsym ();
1036 flag.si = 1;
1037 l1 = expr ();
1038 flag.si = 0;
1039 match (alors);
1040 l2 = instruction ();
1041 if (cursym == autrement)
1042 {
1043 nextsym ();
1044 l3 = instruction ();
1045 }
1046 else
1047 l3 = NULL;
1048 plante (&res, si, 0.F, 0, NULL, pt, l1, l2, l3, NULL);
1049 break;
1050
1051 case loop:
1052 nextsym ();
1053 match (lpar);
1054 thecst = curcst;
1055 match (cste);
1056 match (rpar);
1057 l1 = instruction ();
1058 plante (&res, loop, thecst, 0, NULL, pt, l1, NULL, NULL, NULL);
1059 break;
1060
1061 case newvar:
1062 case oldvar:
1063 case fdecl:
1064 theid = curident;
1065 nextsym ();
1066 if (cursym == fctdef)
1067 {
1068 if (strcmp(theid->name,"x")&&strcmp(theid->name,"y"))
1069 theid->symb = fdecl;
1070 if (!flag.fct)
1071 match (becomes);
1072 match (fctdef);
1073 l1 = expr ();
1074 plante (&res, fctdef, 0.F, 0, theid, pt, l1, NULL, NULL, NULL);
1075 }
1076 else
1077 {
1078 if (theid->symb == fdecl)
1079 theid->symb = oldvar;
1080 match (becomes);
1081 l1 = expr ();
1082 plante (&res, becomes, 0.F, 0, theid, pt, l1, NULL, NULL, NULL);
1083 }
1084 break;
1085
1086 case fctfile:
1087 res = fctfileproc ();
1088 break;
1089
1090 case symb_bdy:
1091 case polygon:
1092 res = symb_bdyproc ();
1093 break;
1094
1095 case symb_build:
1096 if (!flag.build)
1097 {
1098 sprintf (errbuf, "line %d: Illegal use of symbol 'buildmesh'", numligne);
1099 erreur (errbuf);
1100 }
1101 nba = 0;
1102 nbsd = 0;
1103 nbs = 0;
1104 nextsym ();
1105 match (lpar);
1106 l1 = expr ();
1107 if(cursym==comma) {nextsym(); l2 = expr();} else l2=NULL;
1108 plante (&res, symb_build, 0.F, 0, NULL, pt, l1, l2, NULL, NULL);
1109 match (rpar);
1110 flag.build = 0;
1111 flag.bdy = 0;
1112 flag.fct = 1;
1113 flag.onbdy = 1;
1114 flag.solv = 1;
1115 break;
1116
1117 case chargmsh:
1118 case sauvmsh:
1119 case symb_exec:
1120 res = diskmshproc ();
1121 break;
1122
1123 case charge:
1124 if (!flag.fct)
1125 {
1126 sprintf (errbuf, "Illegal use of symbol %s\n", mesg[cursym]);
1127 erreur (errbuf);
1128 }
1129 thesym = cursym;
1130 nextsym ();
1131 match (lpar);
1132 thechaine = curchaine;
1133 nextsym ();
1134 match (comma);
1135 theid = curident;
1136 switch (theid->symb)
1137 {
1138 case newvar:
1139 case oldvar:
1140 theid->symb = fdecl;
1141 nextsym ();
1142 break;
1143
1144 default:
1145 match (fdecl);
1146 }
1147 if (cursym == comma)
1148 {
1149 nextsym();
1150 l1 = expr();
1151 }
1152 match (rpar);
1153 plante (&res, thesym, 0.F, 0, theid, thechaine, l1, NULL, NULL, NULL);
1154 break;
1155
1156 case sauve:
1157 if (!flag.fct)
1158 {
1159 sprintf (errbuf, "line %d: Unexpected symbol %s\n", numligne, mesg[cursym]);
1160 erreur (errbuf);
1161 }
1162 thesym = cursym;
1163 nextsym ();
1164 match (lpar);
1165 thechaine = curchaine;
1166 nextsym ();
1167 match (comma);
1168 if (cursym == oldvar)
1169 {
1170 thecst = 1.F;
1171 std::ofstream file (thechaine);
1172
1173 file << ' ' << std::endl;
1174 file.close ();
1175 }
1176 else
1177 thecst = 0.F;
1178 l1 = expr ();
1179 if (cursym == comma)
1180 {
1181 nextsym();
1182 l2 = expr();
1183 }
1184 match (rpar);
1185 plante (&res, thesym, thecst, 0, NULL, thechaine, l1, l2, NULL, NULL);
1186 break;
1187
1188 case trace:
1189 case trace3d:
1190 if (!flag.fct)
1191 {
1192 sprintf (errbuf, "line %d: Unexpected symbol %s\n", numligne, mesg[cursym]);
1193 erreur (errbuf);
1194 }
1195 thesym = cursym;
1196 nextsym ();
1197 match (lpar);
1198 l1 = expr ();
1199 plante (&res, thesym, 0.F, 0, NULL, pt, l1, NULL, NULL, NULL);
1200 match (rpar);
1201 break;
1202
1203 case adaptmesh:
1204 {
1205 int i = 0;
1206 noeudPtr li[4] = {NULL,NULL,NULL,NULL};
1207 nextsym ();
1208 match (lpar);
1209 li[i++] = expr ();
1210 while (cursym == comma)
1211 {
1212 nextsym();
1213 li[i] = expr();
1214 i++;
1215 }
1216 plante (&res, adaptmesh, 0.F, 0, NULL, pt, li[0], li[1], li[2], li[3]);
1217 match (rpar);
1218 }
1219 break;
1220
1221 case symb_dch:
1222 if (flag.syst)
1223 res = symb_dchproc ();
1224 else
1225 {
1226 sprintf (errbuf, "line %d: onbdy must be nested within solve(){...}\n", numligne);
1227 erreur (errbuf);
1228 }
1229 break;
1230
1231
1232 case symb_pde:
1233 res = symb_pdeproc ();
1234 break;
1235
1236 case symb_solv:
1237 case sauvetout:
1238 thesym = cursym;
1239 if (flag.syst)
1240 erreur ("Embedded solvers are not allowed");
1241 flag.syst = 1;
1242 res = preparesolve ();
1243 l2 = instruction ();
1244 plante (&res, thesym, 0.F, N, NULL, NULL, res, l2, NULL, NULL);
1245 flag.syst = 0;
1246 N = 1;
1247 break;
1248
1249 case varsolve:
1250
1251 thesym = cursym;
1252 if (flag.syst)
1253 erreur ("Embedded solvers are not allowed");
1254 flag.syst = 1;
1255 res = prepvarsolve ();
1256 l2 = instruction ();
1257 match(colon);
1258 l3 = expr();
1259 plante (&res, colon, 0.F, N, NULL, NULL, res, l2, l3, NULL);
1260 flag.syst = 0;
1261 N = 1;
1262 break;
1263
1264 case arret:
1265 case changewait:
1266 case wait_state:
1267 case nowait:
1268 case symb_complex:
1269 case symb_precise:
1270 plante (&res, cursym, 0.F, 0, NULL, pt, NULL, NULL, NULL, NULL);
1271 nextsym ();
1272 break;
1273
1274 case lbrace:
1275 do
1276 {
1277 nextsym ();
1278 l1 = instruction ();
1279 if (res == NULL)
1280 res = l1;
1281 else if (l1)
1282 plante (&res, lbrace, 0.F, 0, NULL, pt, res, l1, NULL, NULL);
1283 }
1284 while (cursym == semicolon);
1285 match (rbrace);
1286 break;
1287
1288 case semicolon:
1289 nextsym ();
1290 case rbrace:
1291 case _end:
1292 break;
1293
1294 default:
1295 sprintf (errbuf, "line %d: Cannot use this symbol to begin an expression: %s",
1296 numligne, mesg[cursym]);
1297 erreur (errbuf);
1298 }
1299 return res;
1300}