Annotation of rpl/src/analyse.c, revision 1.55

1.1       bertrand    1: /*
                      2: ================================================================================
1.52      bertrand    3:   RPL/2 (R) version 4.1.3
1.35      bertrand    4:   Copyright (C) 1989-2011 Dr. BERTRAND Joël
1.1       bertrand    5: 
                      6:   This file is part of RPL/2.
                      7: 
                      8:   RPL/2 is free software; you can redistribute it and/or modify it
                      9:   under the terms of the CeCILL V2 License as published by the french
                     10:   CEA, CNRS and INRIA.
                     11:  
                     12:   RPL/2 is distributed in the hope that it will be useful, but WITHOUT
                     13:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
                     14:   FITNESS FOR A PARTICULAR PURPOSE.  See the CeCILL V2 License
                     15:   for more details.
                     16:  
                     17:   You should have received a copy of the CeCILL License
                     18:   along with RPL/2. If not, write to info@cecill.info.
                     19: ================================================================================
                     20: */
                     21: 
                     22: 
1.25      bertrand   23: #include "rpl-conv.h"
1.1       bertrand   24: 
                     25: 
                     26: /*
                     27: ================================================================================
1.3       bertrand   28:   Analyseur syntaxique de l'interprète RPL/2
1.1       bertrand   29: ================================================================================
                     30:   Entrées :
                     31: --------------------------------------------------------------------------------
                     32:   Sorties :
                     33: --------------------------------------------------------------------------------
                     34:   Effets de bord : néant
                     35: ================================================================================
                     36: */
                     37: 
                     38: static void
                     39: creation_instruction(struct_processus *s_etat_processus,
                     40:        unsigned char *instruction, void (*routine)())
                     41: {
                     42:    int                     i;
                     43: 
                     44:    struct_instruction      *l_instruction_courante;
                     45: 
                     46:    unsigned char           *ptr;
                     47: 
1.14      bertrand   48:    BUG(strlen(instruction) >= d_longueur_maximale_instruction,
                     49:            printf("%s -> %d >= %d\n", instruction, (int) strlen(instruction),
                     50:            d_longueur_maximale_instruction));
                     51: 
1.1       bertrand   52:    if ((*s_etat_processus).arbre_instructions == NULL)
                     53:    {
                     54:        if (((*s_etat_processus).arbre_instructions =
                     55:                malloc(sizeof(struct_instruction))) == NULL)
                     56:        {
                     57:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                     58:            return;
                     59:        }
                     60: 
                     61:        (*(*s_etat_processus).arbre_instructions).feuille = NULL;
                     62: 
1.41      bertrand   63:        if (((*(*s_etat_processus).arbre_instructions).noeuds =
1.1       bertrand   64:                malloc((*s_etat_processus).nombre_caracteres
                     65:                * sizeof(struct_instruction))) == NULL)
                     66:        {
                     67:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                     68:            return;
                     69:        }
                     70: 
                     71:        for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++)
                     72:        {
1.41      bertrand   73:            (*(*s_etat_processus).arbre_instructions).noeuds[i] = NULL;
1.1       bertrand   74:        }
                     75:    }
                     76: 
                     77:    l_instruction_courante = (*s_etat_processus).arbre_instructions;
                     78:    ptr = instruction;
                     79: 
                     80:    while((*ptr) != d_code_fin_chaine)
                     81:    {
                     82:        BUG((*s_etat_processus).pointeurs_caracteres[*ptr] < 0,
                     83:                printf("Instruction=\"%s\", (*ptr)='%c'\n",
                     84:                instruction, *ptr));
                     85: 
1.41      bertrand   86:        if ((*l_instruction_courante).noeuds[(*s_etat_processus)
1.1       bertrand   87:                .pointeurs_caracteres[*ptr]] == NULL)
                     88:        {
                     89:            // Le noeud suivant n'existe pas, on le crée.
                     90: 
1.41      bertrand   91:            if (((*l_instruction_courante).noeuds[(*s_etat_processus)
1.1       bertrand   92:                    .pointeurs_caracteres[*ptr]] =
                     93:                    malloc(sizeof(struct_instruction))) == NULL)
                     94:            {
                     95:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                     96:                return;
                     97:            }
                     98: 
1.41      bertrand   99:            (*(*l_instruction_courante).noeuds[(*s_etat_processus)
1.1       bertrand  100:                    .pointeurs_caracteres[*ptr]]).feuille = NULL;
                    101: 
1.41      bertrand  102:            if (((*(*l_instruction_courante).noeuds[(*s_etat_processus)
                    103:                    .pointeurs_caracteres[*ptr]]).noeuds =
1.1       bertrand  104:                    malloc((*s_etat_processus).nombre_caracteres
                    105:                    * sizeof(struct_instruction))) == NULL)
                    106:            {
                    107:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    108:                return;
                    109:            }
                    110: 
                    111:            for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++)
                    112:            {
1.41      bertrand  113:                (*(*l_instruction_courante).noeuds[(*s_etat_processus)
                    114:                        .pointeurs_caracteres[*ptr]]).noeuds[i] = NULL;
1.1       bertrand  115:            }
                    116:        }
                    117: 
1.41      bertrand  118:        l_instruction_courante = (*l_instruction_courante).noeuds
1.1       bertrand  119:                [(*s_etat_processus).pointeurs_caracteres[*ptr]];
                    120:        ptr++;
                    121:    }
                    122: 
                    123:    BUG((*l_instruction_courante).feuille != NULL,
                    124:            printf("Instruction=\"%s\"\n", instruction));
                    125: 
                    126:    (*l_instruction_courante).feuille = routine;
                    127: 
                    128:    return;
                    129: }
                    130: 
                    131: 
                    132: void
                    133: liberation_arbre_instructions(struct_processus *s_etat_processus,
                    134:        struct_instruction *arbre)
                    135: {
                    136:    int                 i;
                    137: 
                    138:    for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++)
                    139:    {
1.41      bertrand  140:        if ((*arbre).noeuds[i] != NULL)
1.1       bertrand  141:        {
1.41      bertrand  142:            liberation_arbre_instructions(s_etat_processus, (*arbre).noeuds[i]);
1.1       bertrand  143:        }
                    144:    }
                    145: 
