Changeset 3252

Show
Ignore:
Timestamp:
01/26/12 21:06:24 (4 months ago)
Author:
erkn
Message:

Code generation: removed STATE PARAMETERS from grammar. Coordinate change
functions have been adapted accordingly, for both X and n.

Location:
branches/mcxtrace-1.0/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/mcxtrace-1.0/src/cogen.c.in

    r3248 r3252  
    10271027  struct comp_inst *comp; 
    10281028  struct group_inst *group; 
     1029  int i; 
    10291030 
    10301031  if (verbose) fprintf(stderr, "Writing instrument and components TRACE\n"); 
     1032   
     1033  static char *statepars_all[NUM_STATE_PARS] = 
     1034  { /* these particle state parameter names are used for all calls */ 
     1035#if MCCODE_PROJECT == 1     /* neutron */ 
     1036        "x", "y", "z", "vx", "vy", "vz", 
     1037        "t", "sx", "sy", "sz", "p" 
     1038#elif MCCODE_PROJECT == 2   /* xray */ 
     1039        "x", "y", "z", "kx", "ky", "kz", 
     1040        "phi", "t", "Ex", "Ey","Ez", "p" 
     1041#endif 
     1042  }; 
     1043  static char *statepars_change[9] = 
     1044  { /* these particle state parameter names are used for coordinate change only */ 
     1045#if MCCODE_PROJECT == 1     /* neutron */ 
     1046        "x", "y", "z", "vx", "vy", "vz", "sx", "sy", "sz" 
     1047#elif MCCODE_PROJECT == 2   /* xray */ 
     1048        "x", "y", "z", "kx", "ky", "kz", "Ex", "Ey","Ez" 
     1049#endif 
     1050  }; 
    10311051 
    10321052  /* Output the function header. */ 
     
    10341054  /* Local @MCCODE_PARTICULE@ state. */ 
    10351055  cout("  /* Copy @MCCODE_PARTICULE@ state to local variables. */"); 
    1036   coutf("  MCNUM %snlx = %snx;", ID_PRE, ID_PRE); 
    1037   coutf("  MCNUM %snly = %sny;", ID_PRE, ID_PRE); 
    1038   coutf("  MCNUM %snlz = %snz;", ID_PRE, ID_PRE); 
    1039 #if MCCODE_PROJECT == 1     /* neutron */ 
    1040   coutf("  MCNUM %snlvx = %snvx;", ID_PRE, ID_PRE); 
    1041   coutf("  MCNUM %snlvy = %snvy;", ID_PRE, ID_PRE); 
    1042   coutf("  MCNUM %snlvz = %snvz;", ID_PRE, ID_PRE); 
    1043   coutf("  MCNUM %snlt = %snt;", ID_PRE, ID_PRE); 
    1044   coutf("  MCNUM %snlsx = %snsx;", ID_PRE, ID_PRE); 
    1045   coutf("  MCNUM %snlsy = %snsy;", ID_PRE, ID_PRE); 
    1046   coutf("  MCNUM %snlsz = %snsz;", ID_PRE, ID_PRE); 
    1047 #elif MCCODE_PROJECT == 2   /* xray */ 
    1048   coutf("  MCNUM %snlkx = %snkx;", ID_PRE, ID_PRE); 
    1049   coutf("  MCNUM %snlky = %snky;", ID_PRE, ID_PRE); 
    1050   coutf("  MCNUM %snlkz = %snkz;", ID_PRE, ID_PRE); 
    1051   coutf("  MCNUM %snlphi = %snphi;", ID_PRE, ID_PRE); 
    1052   coutf("  MCNUM %snlt = %snt;", ID_PRE, ID_PRE); 
    1053   coutf("  MCNUM %snlEx = %snEx;", ID_PRE, ID_PRE); 
    1054   coutf("  MCNUM %snlEy = %snEy;", ID_PRE, ID_PRE); 
    1055   coutf("  MCNUM %snlEz = %snEz;", ID_PRE, ID_PRE); 
    1056 #endif     
    1057   coutf("  MCNUM %snlp = %snp;", ID_PRE, ID_PRE); 
     1056  for(i = 0; i < NUM_STATE_PARS; i++) 
     1057    coutf("  MCNUM %snl%s = %sn%s;", ID_PRE, statepars_all[i], ID_PRE, statepars_all[i]); 
    10581058  cout(""); 
    10591059 
    10601060  /* Debugging (initial state). */ 
    10611061  coutf("  %sDEBUG_ENTER()", ID_PRE); 
    1062 #if MCCODE_PROJECT == 1     /* neutron */ 
    1063   coutf("  %sDEBUG_STATE(%snlx, %snly, %snlz, %snlvx, %snlvy, %snlvz," 
    1064         " %snlt, %snlsx,%snlsy,%snlsz, %snlp)", 
    1065         ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1066         ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
    1067 #elif MCCODE_PROJECT == 2   /* xray */ 
    1068   coutf("  %sDEBUG_STATE(%snlx, %snly, %snlz, %snlkx, %snlky, %snlkz," 
    1069         "%snlphi,%snlt, %snlEx,%snlEy,%snlEz, %snlp)", 
    1070         ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1071         ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
    1072 #endif 
     1062  coutf("  %sDEBUG_STATE(" , ID_PRE); 
     1063  for(i = 0; i < NUM_STATE_PARS; i++) 
     1064    if (i < NUM_STATE_PARS-1) coutf("    %snl%s,", ID_PRE, statepars_all[i]); 
     1065    else                      coutf("    %snl%s)", ID_PRE, statepars_all[i]); 
    10731066 
    10741067  /* Set group flags */ 
     
    11221115  while((comp = list_next(liter)) != NULL) 
    11231116  { 
    1124  
    1125     char *statepars[NUM_STATE_PARS]; 
    1126     static char *statepars_names[NUM_STATE_PARS] = 
    1127       { 
    1128 #if MCCODE_PROJECT == 1     /* neutron */ 
    1129         "nlx", "nly", "nlz", "nlvx", "nlvy", "nlvz", 
    1130         "nlt", "nlsx", "nlsy", "nlsz", "nlp" 
    1131 #elif MCCODE_PROJECT == 2   /* xray */ 
    1132         "nlx", "nly", "nlz", "nlkx", "nlky", "nlkz", 
    1133         "nlphi", "nlt", "nlEx", "nlEy","nlEz", "nlp" 
    1134 #endif 
    1135       }; 
    1136     int i; 
    11371117    List_handle statepars_handle; 
    11381118 
    11391119    coutf("  /* TRACE Component %s [%i] */", comp->name, comp->index); 
    11401120 
    1141     /* Change of coordinates to local frame. */ 
     1121    /* Change of coordinates to local frame, including spin. */ 
    11421122    coutf("  %scoordschange(%sposr%s, %srotr%s,", ID_PRE, ID_PRE, comp->name, 
    11431123          ID_PRE, comp->name); 
    1144     coutf("    &%snlx, &%snly, &%snlz,", ID_PRE, ID_PRE, ID_PRE); 
    1145 #if MCCODE_PROJECT == 1     /* neutron */ 
    1146     coutf("    &%snlvx, &%snlvy, &%snlvz);", ID_PRE, ID_PRE, ID_PRE); 
    1147 #elif MCCODE_PROJECT == 2   /* xray */ 
    1148     coutf("    &%snlkx, &%snlky, &%snlkz);", ID_PRE, ID_PRE, ID_PRE); 
    1149 //    coutf("    &%snlphi, &%snlEx, &%snlEy);", ID_PRE, ID_PRE, ID_PRE); 
    1150 #endif 
    1151  
    1152     /* Change of spin to local frame. */ 
    1153     coutf("  %scoordschange_polarisation(" 
    1154 #if MCCODE_PROJECT == 1     /* neutron */ 
    1155           "%srotr%s, &%snlsx, &%snlsy, &%snlsz);", 
    1156 #elif MCCODE_PROJECT == 2   /* xray */ 
    1157           "%srotr%s, &%snlEx, &%snlEy, &%snlEz);", 
    1158 #endif 
    1159           ID_PRE, ID_PRE, comp->name, ID_PRE, ID_PRE, ID_PRE); 
    1160  
     1124    for(i = 0; i < 9; i++) 
     1125      if (i < 9-1) coutf("    &%snl%s,",  ID_PRE, statepars_change[i]); 
     1126      else         coutf("    &%snl%s);", ID_PRE, statepars_change[i]); 
    11611127     
    11621128    /* JUMP RELATIVE comp */ 
     
    11671133    coutf("  %sDEBUG_COMP(\"%s\")", ID_PRE, comp->name); 
    11681134    /* Debugging (entry into component). */ 
     1135    coutf("  %sDEBUG_STATE(", ID_PRE); 
     1136    for(i = 0; i < NUM_STATE_PARS; i++) 
     1137      if (i < NUM_STATE_PARS-1) coutf("    %snl%s,", ID_PRE, statepars_all[i]); 
     1138      else                      coutf("    %snl%s)", ID_PRE, statepars_all[i]); 
     1139     
     1140    for(i = 0; i < NUM_STATE_PARS; i++)   
     1141      coutf("#define %s %snl%s", statepars_all[i], ID_PRE, statepars_all[i]); 
     1142       
    11691143#if MCCODE_PROJECT == 1     /* neutron */ 
    1170     coutf("  %sDEBUG_STATE(%snlx, %snly, %snlz, %snlvx, %snlvy, %snlvz," 
    1171           "%snlt, %snlsx,%snlsy,%snlsz, %snlp)", 
    1172           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1173           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
     1144    static char *store  ="STORE_NEUTRON"; 
     1145    static char *restore="RESTORE_NEUTRON"; 
    11741146#elif MCCODE_PROJECT == 2   /* xray */ 
    1175     coutf("  %sDEBUG_STATE(%snlx, %snly, %snlz, %snlkx, %snlky, %snlkz," 
    1176           "%snlphi,%snlt,%snlEx,%snlEy,%snlEz, %snlp)", 
    1177           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1178           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
     1147    static char *store  ="STORE_XRAY"; 
     1148    static char *restore="RESTORE_XRAY"; 
    11791149#endif 
    11801150 
    1181     /* Trace code. */ 
    1182     for(i = 0; i < NUM_STATE_PARS; i++) 
    1183       statepars[i] = NULL; 
    1184     statepars_handle = list_iterate(comp->def->state_par); 
    1185     for(i = 0; i < NUM_STATE_PARS; i++) 
    1186     { 
    1187       statepars[i] = list_next(statepars_handle); 
    1188       if(statepars[i] == NULL) 
    1189         break; 
    1190     } 
    1191     list_iterate_end(statepars_handle); 
    1192     for(i = 0; i < NUM_STATE_PARS; i++) 
    1193     { 
    1194       if(statepars[i] != NULL) 
    1195         coutf("#define %s %s%s", statepars[i], ID_PRE, statepars_names[i]); 
    1196       else 
    1197         break; 
    1198     } 
    11991151    /* store @MCCODE_PARTICULE@ state in mccomp_storein */ 
    1200     if (!comp->split) 
    1201 #if MCCODE_PROJECT == 1     /* neutron */ 
    1202     coutf("  STORE_NEUTRON(%i,%snlx, %snly, %snlz, %snlvx," 
    1203           "%snlvy,%snlvz,%snlt,%snlsx,%snlsy, %snlsz, %snlp);", 
    1204           comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1205           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
    1206 #elif MCCODE_PROJECT == 2   /* xray */ 
    1207     coutf("  STORE_XRAY(%i,%snlx, %snly, %snlz, %snlkx," 
    1208          "%snlky,%snlkz,%snlphi,%snlt, %snlEx,%snlEy, %snlEz, %snlp);", 
    1209           comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1210           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
    1211 #endif 
    1212  
    1213     else { 
     1152    if (!comp->split) { 
     1153      coutf("  %s(%i,", store, comp->index); /* STORE */ 
     1154      for(i = 0; i < NUM_STATE_PARS; i++) 
     1155        if (i < NUM_STATE_PARS-1) coutf("    %snl%s,", ID_PRE, statepars_all[i]); 
     1156        else                      coutf("    %snl%s);",ID_PRE, statepars_all[i]); 
     1157    } else { 
    12141158      /* spliting: store first time, then restore @MCCODE_PARTICULE@ */ 
    12151159      char *exp=exp_tostring(comp->split); /* number of splits */ 
    12161160      coutf("  if (!%sSplit_%s) {                   /* STORE only the first time */", ID_PRE, comp->name); 
    12171161      coutf("    if (floor(%s) > 1) p /= floor(%s); /* adapt weight for SPLITed @MCCODE_PARTICULE@ */", exp, exp); 
    1218 #if MCCODE_PROJECT == 1     /* neutron */ 
    1219       coutf("    STORE_NEUTRON(%i,%snlx, %snly, %snlz, %snlvx," 
    1220           "%snlvy,%snlvz,%snlt,%snlsx,%snlsy, %snlsz, %snlp);", 
    1221           comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1222           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
     1162      coutf("    %s(%i,", store, comp->index); /* STORE */ 
     1163      for(i = 0; i < NUM_STATE_PARS; i++) 
     1164        if (i < NUM_STATE_PARS-1) coutf("      %snl%s,", ID_PRE, statepars_all[i]); 
     1165        else                      coutf("      %snl%s);",ID_PRE, statepars_all[i]); 
    12231166      coutf("  } else {"); 
    1224       coutf("    RESTORE_NEUTRON(%i,%snlx, %snly, %snlz, %snlvx," 
    1225           "%snlvy,%snlvz,%snlt,%snlsx,%snlsy, %snlsz, %snlp); }", 
    1226           comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1227           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
    1228 #elif MCCODE_PROJECT == 2   /* xray */ 
    1229       coutf("    STORE_XRAY(%i,%snlx, %snly, %snlz, %snlkx," 
    1230           "%snlky,%snlkz,%snlphi,%snlt, %snlEx,%snlEy, %snlEz, %snlp);", 
    1231           comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1232           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
    1233       coutf("  } else {"); 
    1234       coutf("    RESTORE_XRAY(%i,%snlx, %snly, %snlz, %snlkx," 
    1235           "%snlky,%snlkz,%snlphi,%snlt, %snlEx,%snlEy, %snlEz, %snlp); }", 
    1236           comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1237           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
    1238 #endif 
     1167      coutf("    %s(%i,", restore, comp->index); /* RESTORE */ 
     1168      for(i = 0; i < NUM_STATE_PARS; i++) 
     1169        if (i < NUM_STATE_PARS-1) coutf("      %snl%s,", ID_PRE, statepars_all[i]); 
     1170        else                      coutf("      %snl%s);",ID_PRE, statepars_all[i]); 
     1171      cout ("  }"); 
    12391172      coutf("  %sSplit_%s++; /* SPLIT number */", ID_PRE, comp->name); 
    12401173      str_free(exp); 
     
    12721205        /* not the last comp of GROUP: check if SCATTERED */ 
    12731206        coutf("  if (!%sGroup%s) /* restore @MCCODE_PARTICULE@ if was not scattered in GROUP yet */", ID_PRE, comp->group->name); 
    1274 #if MCCODE_PROJECT == 1     /* neutron */ 
    1275         coutf("    { RESTORE_NEUTRON(%i,%snlx, %snly, %snlz, %snlvx," 
    1276               "%snlvy,%snlvz,%snlt,%snlsx,%snlsy, %snlsz, %snlp); }", 
    1277           comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1278           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
    1279 #elif MCCODE_PROJECT == 2   /* xray */ 
    1280         coutf("    { RESTORE_XRAY(%i,%snlx, %snly, %snlz, %snlkx," 
    1281               "%snlky,%snlkz,%snlphi,%snlt, %snlEx,%snlEy, %snlEz, %snlp); }", 
    1282           comp->index, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1283           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
    1284 #endif 
     1207        coutf("  { %s(%i,", restore, comp->index); /* RESTORE */ 
     1208        for(i = 0; i < NUM_STATE_PARS; i++) 
     1209          if (i < NUM_STATE_PARS-1) coutf("      %snl%s,", ID_PRE, statepars_all[i]); 
     1210          else                      coutf("      %snl%s);",ID_PRE, statepars_all[i]); 
    12851211      } else { 
    12861212        /* last comp of GROUP: restore default ABSORB */ 
     
    12911217 
    12921218    for(i = NUM_STATE_PARS-1; i >= 0; i--) 
    1293     { 
    1294       if(statepars[i] != NULL) 
    1295         coutf("#undef %s", statepars[i]); 
    1296     } 
     1219      coutf("#undef %s", statepars_all[i]); 
    12971220    /* Debugging (exit from component). */ 
    1298 #if MCCODE_PROJECT == 1     /* neutron */ 
    1299     coutf("  %sDEBUG_STATE(%snlx, %snly, %snlz, %snlvx, %snlvy, %snlvz," 
    1300           "%snlt, %snlsx,%snlsy,%snlsz, %snlp)", 
    1301           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1302           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
    1303 #elif MCCODE_PROJECT == 2   /* xray */ 
    1304     coutf("  %sDEBUG_STATE(%snlx, %snly, %snlz, %snlkx, %snlky, %snlkz," 
    1305           "%snlphi,%snlt, %snlEx,%snlEy,%snlEz, %snlp)", 
    1306           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1307           ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
    1308 #endif 
     1221    coutf("  %sDEBUG_STATE(", ID_PRE); 
     1222    for(i = 0; i < NUM_STATE_PARS; i++) 
     1223      if (i < NUM_STATE_PARS-1) coutf("%snl%s,", ID_PRE, statepars_all[i]); 
     1224      else                      coutf("%snl%s)", ID_PRE, statepars_all[i]); 
    13091225    cout(""); 
    13101226  } /* while comp */ 
     
    13461262  /* Debugging (final state). */ 
    13471263  coutf("  %sDEBUG_LEAVE()", ID_PRE); 
    1348 #if MCCODE_PROJECT == 1     /* neutron */ 
    1349   coutf("  %sDEBUG_STATE(%snlx, %snly, %snlz, %snlvx, %snlvy, %snlvz," 
    1350         "%snlt, %snlsx,%snlsy,%snlsz, %snlp)", 
    1351         ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1352         ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
    1353 #elif MCCODE_PROJECT == 2   /* xray */ 
    1354   coutf("  %sDEBUG_STATE(%snlx, %snly, %snlz, %snlkx, %snlky, %snlkz," 
    1355         "%snlphi,%snlt, %snlEx,%snlEy,%snlEz, %snlp)", 
    1356         ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, 
    1357         ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE, ID_PRE); 
    1358 #endif 
     1264  coutf("  %sDEBUG_STATE(", ID_PRE); 
     1265  for(i = 0; i < NUM_STATE_PARS; i++) 
     1266    if (i < NUM_STATE_PARS-1) coutf("%snl%s,", ID_PRE, statepars_all[i]); 
     1267    else                      coutf("%snl%s)", ID_PRE, statepars_all[i]); 
    13591268 
    13601269  /* Copy back @MCCODE_PARTICULE@ state to global variables. */ 
     
    13621271     component - should be transformed back into the global system. */ 
    13631272  cout("  /* Copy @MCCODE_PARTICULE@ state to global variables. */"); 
    1364   coutf("  %snx = %snlx;", ID_PRE, ID_PRE); 
    1365   coutf("  %sny = %snly;", ID_PRE, ID_PRE); 
    1366   coutf("  %snz = %snlz;", ID_PRE, ID_PRE); 
    1367 #if MCCODE_PROJECT == 1     /* neutron */ 
    1368   coutf("  %snvx = %snlvx;", ID_PRE, ID_PRE); 
    1369   coutf("  %snvy = %snlvy;", ID_PRE, ID_PRE); 
    1370   coutf("  %snvz = %snlvz;", ID_PRE, ID_PRE); 
    1371   coutf("  %snt = %snlt;", ID_PRE, ID_PRE); 
    1372   coutf("  %snsx = %snlsx;", ID_PRE, ID_PRE); 
    1373   coutf("  %snsy = %snlsy;", ID_PRE, ID_PRE); 
    1374   coutf("  %snsz = %snlsz;", ID_PRE, ID_PRE); 
    1375 #elif MCCODE_PROJECT == 2   /* xray */ 
    1376   coutf("  %snkx = %snlkx;", ID_PRE, ID_PRE); 
    1377   coutf("  %snky = %snlky;", ID_PRE, ID_PRE); 
    1378   coutf("  %snkz = %snlkz;", ID_PRE, ID_PRE); 
    1379   coutf("  %snphi = %snlphi;", ID_PRE, ID_PRE); 
    1380   coutf("  %snt = %snlt;", ID_PRE, ID_PRE); 
    1381   coutf("  %snEx = %snlEx;", ID_PRE, ID_PRE); 
    1382   coutf("  %snEy = %snlEy;", ID_PRE, ID_PRE); 
    1383   coutf("  %snEz = %snlEz;", ID_PRE, ID_PRE); 
    1384 #endif 
    1385   coutf("  %snp = %snlp;", ID_PRE, ID_PRE); 
     1273  for(i = 0; i < NUM_STATE_PARS; i++) 
     1274    coutf("  %sn%s = %snl%s;", ID_PRE, statepars_all[i], ID_PRE, statepars_all[i]); 
     1275  cout(""); 
    13861276 
    13871277  /* Function end. */ 
     
    16881578  cogen_finally(instr); 
    16891579  cogen_mcdisplay(instr); 
     1580  coutf("/* end of generated C code %s */", output_name); 
    16901581} /* cogen */ 
  • branches/mcxtrace-1.0/src/instrument.l

    r2771 r3252  
    122122PREVIOUS      return TOK_PREVIOUS; 
    123123SETTING       return TOK_SETTING; 
    124 STATE         return TOK_STATE; 
    125124TRACE         return TOK_TRACE; 
    126125SHARE         return TOK_SHARE; 
  • branches/mcxtrace-1.0/src/instrument.y

    r3120 r3252  
    11/******************************************************************************* 
    22* 
    3 * McStas, neutron ray-tracing package 
     3* McStas/McXtrace, neutron ray-tracing package 
    44*         Copyright (C) 1997-2007, All rights reserved 
    55*         Risoe National Laboratory, Roskilde, Denmark 
     
    5555  struct comp_iformal *cformal; /* Single formal component input parameter */ 
    5656  Symtab actuals;   /* Values for formal parameters */ 
    57   struct {List def, set, out, state; } parms;  /* Parameter lists */ 
     57  struct {List def, set, out; } parms;  /* Parameter lists */ 
    5858  struct instr_def *instrument; /* Instrument definition */ 
    5959  struct comp_inst *instance; /* Component instance */ 
     
    8787%token TOK_PREVIOUS   "PREVIOUS" 
    8888%token TOK_SETTING    "SETTING" 
    89 %token TOK_STATE      "STATE" 
    9089%token TOK_TRACE      "TRACE" 
    9190%token TOK_SHARE      "SHARE" 
    9291%token TOK_EXTEND     "EXTEND" 
    93 %token TOK_GROUP      "GROUP"   /* extended McStas grammar */ 
     92%token TOK_GROUP      "GROUP"   /* extended McCode grammar */ 
    9493%token TOK_SAVE       "SAVE" 
    9594%token TOK_NEXUS      "NEXUS"   /* optional */ 
    96 %token TOK_JUMP       "JUMP"    /* extended McStas grammar */ 
    97 %token TOK_WHEN       "WHEN"    /* extended McStas grammar */ 
    98 %token TOK_NEXT       "NEXT"    /* extended McStas grammar */ 
    99 %token TOK_ITERATE    "ITERATE" /* extended McStas grammar */ 
    100 %token TOK_MYSELF     "MYSELF"  /* extended McStas grammar */ 
    101 %token TOK_COPY       "COPY"    /* extended McStas grammar */ 
    102 %token TOK_SPLIT      "SPLIT"   /* extended McStas grammar */ 
    103 %token TOK_REMOVABLE  "REMOVABLE" /* extended McStas grammar with include */ 
     95%token TOK_JUMP       "JUMP"    /* extended McCode grammar */ 
     96%token TOK_WHEN       "WHEN"    /* extended McCode grammar */ 
     97%token TOK_NEXT       "NEXT"    /* extended McCode grammar */ 
     98%token TOK_ITERATE    "ITERATE" /* extended McCode grammar */ 
     99%token TOK_MYSELF     "MYSELF"  /* extended McCode grammar */ 
     100%token TOK_COPY       "COPY"    /* extended McCode grammar */ 
     101%token TOK_SPLIT      "SPLIT"   /* extended McCode grammar */ 
     102%token TOK_REMOVABLE  "REMOVABLE" /* extended McCode grammar with include */ 
    104103 
    105104/******************************************************************************* 
     
    124123%type <comp_iformals> comp_iformallist comp_iformals comp_iformals1 
    125124%type <cformal> comp_iformal 
    126 %type <formals> formallist formals formals1 def_par set_par out_par state_par 
     125%type <formals> formallist formals formals1 def_par set_par out_par 
    127126%type <iformals> instrpar_list instr_formals instr_formals1 
    128127%type <iformal> instr_formal 
     
    159158        c->set_par = $4.set; 
    160159        c->out_par = $4.out; 
    161         c->state_par = $4.state; 
    162160        c->share_code = $5; 
    163161        c->decl_code = $6; 
     
    173171        /* Put component definition in table. */ 
    174172        symtab_add(read_components, c->name, c); 
    175         /* checks */ 
    176         if (!list_len(c->state_par)) print_error("No particule state parameters defined in component " 
    177           "%s at line %s:%d.\n", $3, instr_current_filename, instr_current_line); 
    178173        if (verbose) fprintf(stderr, "Embedding component %s from file %s\n", c->name, c->source); 
    179174      } 
     
    198193        if (list_len($6.out)) list_cat(c->out_par,$6.out); 
    199194 
    200         c->state_par = (list_len($6.state) ? $6.state : def->state_par); /* includes polarisation par */ 
    201  
    202195        c->share_code = ($7->linenum ?  $7  : def->share_code); 
    203196        c->decl_code  = ($8->linenum ?  $8  : def->decl_code); 
     
    213206        /* Put component definition in table. */ 
    214207        symtab_add(read_components, c->name, c); 
    215         /* checks */ 
    216         if (!list_len(c->state_par)) print_error("No particule state parameters defined in (copied) component " 
    217           "%s at line %s:%d.\n", $3, instr_current_filename, instr_current_line); 
    218208        if (verbose) fprintf(stderr, "Embedding component %s from file %s\n", c->name, c->source); 
    219209 
     
    281271; 
    282272 
    283 parameters:   def_par set_par out_par state_par 
     273parameters:   def_par set_par out_par 
    284274      { 
    285275        $$.def = $1; 
    286276        $$.set = $2; 
    287277        $$.out = $3; 
    288         $$.state = $4; 
    289278      } 
    290279; 
     
    316305      } 
    317306    | "OUTPUT" "PARAMETERS" formallist 
    318       { 
    319         $$ = $3; 
    320       } 
    321 ; 
    322  
    323 state_par:    /* empty */ 
    324       { 
    325         $$ = list_create(); 
    326       } 
    327     | "STATE" "PARAMETERS" formallist 
    328307      { 
    329308        $$ = $3; 
     
    14831462  fprintf(stderr, "      -I DIR  --search-dir=DIR   Append DIR to the component search list. \n"); 
    14841463  fprintf(stderr, "      -t      --trace            Enable 'trace' mode for instrument display.\n"); 
    1485   fprintf(stderr, "      -v      --version          Prints McStas version.\n"); 
     1464  fprintf(stderr, "      -v      --version          Prints " MCCODE_NAME " version.\n"); 
    14861465  fprintf(stderr, "      --no-main                  Do not create main(), for external embedding.\n"); 
    14871466  fprintf(stderr, "      --no-runtime               Do not embed run-time libraries.\n"); 
     
    14921471  fprintf(stderr, "  The default component search list is usually defined by the environment\n"); 
    14931472  fprintf(stderr, "    variable 'MCSTAS' (default is " MCSTAS ") \n"); 
    1494   fprintf(stderr, "  Use 'mcrun' to both run mcstas and the C compiler.\n"); 
    1495   fprintf(stderr, "  Use 'mcgui' to run the McStas GUI.\n");   
     1473  fprintf(stderr, "  Use 'mcrun' to both run " MCCODE_NAME " and the C compiler.\n"); 
     1474  fprintf(stderr, "  Use 'mcgui' to run the " MCCODE_NAME " GUI.\n");   
    14961475  fprintf(stderr, "SEE ALSO: mcrun, mcplot, mcdisplay, mcresplot, mcstas2vitess, mcgui, mcformat, mcdoc\n"); 
    14971476  fprintf(stderr, "DOC:      Please visit " MCCODE_BUGREPORT "\n"); 
     
    14991478} 
    15001479 
    1501 /* Print McStas version and copyright. */ 
     1480/* Print McCode version and copyright. */ 
    15021481static void 
    15031482print_version(void) 
  • branches/mcxtrace-1.0/src/mccode.h.in

    r2770 r3252  
    392392    char *source;                   /*  Name of source file for definition */ 
    393393    int  comp_inst_number;          /* Number of this comp in the instrument  */ 
    394     List def_par, set_par, out_par, state_par; /* Formal parameters. */ 
     394    List def_par, set_par, out_par; /* Formal parameters. */ 
    395395    struct code_block *share_code;  /* Unique Declaration code (shared). */ 
    396396    struct code_block *decl_code;   /* Declaration code. */