1.41      bertrand  146:    free((*arbre).noeuds);
1.1       bertrand  147:    free(arbre);
                    148: 
                    149:    return;
                    150: }
                    151: 
                    152: 
                    153: /*
                    154:  * Caractères autorisés dans les instructions
                    155:  *
                    156:  * A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
                    157:  * e i (mais traités comme des majuscules grâce à 'instruction_*_sensible()'
                    158:  * + - * / % ^ < > = ? 1 2
                    159:  */
                    160: 
                    161: void
                    162: initialisation_instructions(struct_processus *s_etat_processus)
                    163: {
                    164:    int             decalage;
                    165:    int             i;
                    166:    int             longueur_tableau;
                    167: 
                    168:    unsigned char   caractere;
                    169: 
                    170:    // Récupération de la longueur d'un unsigned char
                    171: 
                    172:    longueur_tableau = 1;
                    173:    decalage = 0;
                    174:    caractere = 1;
                    175: 
                    176:    while((1L << decalage) == (long) ((unsigned char) (caractere << decalage)))
                    177:    {
                    178:        decalage++;
                    179:        longueur_tableau *= 2;
                    180:    }
                    181: 
                    182:    if (((*s_etat_processus).pointeurs_caracteres =
                    183:            malloc(longueur_tableau * sizeof(int))) == NULL)
                    184:    {
                    185:        (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    186:        return;
                    187:    }
                    188: 
                    189:    for(i = 0; i < longueur_tableau; i++)
                    190:    {
                    191:        (*s_etat_processus).pointeurs_caracteres[i] = -1;
                    192:    }
                    193: 
                    194:    (*s_etat_processus).nombre_caracteres = 0;
                    195: 
                    196: #define DECLARATION_CARACTERE(c) \
                    197:        do { (*s_etat_processus).pointeurs_caracteres[c] = \
                    198:        (*s_etat_processus).nombre_caracteres++; } while(0)
                    199: 
                    200:    DECLARATION_CARACTERE('A');
                    201:    DECLARATION_CARACTERE('B');
                    202:    DECLARATION_CARACTERE('C');
                    203:    DECLARATION_CARACTERE('D');
                    204:    DECLARATION_CARACTERE('E');
                    205:    DECLARATION_CARACTERE('F');
                    206:    DECLARATION_CARACTERE('G');
                    207:    DECLARATION_CARACTERE('H');
                    208:    DECLARATION_CARACTERE('I');
                    209:    DECLARATION_CARACTERE('J');
                    210:    DECLARATION_CARACTERE('K');
                    211:    DECLARATION_CARACTERE('L');
                    212:    DECLARATION_CARACTERE('M');
                    213:    DECLARATION_CARACTERE('N');
                    214:    DECLARATION_CARACTERE('O');
                    215:    DECLARATION_CARACTERE('P');
                    216:    DECLARATION_CARACTERE('Q');
                    217:    DECLARATION_CARACTERE('R');
                    218:    DECLARATION_CARACTERE('S');
                    219:    DECLARATION_CARACTERE('T');
                    220:    DECLARATION_CARACTERE('U');
                    221:    DECLARATION_CARACTERE('V');
                    222:    DECLARATION_CARACTERE('W');
                    223:    DECLARATION_CARACTERE('X');
                    224:    DECLARATION_CARACTERE('Y');
                    225:    DECLARATION_CARACTERE('Z');
                    226:    DECLARATION_CARACTERE('+');
                    227:    DECLARATION_CARACTERE('-');
                    228:    DECLARATION_CARACTERE('/');
                    229:    DECLARATION_CARACTERE('*');
                    230:    DECLARATION_CARACTERE('%');
                    231:    DECLARATION_CARACTERE('^');
                    232:    DECLARATION_CARACTERE('<');
                    233:    DECLARATION_CARACTERE('>');
                    234:    DECLARATION_CARACTERE('=');
                    235:    DECLARATION_CARACTERE('?');
                    236:    DECLARATION_CARACTERE('1');
                    237:    DECLARATION_CARACTERE('2');
                    238: 
                    239: #undef DECLARATION_CARACTERE
                    240: 
                    241: #define INSTRUCTION(chaine, fonction) \
                    242:        creation_instruction(s_etat_processus, chaine, fonction)
                    243: 
                    244:    INSTRUCTION("E", instruction_sensible_e);
                    245:    INSTRUCTION("I", instruction_sensible_i);
                    246:    INSTRUCTION("+", instruction_plus);
                    247:    INSTRUCTION("-", instruction_moins);
                    248:    INSTRUCTION("*", instruction_multiplication);
                    249:    INSTRUCTION("/", instruction_division);
                    250:    INSTRUCTION("%", instruction_pourcent);
                    251:    INSTRUCTION("^", instruction_puissance);
                    252:    INSTRUCTION("<", instruction_lt);
                    253:    INSTRUCTION("=", instruction_egalite);
                    254:    INSTRUCTION(">", instruction_gt);
                    255: 
                    256:    INSTRUCTION("CF", instruction_cf);
                    257:    INSTRUCTION("CR", instruction_cr);
                    258:    INSTRUCTION("DO", instruction_do);
                    259:    INSTRUCTION("FP", instruction_fp);
                    260:    INSTRUCTION("IF", instruction_if);
                    261:    INSTRUCTION("IM", instruction_im);
                    262:    INSTRUCTION("IN", instruction_in);
                    263:    INSTRUCTION("IP", instruction_ip);
                    264:    INSTRUCTION("LN", instruction_ln);
                    265:    INSTRUCTION("LQ", instruction_lq);
                    266:    INSTRUCTION("LU", instruction_lu);
                    267:    INSTRUCTION("NS", instruction_ns);
                    268:    INSTRUCTION("OR", instruction_or);
                    269:    INSTRUCTION("PI", instruction_pi);
                    270:    INSTRUCTION("QR", instruction_qr);
                    271:    INSTRUCTION("RE", instruction_re);
                    272:    INSTRUCTION("RL", instruction_rl);
                    273:    INSTRUCTION("RR", instruction_rr);
                    274:    INSTRUCTION("SF", instruction_sf);
                    275:    INSTRUCTION("SL", instruction_sl);
                    276:    INSTRUCTION("SQ", instruction_sq);
                    277:    INSTRUCTION("SR", instruction_sr);
                    278:    INSTRUCTION("SX", instruction_sx);
                    279:    INSTRUCTION("SY", instruction_sy);
                    280:    INSTRUCTION("S+", instruction_s_plus);
                    281:    INSTRUCTION("S-", instruction_s_moins);
                    282:    INSTRUCTION("->", instruction_fleche);
                    283:    INSTRUCTION("*D", instruction_star_d);
                    284:    INSTRUCTION("*H", instruction_star_h);
                    285:    INSTRUCTION("*S", instruction_star_s);
                    286:    INSTRUCTION("*W", instruction_star_w);
                    287:    INSTRUCTION("**", instruction_puissance);
                    288:    INSTRUCTION("%T", instruction_pourcent_t);
                    289:    INSTRUCTION("<=", instruction_le);
                    290:    INSTRUCTION("<<", instruction_vers_niveau_superieur);
                    291:    INSTRUCTION("<>", instruction_ne);
                    292:    INSTRUCTION("==", instruction_same);
                    293:    INSTRUCTION("=>", instruction_ge);
                    294:    INSTRUCTION("=<", instruction_le);
                    295:    INSTRUCTION(">=", instruction_ge);
                    296:    INSTRUCTION(">>", instruction_vers_niveau_inferieur);
                    297: 
                    298:    INSTRUCTION("ABS", instruction_abs);
                    299:    INSTRUCTION("AND", instruction_and);
                    300:    //INSTRUCTION("ARC")
                    301:    //(centre, rayon, theta1, theta2 dans le sens trigonométrique)
                    302:    INSTRUCTION("ARG", instruction_arg);
                    303:    INSTRUCTION("ASL", instruction_asl);
                    304:    INSTRUCTION("ASR", instruction_asr);
                    305:    //INSTRUCTION("BAR")
                    306:    //Instruction HP48 (sélectionne le type de graphique à barres)
                    307:    //Chaque point est représenté par une barre verticale.
                    308:    INSTRUCTION("BIN", instruction_bin);
                    309:    //INSTRUCTION("BOX")
                    310:    //(point 1, point 2)
                    311:    INSTRUCTION("CHR", instruction_chr);
                    312:    INSTRUCTION("CLS", instruction_cls);
                    313:    INSTRUCTION("CON", instruction_con);
                    314:    INSTRUCTION("COS", instruction_cos);
                    315:    INSTRUCTION("COV", instruction_cov);
                    316:    INSTRUCTION("DEC", instruction_dec);
                    317:    INSTRUCTION("DEG", instruction_deg);
                    318:    INSTRUCTION("DER", instruction_der);
                    319:    INSTRUCTION("DET", instruction_det);
                    320:    INSTRUCTION("DFT", instruction_dft);
                    321:    INSTRUCTION("DOT", instruction_dot);
                    322:    INSTRUCTION("DUP", instruction_dup);
                    323:    INSTRUCTION("EGV", instruction_egv);
                    324:    INSTRUCTION("END", instruction_end);
                    325:    INSTRUCTION("ENG", instruction_eng);
                    326:    INSTRUCTION("EXP", instruction_exp);
                    327:    INSTRUCTION("FC?", instruction_fc_test);
                    328:    INSTRUCTION("FFT", instruction_fft);
                    329:    //INSTRUCTION("FIT")
                    330:    //Extension RPL/2 (choix de la méthode de régression, par défaut, 'LINEAR'.
                    331:    //Les types sont
                    332:    //'LINEAR' => y = b + mx
                    333:    //'LOGARITHMIC' => y = b + m ln(x)
                    334:    //'EXPONENTIAL' => y = be^(mx) ou ln(y) = ln(b) + mx
                    335:    //'POWER' => y = bx^m ou ln(y) = ln(b) + m ln(x)
                    336:    INSTRUCTION("FIX", instruction_fix);
                    337:    INSTRUCTION("FOR", instruction_for);
                    338:    INSTRUCTION("FS?", instruction_fs_test);
                    339:    INSTRUCTION("GET", instruction_get);
                    340:    INSTRUCTION("HEX", instruction_hex);
                    341:    INSTRUCTION("IDN", instruction_idn);
                    342:    INSTRUCTION("IFT", instruction_ift);
                    343:    INSTRUCTION("INT", instruction_int);
                    344:    INSTRUCTION("INV", instruction_inv);
                    345:    INSTRUCTION("KEY", instruction_key);
                    346:    INSTRUCTION("LOG", instruction_log);
                    347:    INSTRUCTION("LSQ", instruction_lsq);
                    348:    INSTRUCTION("MAX", instruction_max);
                    349:    INSTRUCTION("MEM", instruction_mem);
                    350:    INSTRUCTION("MIN", instruction_min);
                    351:    INSTRUCTION("MOD", instruction_mod);
                    352:    INSTRUCTION("NEG", instruction_neg);
                    353:    INSTRUCTION("NOT", instruction_not);
                    354:    INSTRUCTION("NUM", instruction_num);
                    355:    INSTRUCTION("OCT", instruction_oct);
                    356:    INSTRUCTION("POS", instruction_pos);
                    357:    INSTRUCTION("PR1", instruction_pr1);
                    358:    INSTRUCTION("PUT", instruction_put);
                    359:    INSTRUCTION("RAD", instruction_rad);
                    360:    INSTRUCTION("RCI", instruction_rci);
                    361:    INSTRUCTION("RCL", instruction_rcl);
                    362:    INSTRUCTION("RDM", instruction_rdm);
                    363:    INSTRUCTION("RDZ", instruction_rdz);
                    364:    INSTRUCTION("RES", instruction_res);
                    365:    INSTRUCTION("RLB", instruction_rlb);
                    366:    INSTRUCTION("RND", instruction_rnd);
                    367:    INSTRUCTION("ROT", instruction_rot);
                    368:    INSTRUCTION("RRB", instruction_rrb);
                    369:    INSTRUCTION("RSD", instruction_rsd);
                    370:    INSTRUCTION("SCI", instruction_sci);
                    371:    INSTRUCTION("SIN", instruction_sin);
                    372:    INSTRUCTION("SLB", instruction_slb);
                    373:    INSTRUCTION("SRB", instruction_srb);
                    374:    INSTRUCTION("SST", instruction_sst);
                    375:    INSTRUCTION("STD", instruction_std);
                    376:    INSTRUCTION("STO", instruction_sto);
                    377:    INSTRUCTION("SVD", instruction_svd);
                    378:    INSTRUCTION("SVL", instruction_svl);
                    379:    INSTRUCTION("SUB", instruction_sub);
                    380:    INSTRUCTION("SWI", instruction_swi);
                    381:    INSTRUCTION("SX2", instruction_sx2);
                    382:    INSTRUCTION("SXY", instruction_sxy);
                    383:    INSTRUCTION("SY2", instruction_sy2);
                    384:    INSTRUCTION("TAN", instruction_tan);
                    385:    INSTRUCTION("TOT", instruction_tot);
                    386:    INSTRUCTION("TRN", instruction_trn);
                    387:    INSTRUCTION("USE", instruction_use);
                    388:    INSTRUCTION("VAR", instruction_var);
                    389:    //INSTRUCTION("V->")
                    390:    //Instruction HP48 (éclate un vecteur [ x y ] => x y quel que soit le
                    391:    //système de
                    392:    //coordonnées)
                    393:    INSTRUCTION("XOR", instruction_xor);
                    394:    INSTRUCTION("->Q", instruction_fleche_q);
                    395:    INSTRUCTION("%CH", instruction_pourcent_ch);
                    396: 
                    397:    INSTRUCTION("ACOS", instruction_acos);
                    398:    INSTRUCTION("ALOG", instruction_alog);
                    399:    INSTRUCTION("ASIN", instruction_asin);
                    400:    INSTRUCTION("ATAN", instruction_atan);
                    401:    INSTRUCTION("AXES", instruction_axes);
                    402:    INSTRUCTION("BEEP", instruction_beep);
                    403:    INSTRUCTION("B->R", instruction_b_vers_r);
                    404:    INSTRUCTION("CASE", instruction_case);
                    405:    INSTRUCTION("CEIL", instruction_ceil);
                    406:    INSTRUCTION("CLMF", instruction_clmf);
                    407:    INSTRUCTION("CNRM", instruction_cnrm);
                    408:    INSTRUCTION("COLS", instruction_cols);
                    409:    INSTRUCTION("COL+", instruction_col_plus);
                    410:    INSTRUCTION("COL-", instruction_col_moins);
                    411:    INSTRUCTION("COMB", instruction_comb);
                    412:    INSTRUCTION("COND", instruction_cond);
                    413:    INSTRUCTION("CONJ", instruction_conj);
                    414:    INSTRUCTION("CONT", instruction_cont);
                    415:    INSTRUCTION("COPY", instruction_copy);
                    416:    INSTRUCTION("CORR", instruction_corr);
                    417:    INSTRUCTION("COSH", instruction_cosh);
                    418:    INSTRUCTION("CSWP", instruction_cswp);
                    419:    INSTRUCTION("C->R", instruction_c_vers_r);
                    420:    INSTRUCTION("DATE", instruction_date);
                    421:    INSTRUCTION("DECR", instruction_decr);
                    422:    INSTRUCTION("DISP", instruction_disp);
                    423:    INSTRUCTION("DRAW", instruction_draw);
                    424:    INSTRUCTION("DRAX", instruction_drax);
                    425:    INSTRUCTION("DROP", instruction_drop);
                    426:    INSTRUCTION("DRWS", instruction_drws);
                    427:    INSTRUCTION("DUP2", instruction_dup2);
                    428:    INSTRUCTION("DUPN", instruction_dupn);
                    429:    INSTRUCTION("D->R", instruction_d_vers_r);
                    430:    INSTRUCTION("EDIT", instruction_edit);
                    431:    INSTRUCTION("EGVL", instruction_egvl);
                    432:    INSTRUCTION("ELSE", instruction_else);
                    433:    INSTRUCTION("ERRM", instruction_errm);
                    434:    INSTRUCTION("ERRN", instruction_errn);
                    435:    INSTRUCTION("EVAL", instruction_eval);
                    436:    INSTRUCTION("EXIT", instruction_exit);
                    437:    INSTRUCTION("EXPM", instruction_expm);
                    438:    INSTRUCTION("FACT", instruction_fact);
                    439:    INSTRUCTION("FC?C", instruction_fc_test_c);
                    440:    INSTRUCTION("FC?S", instruction_fc_test_s);
                    441:    //INSTRUCTION("FORM")
                    442:    INSTRUCTION("FS?C", instruction_fs_test_c);
                    443:    INSTRUCTION("FS?S", instruction_fs_test_s);
                    444:    INSTRUCTION("FUSE", instruction_fuse);
                    445:    INSTRUCTION("GEGV", instruction_gegv);
                    446:    INSTRUCTION("GETC", instruction_getc);
                    447:    INSTRUCTION("GETI", instruction_geti);
                    448:    INSTRUCTION("GETR", instruction_getr);
                    449:    INSTRUCTION("HALT", instruction_halt);
                    450:    INSTRUCTION("HEAD", instruction_head);
                    451:    INSTRUCTION("HELP", instruction_help);
                    452:    INSTRUCTION("HMS+", instruction_hms_plus);
                    453:    INSTRUCTION("HMS-", instruction_hms_moins);
                    454:    //INSTRUCTION("HOME");
                    455:    INSTRUCTION("IDFT", instruction_idft);
                    456:    INSTRUCTION("IFFT", instruction_ifft);
                    457:    INSTRUCTION("IFTE", instruction_ifte);
                    458:    INSTRUCTION("INCR", instruction_incr);
                    459:    //INSTRUCTION("ISOL");
                    460:    INSTRUCTION("ISWI", instruction_iswi);
1.29      bertrand  461: #  ifndef OS2
1.1       bertrand  462:    INSTRUCTION("KILL", instruction_kill);
1.29      bertrand  463: #  endif
1.1       bertrand  464:    INSTRUCTION("KIND", instruction_kind);
                    465:    INSTRUCTION("LAST", instruction_last);
                    466:    INSTRUCTION("LEGV", instruction_legv);
                    467:    INSTRUCTION("LINE", instruction_line);
                    468:    INSTRUCTION("LNP1", instruction_lnp1);
                    469:    INSTRUCTION("LOCK", instruction_lock);
1.36      bertrand  470:    INSTRUCTION("L->T", instruction_l_vers_t);
1.1       bertrand  471:    INSTRUCTION("MANT", instruction_mant);
                    472:    INSTRUCTION("MARK", instruction_mark);
                    473:    //INSTRUCTION("MAXR")
                    474:    INSTRUCTION("MAXS", instruction_maxs);
                    475:    INSTRUCTION("MEAN", instruction_mean);
                    476:    //INSTRUCTION("MINR");
                    477:    INSTRUCTION("MINS", instruction_mins); // MAXDOUBLE/MINDOUBLE
                    478:    INSTRUCTION("NEXT", instruction_next);
                    479:    //INSTRUCTION("NUMX");
                    480:    //INSTRUCTION("NUMY");
                    481:    INSTRUCTION("OPEN", instruction_open);
                    482:    INSTRUCTION("OVER", instruction_over);
                    483:    //INSTRUCTION("PATH");
                    484:    INSTRUCTION("PCOV", instruction_pcov);
                    485:    INSTRUCTION("PEEK", instruction_peek);
                    486:    INSTRUCTION("PERM", instruction_perm);
                    487:    INSTRUCTION("PICK", instruction_pick);
                    488:    INSTRUCTION("PLOT", instruction_plot);
                    489:    INSTRUCTION("PMAX", instruction_pmax);
                    490:    INSTRUCTION("PMIN", instruction_pmin);
1.29      bertrand  491: #  ifndef OS2
1.1       bertrand  492:    INSTRUCTION("POKE", instruction_poke);
1.29      bertrand  493: #  endif
1.1       bertrand  494:    INSTRUCTION("PPAR", instruction_ppar);
                    495:    INSTRUCTION("PRMD", instruction_prmd);
                    496:    INSTRUCTION("PRST", instruction_prst);
                    497:    INSTRUCTION("PUTC", instruction_putc);
                    498:    INSTRUCTION("PUTI", instruction_puti);
                    499:    INSTRUCTION("PUTR", instruction_putr);
                    500:    INSTRUCTION("PVAR", instruction_pvar);
                    501:    INSTRUCTION("P->R", instruction_p_vers_r);
                    502:    //INSTRUCTION("QUAD");
                    503:    INSTRUCTION("RAND", instruction_rand);
                    504:    INSTRUCTION("RANK", instruction_rank);
                    505:    //INSTRUCTION("RANM")
                    506:    //Instruction HP48 (crée une matrice aléatoire
                    507:    //{ nb_lignes nb_colonnes } ou tableau quelconque dont les éléments seront
                    508:    //modifiés pour prendre des valeurs aléatoires entre -9 et 9)
                    509:    INSTRUCTION("RCEQ", instruction_rceq);
                    510:    INSTRUCTION("RCIJ", instruction_rcij);
                    511:    INSTRUCTION("RCLF", instruction_rclf);
                    512:    INSTRUCTION("RCLS", instruction_rcls);
                    513:    INSTRUCTION("RCWS", instruction_rcws);
                    514:    INSTRUCTION("RDGN", instruction_rdgn);
                    515:    INSTRUCTION("READ", instruction_read);
                    516:    INSTRUCTION("RECV", instruction_recv);
                    517:    INSTRUCTION("REGV", instruction_regv);
                    518:    INSTRUCTION("REPL", instruction_repl);
                    519:    INSTRUCTION("RNRM", instruction_rnrm);
                    520:    INSTRUCTION("ROLL", instruction_roll);
                    521:    //INSTRUCTION("ROOT")
                    522:    INSTRUCTION("ROW-", instruction_row_moins);
                    523:    INSTRUCTION("ROW+", instruction_row_plus);
                    524:    //INSTRUCTION("RREF")
                    525:    //Instruction HP48 (transforme [A B] en [I C] par combinaisons linéaires
                    526:    //de lignes)
                    527:    INSTRUCTION("RSWP", instruction_rswp);
                    528:    INSTRUCTION("R->B", instruction_r_vers_b);
                    529:    INSTRUCTION("R->C", instruction_r_vers_c);
                    530:    INSTRUCTION("R->D", instruction_r_vers_d);
                    531:    INSTRUCTION("R->P", instruction_r_vers_p);
                    532:    INSTRUCTION("SAME", instruction_same);
                    533:    INSTRUCTION("SAVE", instruction_save);
                    534:    INSTRUCTION("SCLS", instruction_scls);
                    535:    INSTRUCTION("SDEV", instruction_sdev);
                    536:    INSTRUCTION("SEND", instruction_send);
                    537:    //INSTRUCTION("SHOW");
                    538:    INSTRUCTION("SIGN", instruction_sign);
                    539:    INSTRUCTION("SINH", instruction_sinh);
                    540:    INSTRUCTION("SINV", instruction_sinv);
                    541:    INSTRUCTION("SIZE", instruction_size);
                    542:    INSTRUCTION("SNEG", instruction_sneg);
                    543:    INSTRUCTION("SORT", instruction_sort);
                    544:    INSTRUCTION("SPAR", instruction_spar);
                    545:    INSTRUCTION("SQRT", instruction_sqrt);
                    546:    //INSTRUCTION("SRAD");
1.53      bertrand  547:    INSTRUCTION("SREV", instruction_srev);
1.1       bertrand  548:    //INSTRUCTION("SRNM")
                    549:    //Instruction HP48 (renvoie la norme spectrale d'un tableau. Pour une
                    550:    //matrice,
                    551:    //la norme spectrale est égale à sa plus grande valeur singulière. Pour un
                    552:    //vecteur, la fonction est équivalente à ABS.
                    553:    INSTRUCTION("STEP", instruction_step);
                    554:    INSTRUCTION("STEQ", instruction_steq);
                    555:    INSTRUCTION("STO*", instruction_sto_fois);
                    556:    INSTRUCTION("STO+", instruction_sto_plus);
                    557:    INSTRUCTION("STO-", instruction_sto_moins);
                    558:    INSTRUCTION("STO/", instruction_sto_division);
                    559:    INSTRUCTION("STOF", instruction_stof);
1.29      bertrand  560: #  ifndef OS2
1.1       bertrand  561:    INSTRUCTION("STOP", instruction_stop);
1.29      bertrand  562: #  endif
1.1       bertrand  563:    INSTRUCTION("STOS", instruction_stos);
                    564:    INSTRUCTION("STWS", instruction_stws);
                    565:    INSTRUCTION("SWAP", instruction_swap);
                    566:    INSTRUCTION("SYNC", instruction_sync);
                    567:    INSTRUCTION("TAIL", instruction_tail);
                    568:    INSTRUCTION("TANH", instruction_tanh);
                    569:    INSTRUCTION("THEN", instruction_then);
                    570:    INSTRUCTION("TIME", instruction_time);
                    571:    INSTRUCTION("TRIM", instruction_trim);
                    572:    INSTRUCTION("TRNC", instruction_trnc);
                    573:    INSTRUCTION("TRUE", instruction_true);
                    574:    INSTRUCTION("TYPE", instruction_type);
1.36      bertrand  575:    INSTRUCTION("T->L", instruction_t_vers_l);
1.1       bertrand  576:    INSTRUCTION("UTPC", instruction_utpc);
                    577:    INSTRUCTION("UTPF", instruction_utpf);
                    578:    INSTRUCTION("UTPN", instruction_utpn);
                    579:    INSTRUCTION("UTPT", instruction_utpt);
                    580:    INSTRUCTION("VARS", instruction_vars);
                    581:    INSTRUCTION("WAIT", instruction_wait);
                    582:    INSTRUCTION("XCOL", instruction_xcol);
                    583:    INSTRUCTION("XPON", instruction_xpon);
                    584:    //INSTRUCTION("XRNG")
                    585:    //INSTRUCTION("XVOL")
                    586:    INSTRUCTION("YCOL", instruction_ycol);
                    587:    //INSTRUCTION("YRNG")
                    588:    //INSTRUCTION("YVOL")
                    589:    //INSTRUCTION("ZVOL")
                    590:    //INSTRUCTION("->V2")
                    591:    //Instruction HP48 (combine deux réels x et y en un vecteur 2D en fonction
                    592:    //du mode de coordonnées en cours => [ x y ] et ce quel que soit le système
                    593:    //de coordonnées courant)
                    594:    //INSTRUCTION("->V3")
                    595: 
                    596:    INSTRUCTION("ABORT", instruction_abort);
                    597:    INSTRUCTION("ACOSH", instruction_acosh);
                    598:    INSTRUCTION("ALARM", instruction_alarm);
                    599:    INSTRUCTION("ASINH", instruction_asinh);
                    600:    INSTRUCTION("ATANH", instruction_atanh);
                    601:    //INSTRUCTION("BYTES");
                    602:    INSTRUCTION("CENTR", instruction_centr);
                    603:    //INSTRUCTION("CIRCL");
                    604:    INSTRUCTION("CLEAR", instruction_clear);
                    605:    INSTRUCTION("CLLCD", instruction_cllcd);
                    606:    INSTRUCTION("CLOSE", instruction_close);
                    607:    INSTRUCTION("CLUSR", instruction_clusr);
                    608:    //INSTRUCTION("CLVAR");
                    609:    //INSTRUCTION("COLCT")
                    610:    INSTRUCTION("COL->", instruction_col_fleche);
                    611:    //INSTRUCTION("CONIC")
                    612:    //Instruction HP48 (sélectionne le type de tracé CONIC)
                    613:    //Permet de tracer des coniques en fonction d'équations
                    614:    //de type f(x, y) = 0.
                    615:    //INSTRUCTION("CRDIR")
                    616:    INSTRUCTION("CRMTX", instruction_crmtx);
                    617:    INSTRUCTION("CROSS", instruction_cross);
                    618:    INSTRUCTION("CRTAB", instruction_crtab);
                    619:    INSTRUCTION("CSTOP", instruction_cstop);
                    620:    INSTRUCTION("CYCLE", instruction_cycle);
                    621:    //INSTRUCTION("CYLIN")
                    622:    //Instruction HP48 (sélectionne le type de tracé CYLINDRIC)
                    623:    INSTRUCTION("DEPND", instruction_depnd);
                    624:    INSTRUCTION("DEPTH", instruction_depth);
                    625:    //INSTRUCTION("DOSUB")
                    626:    //Instruction HP48 (application séquentielle d'une fonction à une liste)
                    627:    //liste nombre_elements_traites_a_chaque_iteration fonction DOSUB
                    628:    //{ 1 2 3 4 5 }
                    629:    //2
                    630:    //<< + 2 / >>
                    631:    //DOSUB
                    632:    //=> { 1.5 2.5 3.5 4.5 }
                    633:    INSTRUCTION("DGTIZ", instruction_dgtiz);
                    634:    INSTRUCTION("DROP2", instruction_drop2);
                    635:    INSTRUCTION("DROPN", instruction_dropn);
                    636:    INSTRUCTION("ERASE", instruction_erase);
                    637:    INSTRUCTION("EXGET", instruction_exget);
                    638:    //INSTRUCTION("EXPAN");
                    639:    INSTRUCTION("EXSUB", instruction_exsub);
                    640:    INSTRUCTION("EYEPT", instruction_eyept);
                    641:    INSTRUCTION("FALSE", instruction_false);
                    642:    INSTRUCTION("FLOOR", instruction_floor);
                    643:    INSTRUCTION("GAMMA", instruction_gamma);
                    644:    INSTRUCTION("GEGVL", instruction_gegvl);
                    645:    INSTRUCTION("GLEGV", instruction_glegv);
                    646:    INSTRUCTION("GREGV", instruction_gregv);
                    647:    INSTRUCTION("HMS->", instruction_hms_fleche);
                    648:    INSTRUCTION("IFERR", instruction_iferr);
                    649:    INSTRUCTION("INDEP", instruction_indep);
                    650:    INSTRUCTION("INPUT", instruction_input);
                    651:    INSTRUCTION("JDATE", instruction_jdate);
                    652:    INSTRUCTION("LABEL", instruction_label);
                    653:    INSTRUCTION("LCASE", instruction_lcase);
                    654:    INSTRUCTION("LCHOL", instruction_lchol);
                    655:    INSTRUCTION("LCD->", instruction_lcd_fleche);
1.51      bertrand  656:    INSTRUCTION("LIMIT", instruction_limit);
1.1       bertrand  657:    //INSTRUCTION("NDIST")
                    658:    //Instruction HP48 (distribution normale, prend la moyenne au niveau 3,
                    659:    //la variance au niveau 2, un réel x au niveau 1 et renvoie la probabilité
                    660:    //qu'une variable aléatoire normale soit égale à x dans une distribution
                    661:    //normale).
                    662:    INSTRUCTION("NRAND", instruction_nrand);
                    663:    INSTRUCTION("OBGET", instruction_obget);
                    664:    INSTRUCTION("OBSUB", instruction_obsub);
                    665:    INSTRUCTION("PAPER", instruction_paper);
                    666:    //INSTRUCTION("PCOEFF")
                    667:    //INSTRUCTION("PEVAL")
                    668:    //INSTRUCTION("PGDIR")
                    669:    //INSTRUCTION("PIXEL")
                    670:    //INSTRUCTION("PLIST")
                    671:    //Instruction HP48 (produit des termes d'une liste)
                    672:    INSTRUCTION("POLAR", instruction_polar);
                    673:    INSTRUCTION("PRINT", instruction_print);
                    674:    //INSTRUCTION("PREDV");
                    675:    INSTRUCTION("PRLCD", instruction_prlcd);
                    676:    //INSTRUCTION("PROOT")
                    677:    //Instruction HP48 (calcule les racines d'un polynôme en fonction du tableau
                    678:    //de coefficients)
                    679:    INSTRUCTION("PRSTC", instruction_prstc);
                    680:    INSTRUCTION("PRUSR", instruction_prusr);
                    681:    INSTRUCTION("PRVAR", instruction_prvar);
                    682:    INSTRUCTION("PSDEV", instruction_psdev);
                    683:    INSTRUCTION("PURGE", instruction_purge);
                    684:    INSTRUCTION("RDATE", instruction_rdate);
                    685:    INSTRUCTION("RELAX", instruction_relax);
                    686:    INSTRUCTION("RFUSE", instruction_rfuse);
                    687:    INSTRUCTION("RSTOP", instruction_rstop);
                    688:    INSTRUCTION("ROLLD", instruction_rolld);
                    689:    INSTRUCTION("ROW->", instruction_row_fleche);
                    690:    INSTRUCTION("SCALE", instruction_scale);
                    691:    INSTRUCTION("SCHED", instruction_sched);
                    692:    INSTRUCTION("SCHUR", instruction_schur);
                    693:    INSTRUCTION("SCONJ", instruction_sconj);
                    694:    INSTRUCTION("SLICE", instruction_slice);
                    695:    //INSTRUCTION("SLIST")
                    696:    //Instruction HP48 (somme des termes d'une liste)
1.29      bertrand  697: #  ifndef OS2
1.1       bertrand  698:    INSTRUCTION("SPAWN", instruction_spawn);
1.29      bertrand  699: #  endif
1.1       bertrand  700:    INSTRUCTION("START", instruction_start);
                    701:    INSTRUCTION("STORE", instruction_store);
                    702:    INSTRUCTION("STR->", instruction_str_fleche);
                    703:    INSTRUCTION("TAYLR", instruction_taylr);
                    704:    INSTRUCTION("TITLE", instruction_title);
                    705:    //INSTRUCTION("TRACE")
                    706:    //INSTRUCTION("TRUTH")
                    707:    INSTRUCTION("UCASE", instruction_ucase);
                    708:    INSTRUCTION("UCHOL", instruction_uchol);
                    709:    INSTRUCTION("UNTIL", instruction_until);
                    710:    //INSTRUCTION("UPDIR")
                    711:    INSTRUCTION("VISIT", instruction_visit);
                    712:    INSTRUCTION("WFACK", instruction_wfack);
                    713:    INSTRUCTION("WFSWI", instruction_wfswi);
                    714:    INSTRUCTION("WHILE", instruction_while);
                    715:    //INSTRUCTION("WIDTH")
                    716:    INSTRUCTION("WRITE", instruction_write);
                    717:    INSTRUCTION("XROOT", instruction_xroot);
                    718:    INSTRUCTION("YIELD", instruction_yield);
                    719:    INSTRUCTION("->COL", instruction_fleche_col);
                    720:    INSTRUCTION("->HMS", instruction_fleche_hms);
                    721:    INSTRUCTION("->LCD", instruction_fleche_lcd);
                    722:    INSTRUCTION("->NUM", instruction_fleche_num);
                    723:    INSTRUCTION("->ROW", instruction_fleche_row);
                    724:    INSTRUCTION("->STR", instruction_fleche_str);
                    725: 
                    726:    INSTRUCTION("APPEND", instruction_append);
                    727:    INSTRUCTION("ARRY->", instruction_array_fleche);
1.12      bertrand  728:    INSTRUCTION("ATEXIT", instruction_atexit);
1.24      bertrand  729:    INSTRUCTION("ATPOKE", instruction_atpoke);
1.1       bertrand  730:    INSTRUCTION("BESSEL", instruction_bessel);
                    731:    INSTRUCTION("CLRERR", instruction_clrerr);
                    732:    INSTRUCTION("CLRMTX", instruction_clrmtx);
                    733:    INSTRUCTION("CLRSWI", instruction_clrswi);
                    734:    INSTRUCTION("CREATE", instruction_create);
                    735:    INSTRUCTION("DELETE", instruction_delete);
1.29      bertrand  736: #  ifndef OS2
1.1       bertrand  737:    INSTRUCTION("DETACH", instruction_detach);
1.29      bertrand  738: #  endif
1.1       bertrand  739:    INSTRUCTION("DIAG->", instruction_diag_fleche);
                    740:    //INSTRUCTION("DOLIST")
                    741:    //Instruction HP48 (application d'une fonction à une liste)
                    742:    //liste(s) nombre_de_listes_a_traiter fonction DOLIST
                    743:    //{ 1 2 3 }
                    744:    //{ 4 5 6 }
                    745:    //{ 7 8 9 }
                    746:    //3
                    747:    //<<  * + >>
                    748:    //DOLIST
                    749:    //=> { 29 42 57 }
                    750:    INSTRUCTION("ELSEIF", instruction_elseif);
                    751:    INSTRUCTION("FORMAT", instruction_format);
                    752:    //INSTRUCTION("HEIGHT")
                    753:    INSTRUCTION("ITRACE", instruction_itrace);
                    754:    INSTRUCTION("LIST->", instruction_list_fleche);
                    755:    INSTRUCTION("LOGGER", instruction_logger);
                    756:    INSTRUCTION("MCLRIN", instruction_mclrin);
                    757:    INSTRUCTION("NRPROC", instruction_nrproc);
1.17      bertrand  758:    INSTRUCTION("PROCID", instruction_procid);
1.1       bertrand  759:    INSTRUCTION("PROMPT", instruction_prompt);
                    760:    INSTRUCTION("RCLSWI", instruction_rclswi);
                    761:    INSTRUCTION("RECALL", instruction_recall);
                    762:    INSTRUCTION("RECODE", instruction_recode);
                    763:    INSTRUCTION("REDRAW", instruction_redraw);
                    764:    INSTRUCTION("REMOVE", instruction_remove);
                    765:    INSTRUCTION("REPEAT", instruction_repeat);
                    766:    INSTRUCTION("RETURN", instruction_return);
                    767:    INSTRUCTION("REWIND", instruction_rewind);
                    768:    //INSTRUCTION("SCREEN")
                    769:    INSTRUCTION("SELECT", instruction_select);
                    770:    //INSTRUCTION("SPHERE")
                    771:    INSTRUCTION("SHARED", instruction_shared);
                    772:    INSTRUCTION("SPLASH", instruction_splash);
                    773:    INSTRUCTION("STATIC", instruction_static);
                    774:    INSTRUCTION("STOSWI", instruction_stoswi);
                    775:    //INSTRUCTION("STREAM", instruction_stream);
                    776:    //{ 1 2 3 4 5 } << * >> STREAM => 120
                    777:    INSTRUCTION("TARGET", instruction_target);
                    778:    INSTRUCTION("UNLOCK", instruction_unlock);
                    779:    INSTRUCTION("VERIFY", instruction_verify);
                    780:    INSTRUCTION("WFDATA", instruction_wfdata);
                    781:    INSTRUCTION("WFLOCK", instruction_wflock);
                    782:    INSTRUCTION("WFPOKE", instruction_wfpoke);
                    783:    INSTRUCTION("WFPROC", instruction_wfproc);
                    784:    INSTRUCTION("WFSOCK", instruction_wfsock);
                    785:    INSTRUCTION("->ARRY", instruction_fleche_array);
                    786:    INSTRUCTION("->DIAG", instruction_fleche_diag);
                    787:    INSTRUCTION("->LIST", instruction_fleche_list);
                    788: 
                    789:    INSTRUCTION("ARRAY->", instruction_array_fleche);
                    790:    //INSTRUCTION("BARPLOT")
                    791:    //INSTRUCTION("BESTFIT")
                    792:    //Instruction HP48 (choisit le meilleur modèle de régression)
                    793:    INSTRUCTION("CLRFUSE", instruction_clrfuse);
                    794:    INSTRUCTION("CONVERT", instruction_convert);
                    795:    INSTRUCTION("CRSMPHR", instruction_crsmphr);
                    796:    INSTRUCTION("CURRENC", instruction_currenc);
                    797:    INSTRUCTION("DEFAULT", instruction_default);
                    798:    INSTRUCTION("EPSILON", instruction_epsilon);
                    799:    //INSTRUCTION("GRIDMAP")
                    800:    //Instruction HP48 (sélectionne le mode de tracé GRIDMAP)
                    801:    //Le tracé GRIDMAP transforme la grille d'échantillonnage rectiligne
                    802:    //en appliquant la fonction en cours à valeurs complexes.
                    803:    //Les coordonnées de chaque point de la grille (un nombre complexe)
                    804:    //constituent
                    805:    //les données d'entrée de la fonction qui les projette ensuite dans le
                    806:    //grille
                    807:    //de sortie.
                    808:    //f(x,y)=fnct complexe évaluée sur la grille (x,y) et affichée comme une
                    809:    //fonction paramétrique.
                    810:    INSTRUCTION("INQUIRE", instruction_inquire);
1.15      bertrand  811:    INSTRUCTION("MEMLOCK", instruction_memlock);
1.1       bertrand  812:    INSTRUCTION("MTXLOCK", instruction_mtxlock);
                    813:    INSTRUCTION("PERSIST", instruction_persist);
                    814:    INSTRUCTION("PLOTTER", instruction_plotter);
                    815:    INSTRUCTION("PRIVATE", instruction_private);
                    816:    INSTRUCTION("PROTECT", instruction_protect);
                    817:    INSTRUCTION("PSHPRFL", instruction_pshprfl);
                    818:    INSTRUCTION("PULPRFL", instruction_pulprfl);
                    819:    INSTRUCTION("REVLIST", instruction_revlist);
                    820:    INSTRUCTION("SCATTER", instruction_scatter);
                    821:    INSTRUCTION("SUSPEND", instruction_suspend);
                    822:    INSTRUCTION("SWILOCK", instruction_swilock);
                    823:    INSTRUCTION("SYSEVAL", instruction_syseval);
                    824:    INSTRUCTION("TABLE->", instruction_table_fleche);
                    825:    INSTRUCTION("VERSION", instruction_version);
                    826:    INSTRUCTION("WORKDIR", instruction_workdir);
                    827:    INSTRUCTION("->ARRAY", instruction_fleche_array);
                    828:    INSTRUCTION("->TABLE", instruction_fleche_table);
                    829: 
                    830:    INSTRUCTION("CLRCNTXT", instruction_clrcntxt);
                    831:    INSTRUCTION("CLRSMPHR", instruction_clrsmphr);
1.29      bertrand  832: #  ifndef OS2
1.1       bertrand  833:    INSTRUCTION("CONTINUE", instruction_continue);
1.29      bertrand  834: #  endif
1.1       bertrand  835:    INSTRUCTION("DUPCNTXT", instruction_dupcntxt);
                    836:    INSTRUCTION("FUNCTION", instruction_function);
1.7       bertrand  837:    INSTRUCTION("IMPLICIT", instruction_implicit);
1.50      bertrand  838:    INSTRUCTION("INFINITY", instruction_sensible_infinity);
1.1       bertrand  839:    INSTRUCTION("KEYLABEL", instruction_keylabel);
                    840:    INSTRUCTION("KEYTITLE", instruction_keytitle);
                    841:    INSTRUCTION("LOGSCALE", instruction_logscale);
                    842:    INSTRUCTION("NEWPLANE", instruction_newplane);
                    843:    INSTRUCTION("PSHCNTXT", instruction_pshcntxt);
                    844:    INSTRUCTION("PULCNTXT", instruction_pulcntxt);
                    845:    INSTRUCTION("SQLQUERY", instruction_sqlquery);
                    846:    INSTRUCTION("SWIQUEUE", instruction_swiqueue);
                    847:    INSTRUCTION("TOKENIZE", instruction_tokenize);
                    848:    INSTRUCTION("VARIABLE", instruction_variable);
                    849:    INSTRUCTION("VOLATILE", instruction_volatile);
                    850:    INSTRUCTION("WARRANTY", instruction_warranty);
                    851: 
                    852:    INSTRUCTION("AUTOSCALE", instruction_autoscale);
                    853:    INSTRUCTION("BACKSPACE", instruction_backspace);
1.22      bertrand  854:    INSTRUCTION("BACKTRACE", instruction_backtrace);
1.13      bertrand  855:    INSTRUCTION("CLRATEXIT", instruction_clratexit);
1.24      bertrand  856:    INSTRUCTION("CLRATPOKE", instruction_clratpoke);
1.1       bertrand  857:    INSTRUCTION("COPYRIGHT", instruction_copyright);
                    858:    //INSTRUCTION("CYLINDRIC");
                    859:    INSTRUCTION("DAEMONIZE", instruction_daemonize);
                    860:    INSTRUCTION("DROPCNTXT", instruction_dropcntxt);
                    861:    INSTRUCTION("EXTERNALS", instruction_externals);
                    862:    INSTRUCTION("HISTOGRAM", instruction_histogram);
1.15      bertrand  863:    INSTRUCTION("MEMUNLOCK", instruction_memunlock);
1.1       bertrand  864:    INSTRUCTION("MTXSTATUS", instruction_mtxstatus);
                    865:    INSTRUCTION("MTXUNLOCK", instruction_mtxunlock);
                    866:    INSTRUCTION("PARAMETER", instruction_parameter);
                    867:    //INSTRUCTION("PSCONTOUR")
                    868:    //INSTRUCTION("SCATRPLOT")
                    869:    //(trace un nuage de points de SDAT et la courbe de régression)
                    870:    INSTRUCTION("SMPHRDECR", instruction_smphrdecr);
                    871:    INSTRUCTION("SMPHRGETV", instruction_smphrgetv);
                    872:    INSTRUCTION("SMPHRINCR", instruction_smphrincr);
                    873:    INSTRUCTION("SWAPCNTXT", instruction_swapcntxt);
                    874:    INSTRUCTION("SWISTATUS", instruction_swistatus);
                    875:    INSTRUCTION("SWIUNLOCK", instruction_swiunlock);
                    876:    INSTRUCTION("UNPROTECT", instruction_unprotect);
                    877:    INSTRUCTION("WIREFRAME", instruction_wireframe);
                    878: 
                    879:    INSTRUCTION("MTXTRYLOCK", instruction_mtxtrylock);
                    880:    INSTRUCTION("PARAMETRIC", instruction_parametric);
                    881:    //INSTRUCTION("PARSURFACE")
                    882:    //Instruction HP48 (tracé PARSURFACE) Equation sous forme de liste
                    883:    INSTRUCTION("SLICESCALE", instruction_slicescale);
                    884:    INSTRUCTION("SQLCONNECT", instruction_sqlconnect);
                    885:    //INSTRUCTION("SLOPEFIELD")
                    886:    //Instruction HP48 (type de tracé)
                    887:    //Tracé 3D en courbes de niveaux.
                    888:    //Le type de tracé 'SLOPEFIELD' dessine un réseau de segments dont les
                    889:    //pentes
                    890:    //représentent la valeur de la fonction (x,y) en leur milieu.
                    891:    //=> utile pour y'=F(x,y)
                    892: 
                    893:    INSTRUCTION("LOCALIZATION", instruction_localization);
                    894:    INSTRUCTION("SMPHRTRYDECR", instruction_smphrtrydecr);
                    895: 
                    896:    INSTRUCTION("SQLDISCONNECT", instruction_sqldisconnect);
                    897: #undef INSTRUCTION
                    898: 
                    899:    return;
                    900: }
                    901: 
                    902: 
1.25      bertrand  903: void *
1.1       bertrand  904: analyse_instruction(struct_processus *s_etat_processus, unsigned char *ptr)
                    905: {
                    906:    int                             pointeur;
                    907: 
                    908:    struct_instruction              *l_instruction_courante;
                    909: 
                    910:    l_instruction_courante = (*s_etat_processus).arbre_instructions;
                    911: 
                    912:    while((*ptr) != d_code_fin_chaine)
                    913:    {
                    914:        pointeur = (*s_etat_processus).pointeurs_caracteres[*ptr];
                    915: 
                    916:        if (pointeur < 0)
                    917:        {
                    918:            // Caractère hors de l'alphabet des instructions
                    919: 
                    920:            return(NULL);
                    921:        }
                    922: 
1.41      bertrand  923:        if ((*l_instruction_courante).noeuds[pointeur] == NULL)
1.1       bertrand  924:        {
                    925:            // Le chemin de l'instruction candidate n'existe pas.
                    926: 
                    927:            return(NULL);
                    928:        }
                    929: 
1.41      bertrand  930:        l_instruction_courante = (*l_instruction_courante).noeuds[pointeur];
1.1       bertrand  931:        ptr++;
                    932: 
                    933:        if ((l_instruction_courante == NULL) && ((*ptr) != d_code_fin_chaine))
                    934:        {
                    935:            // Le chemin de l'instruction candidate est incomplet.
                    936: 
                    937:            return(NULL);
                    938:        }
                    939:    }
                    940: 
                    941:    if ((*l_instruction_courante).feuille != NULL)
                    942:    {
                    943:        return((*l_instruction_courante).feuille);
                    944:    }
                    945: 
                    946:    return(NULL);
                    947: }
                    948: 
                    949: 
                    950: void
                    951: analyse(struct_processus *s_etat_processus, void (*fonction)())
                    952: {
                    953:    static logical1                 initialisation = d_faux;
                    954: 
                    955:    real8                           attente;
                    956:    real8                           pourcentage;
                    957:    real8                           temps_cpu;
                    958:    real8                           temps_reel;
                    959: 
                    960:    static struct timeval           horodatage_initial;
                    961:    struct timeval                  horodatage_final;
                    962: 
                    963:    static struct rusage            usage_initial;
                    964:    struct rusage                   usage_final;
                    965: 
                    966:    struct timespec                 temporisation;
                    967: 
                    968:    unsigned char                   *position;
                    969:    unsigned char                   *bibliotheque_candidate;
1.14      bertrand  970:    unsigned char                   instruction_majuscule
                    971:                                            [d_longueur_maximale_instruction];
1.1       bertrand  972:    unsigned char                   registre_instruction_valide;
                    973: 
                    974:    void                            (*instruction)();
                    975: 
                    976:    errno = 0;
                    977:    (*s_etat_processus).var_volatile_exception_gsl = 0;
                    978: 
                    979:    (*s_etat_processus).instruction_valide = 'Y';
                    980:    (*s_etat_processus).constante_symbolique = 'N';
                    981:    (*s_etat_processus).nombre_arguments = -2;
                    982:    (*s_etat_processus).instruction_intrinseque = 'I';
                    983: 
                    984:    /*
                    985:     * On autorise l'exécution d'un fork() dans un thread concurrent.
                    986:     */
                    987: 
1.55    ! bertrand  988:    if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
1.1       bertrand  989:    {
                    990:        (*s_etat_processus).erreur_systeme = d_es_processus;
                    991:        return;
                    992:    }
                    993: 
1.55    ! bertrand  994:    if (sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
1.9       bertrand  995:    {
                    996:        (*s_etat_processus).erreur_systeme = d_es_processus;
                    997:        return;
                    998:    }
                    999: 
1.1       bertrand 1000:    scrutation_injection(s_etat_processus);
                   1001: 
                   1002:    if (fonction == NULL)
                   1003:    {
1.14      bertrand 1004:        conversion_majuscule_limitee((*s_etat_processus).instruction_courante,
                   1005:                instruction_majuscule, d_longueur_maximale_instruction);
1.1       bertrand 1006:        instruction = analyse_instruction(s_etat_processus,
                   1007:                instruction_majuscule);
                   1008: 
                   1009:        if (instruction == NULL)
                   1010:        {
                   1011:            // L'instruction n'existe pas.
                   1012: 
                   1013:            (*s_etat_processus).instruction_valide = 'N';
                   1014:        }
                   1015:        else
                   1016:        {
                   1017:            // Exécution de l'instruction associée. Le drapeau
                   1018:            // (*s_etat_processus).instruction_valide peut passer à 'N'
                   1019:            // dans le cas d'instructions sensibles à la casse.
                   1020: 
                   1021:            if ((*s_etat_processus).niveau_profilage >= 2)
                   1022:            {
                   1023:                profilage(s_etat_processus, instruction_majuscule);
                   1024:            }
                   1025: 
                   1026:            (*s_etat_processus).instruction_valide = 'Y';
                   1027:            instruction(s_etat_processus);
                   1028: 
                   1029:            if ((*s_etat_processus).niveau_profilage >= 2)
                   1030:            {
                   1031:                profilage(s_etat_processus, NULL);
                   1032:            }
                   1033:        }
                   1034:    }
                   1035:    else
                   1036:    {
                   1037:        if ((*s_etat_processus).niveau_profilage >= 2)
                   1038:        {
                   1039:            profilage(s_etat_processus,
                   1040:                    (*s_etat_processus).instruction_courante);
                   1041:        }
                   1042: 
                   1043:        (*s_etat_processus).instruction_valide = 'Y';
                   1044:        fonction(s_etat_processus);
                   1045: 
                   1046:        if ((*s_etat_processus).niveau_profilage >= 2)
                   1047:        {
                   1048:            profilage(s_etat_processus, NULL);
                   1049:        }
                   1050:    }
                   1051: 
                   1052:    if ((*s_etat_processus).instruction_valide == 'Y')
                   1053:    {
                   1054:        (*s_etat_processus).instruction_intrinseque = 'Y';
                   1055:    }
                   1056: 
                   1057:    if ((*s_etat_processus).instruction_valide == 'N')
                   1058:    {
                   1059:        if ((position = index((*s_etat_processus).instruction_courante, '$'))
                   1060:                != NULL)
                   1061:        {
                   1062:            if ((bibliotheque_candidate = malloc((position + 1
                   1063:                    - (*s_etat_processus).instruction_courante)
                   1064:                    * sizeof(unsigned char))) == NULL)
                   1065:            {
                   1066:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   1067:                return;
                   1068:            }
                   1069: 
                   1070:            (*bibliotheque_candidate) = d_code_fin_chaine;
                   1071:            strncat(bibliotheque_candidate,
                   1072:                    (*s_etat_processus).instruction_courante,
                   1073:                    position - (*s_etat_processus).instruction_courante);
                   1074: 
                   1075:            position++;
                   1076: 
                   1077:            if (execution_fonction_de_bibliotheque(s_etat_processus, position,
                   1078:                    bibliotheque_candidate) == d_vrai)
                   1079:            {
                   1080:                (*s_etat_processus).instruction_valide = 'Y';
                   1081:                (*s_etat_processus).instruction_intrinseque = 'N';
                   1082:            }
                   1083:            else
                   1084:            {
                   1085:                (*s_etat_processus).instruction_valide = 'N';
                   1086:            }
                   1087: 
                   1088:            free(bibliotheque_candidate);
                   1089:        }
                   1090:        else
                   1091:        {
                   1092:            if (execution_fonction_de_bibliotheque(s_etat_processus,
                   1093:                    (*s_etat_processus).instruction_courante, NULL)
                   1094:                    == d_vrai)
                   1095:            {
                   1096:                (*s_etat_processus).instruction_valide = 'Y';
                   1097:                (*s_etat_processus).instruction_intrinseque = 'N';
                   1098:            }
                   1099:            else
                   1100:            {
                   1101:                (*s_etat_processus).instruction_valide = 'N';
                   1102:            }
                   1103:        }
                   1104:    }
                   1105: 
                   1106: /*
                   1107: --------------------------------------------------------------------------------
                   1108:   Gestion des interruptions logicielles
                   1109: --------------------------------------------------------------------------------
                   1110: */
                   1111: 
                   1112:    if (((*s_etat_processus).erreur_systeme == d_es) &&
                   1113:            ((*s_etat_processus).erreur_execution == d_ex) &&
                   1114:            ((*s_etat_processus).exception == d_ep))
                   1115:    {
                   1116:        if ((*s_etat_processus).test_instruction == 'N')
                   1117:        {
                   1118:            if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
                   1119:            {
                   1120:                affectation_interruptions_logicielles(s_etat_processus);
                   1121:            }
                   1122: 
                   1123:            if (((*s_etat_processus).nombre_interruptions_en_queue != 0) &&
                   1124:                    ((*s_etat_processus).erreur_systeme == d_es) &&
                   1125:                    ((*s_etat_processus).erreur_execution == d_ex))
                   1126:            {
                   1127: 
                   1128:                registre_instruction_valide =
                   1129:                        (*s_etat_processus).instruction_valide;
                   1130:                traitement_interruptions_logicielles(s_etat_processus);
                   1131:                (*s_etat_processus).instruction_valide =
                   1132:                        registre_instruction_valide;
                   1133:            }
                   1134:        }
                   1135:    }
                   1136: 
                   1137: /*
                   1138: --------------------------------------------------------------------------------
                   1139:   Limitation du pourcetage de temps CPU
                   1140: --------------------------------------------------------------------------------
                   1141: */
                   1142: 
1.27      bertrand 1143: #  ifndef OS2
1.1       bertrand 1144:    if ((*s_etat_processus).pourcentage_maximal_cpu < 100)
                   1145:    {
                   1146:        getrusage(RUSAGE_SELF, &usage_final);
                   1147:        gettimeofday(&horodatage_final, NULL);
                   1148: 
                   1149:        if (initialisation == d_vrai)
                   1150:        {
                   1151:            temps_reel = ((real8) (horodatage_final.tv_sec -
                   1152:                    horodatage_initial.tv_sec)) +
                   1153:                    (((real8) (horodatage_final.tv_usec -
                   1154:                    horodatage_initial.tv_usec)) / ((real8) 1E6));
                   1155: 
                   1156:            if (temps_reel >= 0.1)
                   1157:            {
                   1158:                temps_cpu = ((real8) ((usage_final.ru_utime.tv_sec +
                   1159:                        usage_final.ru_stime.tv_sec) -
                   1160:                        (usage_initial.ru_utime.tv_sec +
                   1161:                        usage_initial.ru_stime.tv_sec))) +
                   1162:                        (((real8) ((usage_final.ru_utime.tv_usec +
                   1163:                        usage_final.ru_stime.tv_usec) -
                   1164:                        (usage_initial.ru_utime.tv_usec +
                   1165:                        usage_initial.ru_stime.tv_usec))) / ((real8) 1E6));
                   1166: 
                   1167:                pourcentage = 100 * temps_cpu / temps_reel;
                   1168: 
                   1169:                if (pourcentage > 100)
                   1170:                {
                   1171:                    pourcentage = 100;
                   1172:                }
                   1173: 
                   1174:                if (pourcentage > (*s_etat_processus).pourcentage_maximal_cpu)
                   1175:                {
                   1176:                    attente = ((pourcentage * temps_cpu) /
                   1177:                            (*s_etat_processus).pourcentage_maximal_cpu)
                   1178:                            - (pourcentage * temps_cpu / 100);
                   1179: 
                   1180:                    temporisation.tv_sec = floor(attente);
                   1181:                    temporisation.tv_nsec = (attente - temporisation.tv_sec) *
                   1182:                            1E9;
                   1183: 
                   1184:                    nanosleep(&temporisation, NULL);
                   1185:                }
                   1186: 
                   1187:                horodatage_initial = horodatage_final;
                   1188:                usage_initial = usage_final;
                   1189:            }
                   1190:        }
                   1191:        else
                   1192:        {
                   1193:            initialisation = d_vrai;
                   1194: 
                   1195:            horodatage_initial = horodatage_final;
                   1196:            usage_initial = usage_final;
                   1197:        }
                   1198:    }
1.27      bertrand 1199: #  endif
1.1       bertrand 1200: 
                   1201: /*
                   1202: --------------------------------------------------------------------------------
                   1203:   Introduction des erreurs générées
                   1204: --------------------------------------------------------------------------------
                   1205: */
                   1206: 
                   1207:    if (((*s_etat_processus).test_instruction == 'N') &&
                   1208:            ((*s_etat_processus).instruction_valide == 'Y'))
                   1209:    {
                   1210:        traitement_asynchrone_exceptions_gsl(s_etat_processus);
                   1211: 
                   1212:        if ((*s_etat_processus).erreur_processus_fils == d_vrai)
                   1213:        {
                   1214:            (*s_etat_processus).erreur_processus_fils = d_faux;
                   1215: 
                   1216:            (*s_etat_processus).erreur_systeme =
                   1217:                    (*s_etat_processus).erreur_systeme_processus_fils;
                   1218:            (*s_etat_processus).erreur_execution =
                   1219:                    (*s_etat_processus).erreur_execution_processus_fils;
                   1220:            (*s_etat_processus).arret_si_exception = d_vrai;
                   1221: 
                   1222:            if ((*s_etat_processus).pid_erreur_processus_fils == getpid())
                   1223:            {
                   1224:                (*s_etat_processus).invalidation_message_erreur = d_faux;
                   1225:            }
                   1226:            else
                   1227:            {
                   1228:                (*s_etat_processus).invalidation_message_erreur = d_vrai;
                   1229:            }
                   1230:        }
                   1231: 
                   1232:        if (((*s_etat_processus).erreur_execution != d_ex) ||
                   1233:                ((*s_etat_processus).erreur_systeme != d_es) ||
                   1234:                ((*s_etat_processus).exception != d_ep))
                   1235:        {
                   1236:            (*s_etat_processus).niveau_derniere_erreur =
                   1237:                    (*s_etat_processus).niveau_courant;
                   1238: 
                   1239:            if ((*s_etat_processus).mode_execution_programme == 'Y')
                   1240:            {
1.21      bertrand 1241:                if ((*s_etat_processus).instruction_derniere_erreur != NULL)
                   1242:                {
                   1243:                    free((*s_etat_processus).instruction_derniere_erreur);
                   1244:                    (*s_etat_processus).instruction_derniere_erreur = NULL;
                   1245:                }
                   1246: 
1.1       bertrand 1247:                if ((*s_etat_processus).instruction_courante == NULL)
                   1248:                {
                   1249:                    if (((*s_etat_processus).instruction_derniere_erreur =
                   1250:                            malloc(16 * sizeof(unsigned char))) == NULL)
                   1251:                    {
                   1252:                        (*s_etat_processus).erreur_systeme =
                   1253:                                d_es_allocation_memoire;
                   1254:                        return;
                   1255:                    }
                   1256: 
                   1257:                    strcpy((*s_etat_processus).instruction_derniere_erreur,
                   1258:                            "<not available>");
                   1259:                }
                   1260:                else
                   1261:                {
                   1262:                    if (((*s_etat_processus).instruction_derniere_erreur =
                   1263:                            malloc((strlen((*s_etat_processus)
                   1264:                            .instruction_courante) + 1) *
                   1265:                            sizeof(unsigned char))) == NULL)
                   1266:                    {
                   1267:                        (*s_etat_processus).erreur_systeme =
                   1268:                                d_es_allocation_memoire;
                   1269:                        return;
                   1270:                    }
                   1271: 
                   1272:                    strcpy((*s_etat_processus).instruction_derniere_erreur,
                   1273:                            (*s_etat_processus).instruction_courante);
                   1274:                }
                   1275:            }
                   1276:            else
                   1277:            {
1.21      bertrand 1278:                if ((*s_etat_processus).objet_courant != NULL)
1.1       bertrand 1279:                {
1.21      bertrand 1280:                    if ((*s_etat_processus).instruction_derniere_erreur != NULL)
                   1281:                    {
                   1282:                        free((*s_etat_processus).instruction_derniere_erreur);
                   1283:                        (*s_etat_processus).instruction_derniere_erreur = NULL;
                   1284:                    }
                   1285: 
                   1286:                    if (((*s_etat_processus).instruction_derniere_erreur =
                   1287:                            formateur(s_etat_processus, 0,
                   1288:                            (*s_etat_processus).objet_courant)) == NULL)
                   1289:                    {
                   1290:                        return;
                   1291:                    }
                   1292: 
                   1293:                    (*s_etat_processus).objet_courant = NULL;
1.1       bertrand 1294:                }
                   1295:            }
                   1296:        }
                   1297:    }
                   1298: 
                   1299:    return;
                   1300: }
                   1301: 
                   1302: 
                   1303: /*
                   1304: ================================================================================
                   1305:   Traitement asynchrone des erreurs de la bibliothèque GSL
                   1306: ================================================================================
                   1307:   Entrées :
                   1308: --------------------------------------------------------------------------------
                   1309:   Sorties :
                   1310: --------------------------------------------------------------------------------
                   1311:   Effets de bord : néant
                   1312: ================================================================================
                   1313: */
                   1314: 
                   1315: void
                   1316: traitement_asynchrone_exceptions_gsl(struct_processus *s_etat_processus)
                   1317: {
                   1318:    if ((*s_etat_processus).var_volatile_exception_gsl != 0)
                   1319:    {
                   1320:        switch((*s_etat_processus).var_volatile_exception_gsl)
                   1321:        {
                   1322:            case GSL_EINVAL :
                   1323:            {
                   1324:                (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
                   1325:                break;
                   1326:            }
                   1327: 
                   1328:            case GSL_EDOM :
                   1329:            {
                   1330:                (*s_etat_processus).exception = d_ep_domaine_definition;
                   1331:                break;
                   1332:            }
                   1333: 
                   1334:            case GSL_ERANGE :
                   1335:            {
                   1336:                (*s_etat_processus).exception = d_ep_resultat_indefini;
                   1337:                break;
                   1338:            }
                   1339: 
                   1340:            case GSL_EZERODIV :
                   1341:            {
                   1342:                (*s_etat_processus).exception = d_ep_division_par_zero;
                   1343:                break;
                   1344:            }
                   1345: 
                   1346:            case GSL_EUNDRFLW :
                   1347:            {
                   1348:                (*s_etat_processus).exception = d_ep_underflow;
                   1349:                break;
                   1350:            }
                   1351: 
                   1352:            case GSL_EOVRFLW :
                   1353:            {
                   1354:                (*s_etat_processus).exception = d_ep_overflow;
                   1355:                break;
                   1356:            }
                   1357: 
                   1358:            case GSL_ENOMEM :
                   1359:            {
                   1360:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   1361:                break;
                   1362:            }
                   1363: 
                   1364:            case GSL_ELOSS :
                   1365:            {
                   1366:                (*s_etat_processus).exception = d_ep_perte_precision;
                   1367:                break;
                   1368:            }
                   1369: 
                   1370:            default :
                   1371:            {
                   1372:                (*s_etat_processus).erreur_execution =
                   1373:                        d_ex_routines_mathematiques;
                   1374:                break;
                   1375:            }
                   1376:        }
                   1377: 
                   1378:        (*s_etat_processus).var_volatile_exception_gsl = 0;
                   1379:    }
                   1380: 
                   1381:    return;
                   1382: }
                   1383: 
                   1384: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>