Annotation of rpl/src/compilation.c, revision 1.1

1.1     ! bertrand    1: /*
        !             2: ================================================================================
        !             3:   RPL/2 (R) version 4.0.9
        !             4:   Copyright (C) 1989-2010 Dr. BERTRAND Joël
        !             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: 
        !            23: #include "rpl.conv.h"
        !            24: 
        !            25: 
        !            26: /*
        !            27: ================================================================================
        !            28:   Procédure de vérification syntaxique du source et de précompilation
        !            29: ================================================================================
        !            30:   Entrées :
        !            31: --------------------------------------------------------------------------------
        !            32:   Sorties :
        !            33:    - renvoi    :   erreur
        !            34: --------------------------------------------------------------------------------
        !            35:   Effets de bord :
        !            36: ================================================================================
        !            37: */
        !            38: 
        !            39: logical1
        !            40: compilation(struct_processus *s_etat_processus)
        !            41: {
        !            42:    struct_objet            *s_objet;
        !            43: 
        !            44:    struct_variable         *s_variable;
        !            45: 
        !            46:    unsigned char           apostrophe_ouverte;
        !            47:    unsigned char           apostrophe_ouverte_registre;
        !            48:    unsigned char           caractere_courant;
        !            49:    unsigned char           caractere_precedent;
        !            50:    unsigned char           caractere_suivant;
        !            51:    unsigned char           *definition;
        !            52:    unsigned char           fermeture_definition;
        !            53:    unsigned char           guillemet_ouvert;
        !            54:    unsigned char           ouverture_definition;
        !            55:    unsigned char           position_debut_nom_definition_valide;
        !            56: 
        !            57:    unsigned long           *adresse;
        !            58:    unsigned long           i;
        !            59:    unsigned long           niveau_definition;
        !            60:    unsigned long           niveau_definition_registre;
        !            61:    unsigned long           position_courante;
        !            62:    unsigned long           position_debut_nom_definition;
        !            63:    unsigned long           position_fin_nom_definition;
        !            64:    unsigned long           validation;
        !            65:    unsigned long           validation_registre;
        !            66: 
        !            67:    (*s_etat_processus).erreur_compilation = d_ec;
        !            68:    (*s_etat_processus).erreur_systeme = d_es;
        !            69:    (*s_etat_processus).erreur_execution = d_ex;
        !            70:    (*s_etat_processus).exception = d_ep;
        !            71:    (*s_etat_processus).arret_si_exception = d_vrai;
        !            72: 
        !            73:    (*s_etat_processus).position_courante = 0;
        !            74: 
        !            75: 
        !            76: /*
        !            77: --------------------------------------------------------------------------------
        !            78:   Recheche des définitions
        !            79: --------------------------------------------------------------------------------
        !            80: */
        !            81: 
        !            82:    niveau_definition = 0;
        !            83:    niveau_definition_registre = 0;
        !            84:    position_courante = 0;
        !            85:    position_debut_nom_definition = 0;
        !            86:    validation = 0;
        !            87: 
        !            88:    apostrophe_ouverte = d_faux;
        !            89:    apostrophe_ouverte_registre = d_faux;
        !            90:    guillemet_ouvert = d_faux;
        !            91:    position_debut_nom_definition_valide = d_faux;
        !            92: 
        !            93:    if ((*s_etat_processus).debug == d_vrai)
        !            94:        if (((*s_etat_processus).type_debug & d_debug_analyse) != 0)
        !            95:    {
        !            96:        printf("\n");
        !            97:        printf("[%d] Compilation\n", (int) getpid());
        !            98:        fflush(stdout);
        !            99:    }
        !           100: 
        !           101:    while((*s_etat_processus).definitions_chainees[position_courante] !=
        !           102:            d_code_fin_chaine)
        !           103:    {
        !           104:        caractere_courant = (*s_etat_processus)
        !           105:                .definitions_chainees[position_courante];
        !           106: 
        !           107:        fermeture_definition = d_faux;
        !           108:        ouverture_definition = d_faux;
        !           109: 
        !           110:        if (position_courante >= 1)
        !           111:        {
        !           112:            if (position_courante >= 2)
        !           113:            {
        !           114:                if (((*s_etat_processus).definitions_chainees
        !           115:                        [position_courante - 2] == '\\') &&
        !           116:                        ((*s_etat_processus).definitions_chainees
        !           117:                        [position_courante - 1] == '\\'))
        !           118:                {
        !           119:                    caractere_precedent = '*';
        !           120:                }
        !           121:                else
        !           122:                {
        !           123:                    caractere_precedent = (*s_etat_processus)
        !           124:                            .definitions_chainees[position_courante - 1];
        !           125:                }
        !           126:            }
        !           127:            else
        !           128:            {
        !           129:                caractere_precedent = (*s_etat_processus)
        !           130:                        .definitions_chainees[position_courante - 1];
        !           131:            }
        !           132:        }
        !           133:        else
        !           134:        {
        !           135:            caractere_precedent = ' ';
        !           136:        }
        !           137: 
        !           138:        caractere_suivant = (*s_etat_processus)
        !           139:                .definitions_chainees[position_courante + 1];
        !           140: 
        !           141:        if (caractere_suivant == d_code_fin_chaine)
        !           142:        {
        !           143:            caractere_suivant = ' ';
        !           144:        }
        !           145: 
        !           146:        if ((caractere_courant == '[') || (caractere_courant == '{'))
        !           147:        {
        !           148:            validation++;
        !           149:        }
        !           150:        else if ((caractere_courant == ']') || (caractere_courant == '}'))
        !           151:        {
        !           152:            validation--;
        !           153:        }
        !           154:        else if (caractere_courant == '\'')
        !           155:        {
        !           156:            if (apostrophe_ouverte == d_faux)
        !           157:            {
        !           158:                validation++;
        !           159:                apostrophe_ouverte = d_vrai;
        !           160:            }
        !           161:            else
        !           162:            {
        !           163:                validation--;
        !           164:                apostrophe_ouverte = d_faux;
        !           165:            }
        !           166:        }
        !           167:        else if (caractere_courant == '"')
        !           168:        {
        !           169:            if (caractere_precedent != '\\')
        !           170:            {
        !           171:                swap((void *) &validation, (void *) &validation_registre,
        !           172:                        sizeof(validation));
        !           173:                swap((void *) &apostrophe_ouverte,
        !           174:                        (void *) &apostrophe_ouverte_registre,
        !           175:                        sizeof(apostrophe_ouverte));
        !           176:                swap((void *) &niveau_definition,
        !           177:                        (void *) &niveau_definition_registre,
        !           178:                        sizeof(niveau_definition));
        !           179: 
        !           180:                guillemet_ouvert = (guillemet_ouvert == d_faux)
        !           181:                        ? d_vrai : d_faux;
        !           182:            }
        !           183:        }
        !           184:        else if ((caractere_courant == '<') &&
        !           185:                (caractere_precedent == ' ') &&
        !           186:                (caractere_suivant == '<'))
        !           187:        {
        !           188:            if ((*s_etat_processus)
        !           189:                    .definitions_chainees[position_courante + 2] == ' ')
        !           190:            {
        !           191:                niveau_definition++;
        !           192:                ouverture_definition = d_vrai;
        !           193:            }
        !           194:        }
        !           195:        else if ((caractere_courant == '>') &&
        !           196:                (caractere_precedent == ' ') &&
        !           197:                (caractere_suivant == '>'))
        !           198:        {
        !           199:            if (((*s_etat_processus)
        !           200:                    .definitions_chainees[position_courante + 2] == ' ') ||
        !           201:                    ((*s_etat_processus).definitions_chainees
        !           202:                    [position_courante + 2] == d_code_fin_chaine))
        !           203:            {
        !           204:                if (niveau_definition == 0)
        !           205:                {
        !           206:                    (*s_etat_processus).erreur_compilation =
        !           207:                            d_ec_niveau_definition_negatif;
        !           208:                    return(d_erreur);
        !           209:                }
        !           210:                else
        !           211:                {
        !           212:                    niveau_definition--;
        !           213:                    fermeture_definition = d_vrai;
        !           214:                    position_courante++;
        !           215:                }
        !           216:            }
        !           217:        }
        !           218: 
        !           219:        if ((niveau_definition == 0) && (guillemet_ouvert == d_faux) &&
        !           220:                (caractere_courant != ' ') && (fermeture_definition == d_faux))
        !           221:        {
        !           222:            if (position_debut_nom_definition_valide == d_faux)
        !           223:            {
        !           224:                position_debut_nom_definition_valide = d_vrai;
        !           225:                position_debut_nom_definition = position_courante;
        !           226:            }
        !           227:        }
        !           228: 
        !           229:        if (((niveau_definition == 1) && (ouverture_definition == d_vrai)) &&
        !           230:                (position_debut_nom_definition_valide == d_vrai))
        !           231:        {
        !           232:            position_fin_nom_definition = position_courante - 1;
        !           233:            position_debut_nom_definition_valide = d_faux;
        !           234: 
        !           235:            while((*s_etat_processus).definitions_chainees
        !           236:                    [position_fin_nom_definition] == ' ')
        !           237:            {
        !           238:                position_fin_nom_definition--;
        !           239:            }
        !           240: 
        !           241:            i = position_debut_nom_definition;
        !           242: 
        !           243:            while(i <= position_fin_nom_definition)
        !           244:            {
        !           245:                if ((*s_etat_processus).definitions_chainees[i] == ' ')
        !           246:                {
        !           247:                    (*s_etat_processus).erreur_compilation =
        !           248:                            d_ec_nom_definition_invalide;
        !           249:                    return(d_erreur);
        !           250:                }
        !           251:                else
        !           252:                {
        !           253:                    i++;
        !           254:                }
        !           255:            }
        !           256: 
        !           257:            s_objet = allocation(s_etat_processus, ADR);
        !           258:            s_variable = (struct_variable *)
        !           259:                    malloc(sizeof(struct_variable));
        !           260:            adresse = (*s_objet).objet;
        !           261:            definition = (unsigned char *) malloc(
        !           262:                    (position_fin_nom_definition -
        !           263:                    position_debut_nom_definition + 2) *
        !           264:                    sizeof(unsigned char));
        !           265: 
        !           266:            if ((s_objet == NULL) || (s_variable == NULL) ||
        !           267:                    (adresse == NULL) || definition == NULL)
        !           268:            {
        !           269:                (*s_etat_processus).erreur_systeme =
        !           270:                        d_es_allocation_memoire;
        !           271:                return(d_erreur);
        !           272:            }
        !           273:            else
        !           274:            {
        !           275:                (*adresse) = position_fin_nom_definition + 1;
        !           276: 
        !           277:                (*s_variable).nom = definition;
        !           278:                (*s_variable).niveau = (*s_etat_processus).niveau_courant;
        !           279:                (*s_variable).objet = s_objet;
        !           280: 
        !           281:                i = position_debut_nom_definition;
        !           282: 
        !           283:                while(i <= position_fin_nom_definition)
        !           284:                {
        !           285:                    *(definition++) = (*s_etat_processus)
        !           286:                            .definitions_chainees[i++];
        !           287:                }
        !           288: 
        !           289:                *definition = d_code_fin_chaine;
        !           290: 
        !           291:                if (recherche_variable(s_etat_processus, (*s_variable).nom)
        !           292:                        == d_vrai)
        !           293:                {
        !           294:                    if ((*s_etat_processus).langue == 'F')
        !           295:                    {
        !           296:                        printf("+++Attention : Plusieurs définitions de"
        !           297:                                " même nom\n");
        !           298:                    }
        !           299:                    else
        !           300:                    {
        !           301:                        printf("+++Warning : Same name for several"
        !           302:                                " definitions\n");
        !           303:                    }
        !           304: 
        !           305:                    fflush(stdout);
        !           306:                    return(d_erreur);
        !           307:                }
        !           308: 
        !           309:                (*s_etat_processus).erreur_systeme = d_es;
        !           310:                creation_variable(s_etat_processus, s_variable, 'V', 'P');
        !           311: 
        !           312:                if ((*s_etat_processus).erreur_systeme != d_es)
        !           313:                {
        !           314:                    free(s_variable);
        !           315: 
        !           316:                    return(d_erreur);
        !           317:                }
        !           318: 
        !           319:                if ((*s_etat_processus).debug == d_vrai)
        !           320:                    if (((*s_etat_processus).type_debug & d_debug_analyse) != 0)
        !           321:                {
        !           322:                    if ((*s_etat_processus).langue == 'F')
        !           323:                    {
        !           324:                        printf("[%d] Compilation : Définition %s ($ %016lX) "
        !           325:                                "\n", (int) getpid(), (*s_variable).nom,
        !           326:                                (*adresse));
        !           327:                    }
        !           328:                    else
        !           329:                    {
        !           330:                        printf("[%d] Compilation : %s definition ($ %016lX) "
        !           331:                                "\n", (int) getpid(), (*s_variable).nom,
        !           332:                                (*adresse));
        !           333:                    }
        !           334: 
        !           335:                    fflush(stdout);
        !           336:                }
        !           337:            }
        !           338: 
        !           339:            free(s_variable);
        !           340:        }
        !           341: 
        !           342:        position_courante++;
        !           343:    }
        !           344: 
        !           345:    return(analyse_syntaxique(s_etat_processus));
        !           346: }
        !           347: 
        !           348: 
        !           349: /*
        !           350: ================================================================================
        !           351:   Procédure de d'analyse syntaxique du source
        !           352: ================================================================================
        !           353:   Entrées :
        !           354: --------------------------------------------------------------------------------
        !           355:   Sorties :
        !           356:    - renvoi    :   erreur
        !           357: --------------------------------------------------------------------------------
        !           358:   Effets de bord :
        !           359: ================================================================================
        !           360: */
        !           361: 
        !           362: logical1
        !           363: analyse_syntaxique(struct_processus *s_etat_processus)
        !           364: {
        !           365:    enum t_condition    { AN_IF = 1, AN_IFERR, AN_THEN, AN_ELSE, AN_ELSEIF,
        !           366:                        AN_END, AN_DO, AN_UNTIL, AN_WHILE, AN_REPEAT, AN_SELECT,
        !           367:                        AN_CASE, AN_DEFAULT, AN_UP, AN_DOWN, AN_FOR, AN_START,
        !           368:                        AN_NEXT, AN_STEP };
        !           369: 
        !           370:    unsigned char       *instruction;
        !           371:    unsigned char       registre;
        !           372: 
        !           373:    typedef struct pile
        !           374:    {
        !           375:        enum t_condition    condition;
        !           376:        struct pile         *suivant;
        !           377:    } struct_pile_analyse;
        !           378: 
        !           379:    struct_pile_analyse     *l_base_pile;
        !           380:    struct_pile_analyse     *l_nouvelle_base_pile;
        !           381: 
        !           382:    inline struct_pile_analyse *
        !           383:    empilement_analyse(struct_pile_analyse *ancienne_base,
        !           384:            enum t_condition condition)
        !           385:    {
        !           386:        struct_pile_analyse     *nouvelle_base;
        !           387: 
        !           388:        if ((nouvelle_base = malloc(sizeof(struct_pile_analyse))) == NULL)
        !           389:        {
        !           390:            return(NULL);
        !           391:        }
        !           392: 
        !           393:        (*nouvelle_base).suivant = ancienne_base;
        !           394:        (*nouvelle_base).condition = condition;
        !           395: 
        !           396:        return(nouvelle_base);
        !           397:    }
        !           398: 
        !           399:    inline struct_pile_analyse *
        !           400:    depilement_analyse(struct_pile_analyse *ancienne_base)
        !           401:    {
        !           402:        struct_pile_analyse     *nouvelle_base;
        !           403: 
        !           404:        if (ancienne_base == NULL)
        !           405:        {
        !           406:            return(NULL);
        !           407:        }
        !           408: 
        !           409:        nouvelle_base = (*ancienne_base).suivant;
        !           410:        free(ancienne_base);
        !           411: 
        !           412:        return(nouvelle_base);
        !           413:    }
        !           414: 
        !           415:    inline logical1
        !           416:    test_analyse(struct_pile_analyse *l_base_pile, enum t_condition condition)
        !           417:    {
        !           418:        if (l_base_pile == NULL)
        !           419:        {
        !           420:            return(d_faux);
        !           421:        }
        !           422: 
        !           423:        return(((*l_base_pile).condition == condition) ? d_vrai : d_faux);
        !           424:    }
        !           425: 
        !           426:    inline void
        !           427:    liberation_analyse(struct_pile_analyse *l_base_pile)
        !           428:    {
        !           429:        struct_pile_analyse     *l_nouvelle_base_pile;
        !           430: 
        !           431:        while(l_base_pile != NULL)
        !           432:        {
        !           433:            l_nouvelle_base_pile = (*l_base_pile).suivant;
        !           434:            free(l_base_pile);
        !           435:            l_base_pile = l_nouvelle_base_pile;
        !           436:        }
        !           437: 
        !           438:        return;
        !           439:    }
        !           440: 
        !           441:    l_base_pile = NULL;
        !           442:    l_nouvelle_base_pile = NULL;
        !           443: 
        !           444:    if ((*s_etat_processus).debug == d_vrai)
        !           445:        if (((*s_etat_processus).type_debug & d_debug_analyse) != 0)
        !           446:    {
        !           447:        if ((*s_etat_processus).langue == 'F')
        !           448:        {
        !           449:            printf("[%d] Analyse\n", (int) getpid());
        !           450:        }
        !           451:        else
        !           452:        {
        !           453:            printf("[%d] Analysis\n", (int) getpid());
        !           454:        }
        !           455: 
        !           456:        fflush(stdout);
        !           457:    }
        !           458: 
        !           459:    (*s_etat_processus).position_courante = 0;
        !           460:    registre = (*s_etat_processus).autorisation_empilement_programme;
        !           461:    (*s_etat_processus).autorisation_empilement_programme = 'N';
        !           462: 
        !           463: /*
        !           464: --------------------------------------------------------------------------------
        !           465:   Analyse structurelle
        !           466: --------------------------------------------------------------------------------
        !           467: */
        !           468: 
        !           469:    while((*s_etat_processus).definitions_chainees
        !           470:            [(*s_etat_processus).position_courante] != d_code_fin_chaine)
        !           471:    {
        !           472:        if (recherche_instruction_suivante(s_etat_processus) !=
        !           473:                d_absence_erreur)
        !           474:        {
        !           475:            liberation_analyse(l_base_pile);
        !           476: 
        !           477:            (*s_etat_processus).autorisation_empilement_programme = registre;
        !           478:            return(d_erreur);
        !           479:        }
        !           480: 
        !           481:        if ((instruction = conversion_majuscule(
        !           482:                (*s_etat_processus).instruction_courante)) == NULL)
        !           483:        {
        !           484:            liberation_analyse(l_base_pile);
        !           485: 
        !           486:            (*s_etat_processus).autorisation_empilement_programme = registre;
        !           487:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !           488:            return(d_erreur);
        !           489:        }
        !           490: 
        !           491:        if (strcmp(instruction, "IF") == 0)
        !           492:        {
        !           493:            if ((l_nouvelle_base_pile = empilement_analyse(l_base_pile, AN_IF))
        !           494:                    == NULL)
        !           495:            {
        !           496:                liberation_analyse(l_base_pile);
        !           497: 
        !           498:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !           499:                return(d_erreur);
        !           500:            }
        !           501: 
        !           502:            l_base_pile = l_nouvelle_base_pile;
        !           503:            (*l_base_pile).condition = AN_IF;
        !           504:        }
        !           505:        else if (strcmp(instruction, "IFERR") == 0)
        !           506:        {
        !           507:            if ((l_nouvelle_base_pile = empilement_analyse(l_base_pile,
        !           508:                    AN_IFERR)) == NULL)
        !           509:            {
        !           510:                liberation_analyse(l_base_pile);
        !           511: 
        !           512:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !           513:                return(d_erreur);
        !           514:            }
        !           515: 
        !           516:            l_base_pile = l_nouvelle_base_pile;
        !           517:        }
        !           518:        else if (strcmp(instruction, "THEN") == 0)
        !           519:        {
        !           520:            if ((test_analyse(l_base_pile, AN_IF) == d_faux) &&
        !           521:                    (test_analyse(l_base_pile, AN_ELSEIF) == d_faux) &&
        !           522:                    (test_analyse(l_base_pile, AN_CASE) == d_faux) &&
        !           523:                    (test_analyse(l_base_pile, AN_IFERR) == d_faux))
        !           524:            {
        !           525:                liberation_analyse(l_base_pile);
        !           526: 
        !           527:                (*s_etat_processus).autorisation_empilement_programme =
        !           528:                        registre;
        !           529: 
        !           530:                (*s_etat_processus).erreur_compilation =
        !           531:                        d_ec_erreur_instruction_then;
        !           532:                return(d_erreur);
        !           533:            }
        !           534: 
        !           535:            (*l_base_pile).condition = AN_THEN;
        !           536:        }
        !           537:        else if (strcmp(instruction, "ELSE") == 0)
        !           538:        {
        !           539:            if (test_analyse(l_base_pile, AN_THEN) == d_faux)
        !           540:            {
        !           541:                liberation_analyse(l_base_pile);
        !           542: 
        !           543:                (*s_etat_processus).autorisation_empilement_programme =
        !           544:                        registre;
        !           545: 
        !           546:                (*s_etat_processus).erreur_compilation =
        !           547:                        d_ec_erreur_instruction_else;
        !           548:                return(d_erreur);
        !           549:            }
        !           550: 
        !           551:            (*l_base_pile).condition = AN_ELSE;
        !           552:        }
        !           553:        else if (strcmp(instruction, "ELSEIF") == 0)
        !           554:        {
        !           555:            if (test_analyse(l_base_pile, AN_THEN) == d_faux)
        !           556:            {
        !           557:                liberation_analyse(l_base_pile);
        !           558: 
        !           559:                (*s_etat_processus).autorisation_empilement_programme =
        !           560:                        registre;
        !           561: 
        !           562:                (*s_etat_processus).erreur_compilation =
        !           563:                        d_ec_erreur_instruction_elseif;
        !           564:                return(d_erreur);
        !           565:            }
        !           566: 
        !           567:            (*l_base_pile).condition = AN_ELSEIF;
        !           568:        }
        !           569:        else if (strcmp(instruction, "END") == 0)
        !           570:        {
        !           571:            if ((test_analyse(l_base_pile, AN_UNTIL) == d_faux) &&
        !           572:                    (test_analyse(l_base_pile, AN_REPEAT) == d_faux) &&
        !           573:                    (test_analyse(l_base_pile, AN_DEFAULT) == d_faux) &&
        !           574:                    (test_analyse(l_base_pile, AN_SELECT) == d_faux) &&
        !           575:                    (test_analyse(l_base_pile, AN_THEN) == d_faux) &&
        !           576:                    (test_analyse(l_base_pile, AN_ELSE) == d_faux))
        !           577:            {
        !           578:                liberation_analyse(l_base_pile);
        !           579: 
        !           580:                (*s_etat_processus).autorisation_empilement_programme =
        !           581:                        registre;
        !           582: 
        !           583:                (*s_etat_processus).erreur_compilation =
        !           584:                        d_ec_erreur_instruction_end;
        !           585:                return(d_erreur);
        !           586:            }
        !           587: 
        !           588:            l_base_pile = depilement_analyse(l_base_pile);
        !           589:        }
        !           590:        else if (strcmp(instruction, "DO") == 0)
        !           591:        {
        !           592:            if ((l_nouvelle_base_pile = empilement_analyse(l_base_pile, AN_DO))
        !           593:                    == NULL)
        !           594:            {
        !           595:                liberation_analyse(l_base_pile);
        !           596: 
        !           597:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !           598:                return(d_erreur);
        !           599:            }
        !           600: 
        !           601:            l_base_pile = l_nouvelle_base_pile;
        !           602:        }
        !           603:        else if (strcmp(instruction, "UNTIL") == 0)
        !           604:        {
        !           605:            if (test_analyse(l_base_pile, AN_DO) == d_faux)
        !           606:            {
        !           607:                liberation_analyse(l_base_pile);
        !           608: 
        !           609:                (*s_etat_processus).autorisation_empilement_programme =
        !           610:                        registre;
        !           611: 
        !           612:                (*s_etat_processus).erreur_compilation =
        !           613:                        d_ec_erreur_instruction_until;
        !           614:                return(d_erreur);
        !           615:            }
        !           616: 
        !           617:            (*l_base_pile).condition = AN_UNTIL;
        !           618:        }
        !           619:        else if (strcmp(instruction, "WHILE") == 0)
        !           620:        {
        !           621:            if ((l_nouvelle_base_pile = empilement_analyse(l_base_pile,
        !           622:                    AN_WHILE)) == NULL)
        !           623:            {
        !           624:                liberation_analyse(l_base_pile);
        !           625: 
        !           626:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !           627:                return(d_erreur);
        !           628:            }
        !           629: 
        !           630:            l_base_pile = l_nouvelle_base_pile;
        !           631:        }
        !           632:        else if (strcmp(instruction, "REPEAT") == 0)
        !           633:        {
        !           634:            if (test_analyse(l_base_pile, AN_WHILE) == d_faux)
        !           635:            {
        !           636:                liberation_analyse(l_base_pile);
        !           637: 
        !           638:                (*s_etat_processus).autorisation_empilement_programme =
        !           639:                        registre;
        !           640: 
        !           641:                (*s_etat_processus).erreur_compilation =
        !           642:                        d_ec_erreur_instruction_while;
        !           643:                return(d_erreur);
        !           644:            }
        !           645: 
        !           646:            (*l_base_pile).condition = AN_REPEAT;
        !           647:        }
        !           648:        else if (strcmp(instruction, "SELECT") == 0)
        !           649:        {
        !           650:            if ((l_nouvelle_base_pile = empilement_analyse(l_base_pile,
        !           651:                    AN_SELECT)) == NULL)
        !           652:            {
        !           653:                liberation_analyse(l_base_pile);
        !           654: 
        !           655:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !           656:                return(d_erreur);
        !           657:            }
        !           658: 
        !           659:            l_base_pile = l_nouvelle_base_pile;
        !           660:        }
        !           661:        else if (strcmp(instruction, "CASE") == 0)
        !           662:        {
        !           663:            if (test_analyse(l_base_pile, AN_SELECT) == d_faux)
        !           664:            {
        !           665:                liberation_analyse(l_base_pile);
        !           666: 
        !           667:                (*s_etat_processus).autorisation_empilement_programme =
        !           668:                        registre;
        !           669: 
        !           670:                (*s_etat_processus).erreur_compilation =
        !           671:                        d_ec_erreur_instruction_case;
        !           672:                return(d_erreur);
        !           673:            }
        !           674: 
        !           675:            if ((l_nouvelle_base_pile = empilement_analyse(l_base_pile,
        !           676:                    AN_CASE)) == NULL)
        !           677:            {
        !           678:                liberation_analyse(l_base_pile);
        !           679: 
        !           680:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !           681:                return(d_erreur);
        !           682:            }
        !           683: 
        !           684:            l_base_pile = l_nouvelle_base_pile;
        !           685:        }
        !           686:        else if (strcmp(instruction, "DEFAULT") == 0)
        !           687:        {
        !           688:            if (test_analyse(l_base_pile, AN_SELECT) == d_faux)
        !           689:            {
        !           690:                liberation_analyse(l_base_pile);
        !           691: 
        !           692:                (*s_etat_processus).autorisation_empilement_programme =
        !           693:                        registre;
        !           694: 
        !           695:                (*s_etat_processus).erreur_compilation =
        !           696:                        d_ec_erreur_instruction_select;
        !           697:                return(d_erreur);
        !           698:            }
        !           699: 
        !           700:            (*l_base_pile).condition = AN_DEFAULT;
        !           701:        }
        !           702:        else if (strcmp(instruction, "<<") == 0)
        !           703:        {
        !           704:            if ((l_nouvelle_base_pile = empilement_analyse(l_base_pile, AN_UP))
        !           705:                    == NULL)
        !           706:            {
        !           707:                liberation_analyse(l_base_pile);
        !           708: 
        !           709:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !           710:                return(d_erreur);
        !           711:            }
        !           712: 
        !           713:            l_base_pile = l_nouvelle_base_pile;
        !           714:        }
        !           715:        else if (strcmp(instruction, ">>") == 0)
        !           716:        {
        !           717:            if (test_analyse(l_base_pile, AN_UP) == d_faux)
        !           718:            {
        !           719:                liberation_analyse(l_base_pile);
        !           720: 
        !           721:                (*s_etat_processus).autorisation_empilement_programme =
        !           722:                        registre;
        !           723: 
        !           724:                (*s_etat_processus).erreur_compilation =
        !           725:                        d_ec_source_incoherent;
        !           726:                return(d_erreur);
        !           727:            }
        !           728: 
        !           729:            l_base_pile = depilement_analyse(l_base_pile);
        !           730:        }
        !           731:        else if (strcmp(instruction, "FOR") == 0)
        !           732:        {
        !           733:            if ((l_nouvelle_base_pile = empilement_analyse(l_base_pile, AN_FOR))
        !           734:                    == NULL)
        !           735:            {
        !           736:                liberation_analyse(l_base_pile);
        !           737: 
        !           738:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !           739:                return(d_erreur);
        !           740:            }
        !           741: 
        !           742:            l_base_pile = l_nouvelle_base_pile;
        !           743:        }
        !           744:        else if (strcmp(instruction, "START") == 0)
        !           745:        {
        !           746:            if ((l_nouvelle_base_pile = empilement_analyse(l_base_pile,
        !           747:                    AN_START)) == NULL)
        !           748:            {
        !           749:                liberation_analyse(l_base_pile);
        !           750: 
        !           751:                (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !           752:                return(d_erreur);
        !           753:            }
        !           754: 
        !           755:            l_base_pile = l_nouvelle_base_pile;
        !           756:        }
        !           757:        else if (strcmp(instruction, "NEXT") == 0)
        !           758:        {
        !           759:            if ((test_analyse(l_base_pile, AN_FOR) == d_faux) &&
        !           760:                    (test_analyse(l_base_pile, AN_START) == d_faux))
        !           761:            {
        !           762:                liberation_analyse(l_base_pile);
        !           763: 
        !           764:                (*s_etat_processus).autorisation_empilement_programme =
        !           765:                        registre;
        !           766: 
        !           767:                (*s_etat_processus).erreur_compilation =
        !           768:                        d_ec_erreur_boucle_definie;
        !           769:                return(d_erreur);
        !           770:            }
        !           771: 
        !           772:            l_base_pile = depilement_analyse(l_base_pile);
        !           773:        }
        !           774:        else if (strcmp(instruction, "STEP") == 0)
        !           775:        {
        !           776:            if ((test_analyse(l_base_pile, AN_FOR) == d_faux) &&
        !           777:                    (test_analyse(l_base_pile, AN_START) == d_faux))
        !           778:            {
        !           779:                liberation_analyse(l_base_pile);
        !           780: 
        !           781:                (*s_etat_processus).autorisation_empilement_programme =
        !           782:                        registre;
        !           783: 
        !           784:                (*s_etat_processus).erreur_compilation =
        !           785:                        d_ec_erreur_boucle_definie;
        !           786:                return(d_erreur);
        !           787:            }
        !           788: 
        !           789:            l_base_pile = depilement_analyse(l_base_pile);
        !           790:        }
        !           791: 
        !           792:        // Invalidation de l'instruction courante dans le fichier rpl-core
        !           793:        free((*s_etat_processus).instruction_courante);
        !           794:        (*s_etat_processus).instruction_courante = NULL;
        !           795:        free(instruction);
        !           796:    }
        !           797: 
        !           798:    (*s_etat_processus).autorisation_empilement_programme = registre;
        !           799: 
        !           800:    if (l_base_pile != NULL)
        !           801:    {
        !           802:        liberation_analyse(l_base_pile);
        !           803: 
        !           804:        (*s_etat_processus).autorisation_empilement_programme = registre;
        !           805:        (*s_etat_processus).erreur_compilation = d_ec_source_incoherent;
        !           806:        return(d_erreur);
        !           807:    }
        !           808: 
        !           809:    return(d_absence_erreur);
        !           810: }
        !           811: 
        !           812: 
        !           813: /*
        !           814: ================================================================================
        !           815:   Routine d'échange de deux variables
        !           816: ================================================================================
        !           817:   Entrées :
        !           818:    -   pointeurs génériques sur les deux variables,
        !           819:    -   longueur en octet des objets à permuter.
        !           820: --------------------------------------------------------------------------------
        !           821:   Sorties : idem.
        !           822: --------------------------------------------------------------------------------
        !           823:   Effets de bord : néant.
        !           824: ================================================================================
        !           825: */
        !           826: 
        !           827: void
        !           828: swap(void *variable_1, void *variable_2, unsigned long taille)
        !           829: {
        !           830:    register unsigned char      *t_var_1;
        !           831:    register unsigned char      *t_var_2;
        !           832:    register unsigned char      variable_temporaire;
        !           833: 
        !           834:    register signed long        i;
        !           835: 
        !           836:    t_var_1 = (unsigned char *) variable_1;
        !           837:    t_var_2 = (unsigned char *) variable_2;
        !           838: 
        !           839:    i = taille;
        !           840: 
        !           841:    for(i--; i >= 0; i--)
        !           842:    {
        !           843:        variable_temporaire = t_var_1[i];
        !           844:        t_var_1[i] = t_var_2[i];
        !           845:        t_var_2[i] = variable_temporaire;
        !           846:    }
        !           847: }
        !           848: 
        !           849: 
        !           850: /*
        !           851: ================================================================================
        !           852:   Routine recherchant l'instruction suivante dans le programme compilé
        !           853: ================================================================================
        !           854:   Entrée :
        !           855: --------------------------------------------------------------------------------
        !           856:   Sortie :
        !           857: --------------------------------------------------------------------------------
        !           858:   Effets de bord : néant.
        !           859: ================================================================================
        !           860: */
        !           861: 
        !           862: logical1
        !           863: recherche_instruction_suivante(struct_processus *s_etat_processus)
        !           864: {
        !           865:    logical1                    drapeau_fin_objet;
        !           866:    logical1                    erreur;
        !           867:    logical1                    erreur_analyse;
        !           868:    logical1                    erreur_format;
        !           869: 
        !           870:    unsigned char               base_binaire;
        !           871:    unsigned char               *pointeur_caractere_courant;
        !           872:    unsigned char               *pointeur_caractere_destination;
        !           873:    unsigned char               *pointeur_debut_instruction;
        !           874:    unsigned char               *pointeur_fin_instruction;
        !           875: 
        !           876:    signed long                 niveau;
        !           877:    signed long                 niveau_annexe;
        !           878: 
        !           879:    erreur_analyse = d_ex;
        !           880:    erreur_format = d_ex;
        !           881:    erreur = d_absence_erreur;
        !           882: 
        !           883:    drapeau_fin_objet = d_faux;
        !           884:    niveau = 0;
        !           885: 
        !           886:    pointeur_caractere_courant = (*s_etat_processus).definitions_chainees +
        !           887:            (*s_etat_processus).position_courante;
        !           888: 
        !           889:    while(((*pointeur_caractere_courant) == d_code_espace) &&
        !           890:            ((*pointeur_caractere_courant) != d_code_fin_chaine))
        !           891:    {
        !           892:        pointeur_caractere_courant++;
        !           893:    }
        !           894: 
        !           895:    if ((*pointeur_caractere_courant) == d_code_fin_chaine)
        !           896:    {
        !           897:        (*s_etat_processus).instruction_courante = (unsigned char *)
        !           898:                malloc(sizeof(unsigned char));
        !           899: 
        !           900:        if ((*s_etat_processus).instruction_courante == NULL)
        !           901:        {
        !           902:            erreur = d_erreur;
        !           903:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !           904:        }
        !           905:        else
        !           906:        {
        !           907:            erreur = d_absence_erreur;
        !           908:            (*(*s_etat_processus).instruction_courante) = d_code_fin_chaine;
        !           909:            (*s_etat_processus).position_courante = pointeur_caractere_courant
        !           910:                    - (*s_etat_processus).definitions_chainees;
        !           911:        }
        !           912: 
        !           913:        return(erreur);
        !           914:    }
        !           915: 
        !           916:    pointeur_debut_instruction = pointeur_caractere_courant;
        !           917: 
        !           918:    while(((*pointeur_caractere_courant) != d_code_espace) &&
        !           919:            ((*pointeur_caractere_courant) != d_code_fin_chaine) &&
        !           920:            (drapeau_fin_objet == d_faux) &&
        !           921:            (erreur_analyse == d_ex) &&
        !           922:            (erreur_format == d_ex))
        !           923:    {
        !           924:        switch(*pointeur_caractere_courant++)
        !           925:        {
        !           926:            case ']' :
        !           927:            case '}' :
        !           928:            case ')' :
        !           929:            {
        !           930:                erreur_format = d_ex_syntaxe;
        !           931:                break;
        !           932:            }
        !           933: 
        !           934:            case '"' :
        !           935:            {
        !           936:                if (pointeur_debut_instruction !=
        !           937:                        (pointeur_caractere_courant - 1))
        !           938:                {
        !           939:                    erreur_format = d_ex_syntaxe;
        !           940:                }
        !           941: 
        !           942:                while((*pointeur_caractere_courant != '"') &&
        !           943:                        ((*pointeur_caractere_courant) != d_code_fin_chaine))
        !           944:                {
        !           945:                    if (*pointeur_caractere_courant == '\\')
        !           946:                    {
        !           947:                        pointeur_caractere_courant++;
        !           948: 
        !           949:                        switch(*pointeur_caractere_courant)
        !           950:                        {
        !           951:                            case '\\' :
        !           952:                            case '"' :
        !           953:                            {
        !           954:                                pointeur_caractere_courant++;
        !           955:                                break;
        !           956:                            }
        !           957:                        }
        !           958:                    }
        !           959:                    else
        !           960:                    {
        !           961:                        pointeur_caractere_courant++;
        !           962:                    }
        !           963:                }
        !           964: 
        !           965:                if ((*pointeur_caractere_courant) != '"')
        !           966:                {
        !           967:                    erreur_analyse = d_ex_syntaxe;
        !           968:                }
        !           969: 
        !           970:                if (erreur_analyse == d_ex)
        !           971:                {
        !           972:                    pointeur_caractere_courant++;
        !           973:                }
        !           974: 
        !           975:                drapeau_fin_objet = d_vrai;
        !           976:                break;
        !           977:            }
        !           978: 
        !           979:            case '\'' :
        !           980:            {
        !           981:                if (pointeur_debut_instruction !=
        !           982:                        (pointeur_caractere_courant - 1))
        !           983:                {
        !           984:                    erreur_format = d_ex_syntaxe;
        !           985:                }
        !           986: 
        !           987:                while(((*pointeur_caractere_courant) != '\'') &&
        !           988:                        ((*pointeur_caractere_courant) != d_code_fin_chaine))
        !           989:                {
        !           990:                    if ((*pointeur_caractere_courant) == '(')
        !           991:                    {
        !           992:                        niveau++;
        !           993:                    }
        !           994:                    else if ((*pointeur_caractere_courant) == ')')
        !           995:                    {
        !           996:                        niveau--;
        !           997:                    }
        !           998: 
        !           999:                    pointeur_caractere_courant++;
        !          1000:                }
        !          1001: 
        !          1002:                if ((*pointeur_caractere_courant) != '\'')
        !          1003:                {
        !          1004:                    erreur_analyse = d_ex_syntaxe;
        !          1005:                }
        !          1006:                else if (niveau != 0)
        !          1007:                {
        !          1008:                    erreur_analyse = d_ex_syntaxe;
        !          1009:                }
        !          1010: 
        !          1011:                if (erreur_analyse == d_ex)
        !          1012:                {
        !          1013:                    pointeur_caractere_courant++;
        !          1014:                }
        !          1015: 
        !          1016:                drapeau_fin_objet = d_vrai;
        !          1017:                break;
        !          1018:            }
        !          1019: 
        !          1020:            case '(' :
        !          1021:            {
        !          1022:                if (pointeur_debut_instruction !=
        !          1023:                        (pointeur_caractere_courant - 1))
        !          1024:                {
        !          1025:                    erreur_format = d_ex_syntaxe;
        !          1026:                }
        !          1027: 
        !          1028:                while(((*pointeur_caractere_courant) != ')') &&
        !          1029:                        ((*pointeur_caractere_courant) != d_code_fin_chaine)
        !          1030:                        && (erreur_analyse == d_ex))
        !          1031:                {
        !          1032:                    switch(*pointeur_caractere_courant)
        !          1033:                    {
        !          1034:                        case '0' :
        !          1035:                        case '1' :
        !          1036:                        case '2' :
        !          1037:                        case '3' :
        !          1038:                        case '4' :
        !          1039:                        case '5' :
        !          1040:                        case '6' :
        !          1041:                        case '7' :
        !          1042:                        case '8' :
        !          1043:                        case '9' :
        !          1044:                        case 'e' :
        !          1045:                        case 'E' :
        !          1046:                        case ',' :
        !          1047:                        case '.' :
        !          1048:                        case ' ' :
        !          1049:                        case '-' :
        !          1050:                        case '+' :
        !          1051:                        case ')' :
        !          1052:                        {
        !          1053:                            break;
        !          1054:                        }
        !          1055: 
        !          1056:                        default :
        !          1057:                        {
        !          1058:                            erreur_analyse = d_ex_syntaxe;
        !          1059:                            break;
        !          1060:                        }
        !          1061:                    }
        !          1062: 
        !          1063:                    pointeur_caractere_courant++;
        !          1064:                }
        !          1065: 
        !          1066:                if ((*pointeur_caractere_courant) != ')')
        !          1067:                {
        !          1068:                    erreur_analyse = d_ex_syntaxe;
        !          1069:                }
        !          1070: 
        !          1071:                if (erreur_analyse == d_ex)
        !          1072:                {
        !          1073:                    pointeur_caractere_courant++;
        !          1074:                }
        !          1075: 
        !          1076:                drapeau_fin_objet = d_vrai;
        !          1077:                break;
        !          1078:            }
        !          1079: 
        !          1080:            case '#' :
        !          1081:            {
        !          1082:                if (pointeur_debut_instruction !=
        !          1083:                        (pointeur_caractere_courant - 1))
        !          1084:                {
        !          1085:                    erreur_format = d_ex_syntaxe;
        !          1086:                }
        !          1087: 
        !          1088:                while(((*pointeur_caractere_courant) != 'b') &&
        !          1089:                        ((*pointeur_caractere_courant) != 'o') &&
        !          1090:                        ((*pointeur_caractere_courant) != 'd') &&
        !          1091:                        ((*pointeur_caractere_courant) != 'h') &&
        !          1092:                        ((*pointeur_caractere_courant) !=
        !          1093:                        d_code_fin_chaine) &&
        !          1094:                        (erreur_analyse == d_ex))
        !          1095:                {
        !          1096:                    switch(*pointeur_caractere_courant)
        !          1097:                    {
        !          1098:                        case ' ' :
        !          1099:                        case '0' :
        !          1100:                        case '1' :
        !          1101:                        case '2' :
        !          1102:                        case '3' :
        !          1103:                        case '4' :
        !          1104:                        case '5' :
        !          1105:                        case '6' :
        !          1106:                        case '7' :
        !          1107:                        case '8' :
        !          1108:                        case '9' :
        !          1109:                        case 'A' :
        !          1110:                        case 'B' :
        !          1111:                        case 'C' :
        !          1112:                        case 'D' :
        !          1113:                        case 'E' :
        !          1114:                        case 'F' :
        !          1115:                        case 'b' :
        !          1116:                        case 'o' :
        !          1117:                        case 'd' :
        !          1118:                        case 'h' :
        !          1119:                        {
        !          1120:                            break;
        !          1121:                        }
        !          1122: 
        !          1123:                        default :
        !          1124:                        {
        !          1125:                            erreur_analyse = d_ex_syntaxe;
        !          1126:                            break;
        !          1127:                        }
        !          1128:                    }
        !          1129: 
        !          1130:                    pointeur_caractere_courant++;
        !          1131:                }
        !          1132: 
        !          1133:                base_binaire = (*pointeur_caractere_courant);
        !          1134:                pointeur_caractere_courant++;
        !          1135: 
        !          1136:                if (((*pointeur_caractere_courant) != d_code_fin_chaine) &&
        !          1137:                        ((*pointeur_caractere_courant) != ' '))
        !          1138:                {
        !          1139:                    erreur_analyse = d_ex_syntaxe;
        !          1140:                }
        !          1141:                else
        !          1142:                {
        !          1143:                    pointeur_caractere_courant = pointeur_debut_instruction + 1;
        !          1144: 
        !          1145:                    switch(base_binaire)
        !          1146:                    {
        !          1147:                        case 'b' :
        !          1148:                        case 'o' :
        !          1149:                        case 'd' :
        !          1150:                        case 'h' :
        !          1151:                        {
        !          1152:                            break;
        !          1153:                        }
        !          1154: 
        !          1155:                        default :
        !          1156:                        {
        !          1157:                            erreur_analyse = d_ex_syntaxe;
        !          1158:                            break;
        !          1159:                        }
        !          1160:                    }
        !          1161:                }
        !          1162: 
        !          1163:                while(((*pointeur_caractere_courant) != base_binaire) &&
        !          1164:                        ((*pointeur_caractere_courant) != d_code_fin_chaine) &&
        !          1165:                        (erreur_analyse == d_ex))
        !          1166:                {
        !          1167:                    if (base_binaire == 'b')
        !          1168:                    {
        !          1169:                        switch(*pointeur_caractere_courant)
        !          1170:                        {
        !          1171:                            case ' ' :
        !          1172:                            case '0' :
        !          1173:                            case '1' :
        !          1174:                            {
        !          1175:                                break;
        !          1176:                            }
        !          1177: 
        !          1178:                            default :
        !          1179:                            {
        !          1180:                                erreur_analyse = d_ex_syntaxe;
        !          1181:                                break;
        !          1182:                            }
        !          1183:                        }
        !          1184:                    }
        !          1185:                    else if (base_binaire == 'o')
        !          1186:                    {
        !          1187:                        switch(*pointeur_caractere_courant)
        !          1188:                        {
        !          1189:                            case ' ' :
        !          1190:                            case '0' :
        !          1191:                            case '1' :
        !          1192:                            case '2' :
        !          1193:                            case '3' :
        !          1194:                            case '4' :
        !          1195:                            case '5' :
        !          1196:                            case '6' :
        !          1197:                            case '7' :
        !          1198:                            {
        !          1199:                                break;
        !          1200:                            }
        !          1201: 
        !          1202:                            default :
        !          1203:                            {
        !          1204:                                erreur_analyse = d_ex_syntaxe;
        !          1205:                                break;
        !          1206:                            }
        !          1207:                        }
        !          1208:                    }
        !          1209:                    else if (base_binaire == 'd')
        !          1210:                    {
        !          1211:                        switch(*pointeur_caractere_courant)
        !          1212:                        {
        !          1213:                            case ' ' :
        !          1214:                            case '0' :
        !          1215:                            case '1' :
        !          1216:                            case '2' :
        !          1217:                            case '3' :
        !          1218:                            case '4' :
        !          1219:                            case '5' :
        !          1220:                            case '6' :
        !          1221:                            case '7' :
        !          1222:                            case '8' :
        !          1223:                            case '9' :
        !          1224:                            {
        !          1225:                                break;
        !          1226:                            }
        !          1227: 
        !          1228:                            default :
        !          1229:                            {
        !          1230:                                erreur_analyse = d_ex_syntaxe;
        !          1231:                                break;
        !          1232:                            }
        !          1233:                        }
        !          1234:                    }
        !          1235:                    else if (base_binaire != 'h')
        !          1236:                    {
        !          1237:                        erreur_analyse = d_ex_syntaxe;
        !          1238:                    }
        !          1239: 
        !          1240:                    pointeur_caractere_courant++;
        !          1241:                }
        !          1242: 
        !          1243:                if (erreur_analyse == d_ex)
        !          1244:                {
        !          1245:                    pointeur_caractere_courant++;
        !          1246:                }
        !          1247: 
        !          1248:                drapeau_fin_objet = d_vrai;
        !          1249:                break;
        !          1250:            }
        !          1251: 
        !          1252:            case '{' :
        !          1253:            {
        !          1254:                if (pointeur_debut_instruction !=
        !          1255:                        (pointeur_caractere_courant - 1))
        !          1256:                {
        !          1257:                    erreur_format = d_ex_syntaxe;
        !          1258:                }
        !          1259: 
        !          1260:                niveau = 1;
        !          1261:                niveau_annexe = 0;
        !          1262: 
        !          1263:                while((niveau != 0) && ((*pointeur_caractere_courant) !=
        !          1264:                        d_code_fin_chaine))
        !          1265:                {
        !          1266:                    switch(*pointeur_caractere_courant)
        !          1267:                    {
        !          1268:                        case '{' :
        !          1269:                        {
        !          1270:                            if (niveau_annexe == 0)
        !          1271:                            {
        !          1272:                                niveau++;
        !          1273:                            }
        !          1274:                            else
        !          1275:                            {
        !          1276:                                erreur_analyse = d_ex_syntaxe;
        !          1277:                            }
        !          1278: 
        !          1279:                            break;
        !          1280:                        }
        !          1281: 
        !          1282:                        case '}' :
        !          1283:                        {
        !          1284:                            if (niveau_annexe == 0)
        !          1285:                            {
        !          1286:                                niveau--;
        !          1287:                            }
        !          1288:                            else
        !          1289:                            {
        !          1290:                                erreur_analyse = d_ex_syntaxe;
        !          1291:                            }
        !          1292: 
        !          1293:                            break;
        !          1294:                        }
        !          1295: 
        !          1296:                        case '[' :
        !          1297:                        {
        !          1298:                            niveau_annexe++;
        !          1299: 
        !          1300:                            if (niveau_annexe > 2)
        !          1301:                            {
        !          1302:                                erreur_analyse = d_ex_syntaxe;
        !          1303:                            }
        !          1304: 
        !          1305:                            break;
        !          1306:                        }
        !          1307: 
        !          1308:                        case ']' :
        !          1309:                        {
        !          1310:                            niveau_annexe--;
        !          1311: 
        !          1312:                            if (niveau_annexe < 0)
        !          1313:                            {
        !          1314:                                erreur_analyse = d_ex_syntaxe;
        !          1315:                            }
        !          1316: 
        !          1317:                            break;
        !          1318:                        }
        !          1319: 
        !          1320:                        case '"' :
        !          1321:                        {
        !          1322:                            if (niveau_annexe == 0)
        !          1323:                            {
        !          1324:                                pointeur_caractere_courant++;
        !          1325: 
        !          1326:                                while((*pointeur_caractere_courant != '"') &&
        !          1327:                                        ((*pointeur_caractere_courant) !=
        !          1328:                                        d_code_fin_chaine))
        !          1329:                                {
        !          1330:                                    if (*pointeur_caractere_courant == '\\')
        !          1331:                                    {
        !          1332:                                        pointeur_caractere_courant++;
        !          1333: 
        !          1334:                                        switch(*pointeur_caractere_courant)
        !          1335:                                        {
        !          1336:                                            case '\\' :
        !          1337:                                            case '"' :
        !          1338:                                            {
        !          1339:                                                pointeur_caractere_courant++;
        !          1340:                                                break;
        !          1341:                                            }
        !          1342:                                        }
        !          1343:                                    }
        !          1344:                                    else
        !          1345:                                    {
        !          1346:                                        pointeur_caractere_courant++;
        !          1347:                                    }
        !          1348:                                }
        !          1349:                            }
        !          1350:                            else
        !          1351:                            {
        !          1352:                                erreur_analyse = d_ex_syntaxe;
        !          1353:                            }
        !          1354: 
        !          1355:                            break;
        !          1356:                        }
        !          1357:                    }
        !          1358: 
        !          1359:                    pointeur_caractere_courant++;
        !          1360:                }
        !          1361: 
        !          1362:                if ((niveau != 0) || (niveau_annexe != 0))
        !          1363:                {
        !          1364:                    erreur_analyse = d_ex_syntaxe;
        !          1365:                }
        !          1366: 
        !          1367:                drapeau_fin_objet = d_vrai;
        !          1368:                break;
        !          1369:            }
        !          1370: 
        !          1371:            case '[' :
        !          1372:            {
        !          1373:                if (pointeur_debut_instruction !=
        !          1374:                        (pointeur_caractere_courant - 1))
        !          1375:                {
        !          1376:                    erreur_format = d_ex_syntaxe;
        !          1377:                }
        !          1378: 
        !          1379:                niveau = 1;
        !          1380: 
        !          1381:                while((niveau > 0) && ((*pointeur_caractere_courant) !=
        !          1382:                        d_code_fin_chaine) && (erreur_analyse == d_ex))
        !          1383:                {
        !          1384:                    switch(*pointeur_caractere_courant)
        !          1385:                    {
        !          1386:                        case '[' :
        !          1387:                        {
        !          1388:                            niveau++;
        !          1389:                            break;
        !          1390:                        }
        !          1391: 
        !          1392:                        case ']' :
        !          1393:                        {
        !          1394:                            niveau--;
        !          1395:                            break;
        !          1396:                        }
        !          1397: 
        !          1398:                        case '0' :
        !          1399:                        case '1' :
        !          1400:                        case '2' :
        !          1401:                        case '3' :
        !          1402:                        case '4' :
        !          1403:                        case '5' :
        !          1404:                        case '6' :
        !          1405:                        case '7' :
        !          1406:                        case '8' :
        !          1407:                        case '9' :
        !          1408:                        case '+' :
        !          1409:                        case '-' :
        !          1410:                        case 'e' :
        !          1411:                        case 'E' :
        !          1412:                        case '.' :
        !          1413:                        case ',' :
        !          1414:                        case '(' :
        !          1415:                        case ')' :
        !          1416:                        case ' ' :
        !          1417:                        {
        !          1418:                            break;
        !          1419:                        }
        !          1420: 
        !          1421:                        default :
        !          1422:                        {
        !          1423:                            erreur_analyse = d_ex_syntaxe;
        !          1424:                            break;
        !          1425:                        }
        !          1426:                    }
        !          1427: 
        !          1428:                    if (niveau < 0)
        !          1429:                    {
        !          1430:                        erreur_analyse = d_ex_syntaxe;
        !          1431:                    }
        !          1432:                    else if (niveau > 2)
        !          1433:                    {
        !          1434:                        erreur_format = d_ex_syntaxe;
        !          1435:                    }
        !          1436: 
        !          1437:                    pointeur_caractere_courant++;
        !          1438:                }
        !          1439: 
        !          1440:                if (niveau != 0)
        !          1441:                {
        !          1442:                    erreur_analyse = d_ex_syntaxe;
        !          1443:                }
        !          1444: 
        !          1445:                drapeau_fin_objet = d_vrai;
        !          1446:                break;
        !          1447:            }
        !          1448: 
        !          1449:            case '<' :
        !          1450:            {
        !          1451:                if (((*s_etat_processus).autorisation_empilement_programme
        !          1452:                        == 'Y') && ((*pointeur_caractere_courant) == '<'))
        !          1453:                {
        !          1454:                    if (pointeur_debut_instruction !=
        !          1455:                            (pointeur_caractere_courant - 1))
        !          1456:                    {
        !          1457:                        erreur_format = d_ex_syntaxe;
        !          1458:                    }
        !          1459: 
        !          1460:                    niveau = 1;
        !          1461: 
        !          1462:                    while((niveau != 0) && ((*pointeur_caractere_courant) !=
        !          1463:                            d_code_fin_chaine))
        !          1464:                    {
        !          1465:                        if (((*pointeur_caractere_courant) == '<') &&
        !          1466:                                ((*(pointeur_caractere_courant + 1)) == '<'))
        !          1467:                        {
        !          1468:                            niveau++;
        !          1469:                            pointeur_caractere_courant++;
        !          1470:                        }
        !          1471:                        else if (((*pointeur_caractere_courant) == '>') &&
        !          1472:                                ((*(pointeur_caractere_courant + 1)) == '>'))
        !          1473:                        {
        !          1474:                            niveau--;
        !          1475:                            pointeur_caractere_courant++;
        !          1476:                        }
        !          1477:                        else if ((*pointeur_caractere_courant) == '"')
        !          1478:                        {
        !          1479:                            pointeur_caractere_courant++;
        !          1480: 
        !          1481:                            while((*pointeur_caractere_courant != '"') &&
        !          1482:                                    ((*pointeur_caractere_courant) !=
        !          1483:                                    d_code_fin_chaine))
        !          1484:                            {
        !          1485:                                if (*pointeur_caractere_courant == '\\')
        !          1486:                                {
        !          1487:                                    pointeur_caractere_courant++;
        !          1488: 
        !          1489:                                    switch(*pointeur_caractere_courant)
        !          1490:                                    {
        !          1491:                                        case '\\' :
        !          1492:                                        case '"' :
        !          1493:                                        {
        !          1494:                                            pointeur_caractere_courant++;
        !          1495:                                            break;
        !          1496:                                        }
        !          1497:                                    }
        !          1498:                                }
        !          1499:                                else
        !          1500:                                {
        !          1501:                                    pointeur_caractere_courant++;
        !          1502:                                }
        !          1503:                            }
        !          1504:                        }
        !          1505: 
        !          1506:                        pointeur_caractere_courant++;
        !          1507:                    }
        !          1508: 
        !          1509:                    if (niveau != 0)
        !          1510:                    {
        !          1511:                        erreur_analyse = d_ex_syntaxe;
        !          1512:                    }
        !          1513: 
        !          1514:                    drapeau_fin_objet = d_vrai;
        !          1515:                }
        !          1516:                else if ((*pointeur_caractere_courant) == '[')
        !          1517:                {
        !          1518:                    if (pointeur_debut_instruction !=
        !          1519:                            (pointeur_caractere_courant - 1))
        !          1520:                    {
        !          1521:                        erreur_format = d_ex_syntaxe;
        !          1522:                    }
        !          1523: 
        !          1524:                    pointeur_caractere_courant++;
        !          1525:                    drapeau_fin_objet = d_faux;
        !          1526: 
        !          1527:                    while(((*pointeur_caractere_courant) != d_code_fin_chaine)
        !          1528:                            && (erreur_format == d_absence_erreur))
        !          1529:                    {
        !          1530:                        while((*pointeur_caractere_courant) == d_code_espace)
        !          1531:                        {
        !          1532:                            pointeur_caractere_courant++;
        !          1533:                        }
        !          1534: 
        !          1535:                        if ((*pointeur_caractere_courant) == ']')
        !          1536:                        {
        !          1537:                            if ((*(++pointeur_caractere_courant)) == '>')
        !          1538:                            {
        !          1539:                                drapeau_fin_objet = d_vrai;
        !          1540:                            }
        !          1541:                            else
        !          1542:                            {
        !          1543:                                erreur_analyse = d_ex_syntaxe;
        !          1544:                            }
        !          1545: 
        !          1546:                            pointeur_caractere_courant++;
        !          1547:                            break;
        !          1548:                        }
        !          1549: 
        !          1550:                        if ((erreur_format == d_absence_erreur) &&
        !          1551:                                (drapeau_fin_objet == d_faux))
        !          1552:                        {
        !          1553:                            (*s_etat_processus).position_courante =
        !          1554:                                    pointeur_caractere_courant
        !          1555:                                    - (*s_etat_processus).definitions_chainees;
        !          1556: 
        !          1557:                            if ((erreur = recherche_instruction_suivante(
        !          1558:                                    s_etat_processus)) != d_absence_erreur)
        !          1559:                            {
        !          1560:                                if ((*s_etat_processus).instruction_courante
        !          1561:                                        != NULL)
        !          1562:                                {
        !          1563:                                    free((*s_etat_processus)
        !          1564:                                            .instruction_courante);
        !          1565:                                }
        !          1566: 
        !          1567:                                return(d_erreur);
        !          1568:                            }
        !          1569: 
        !          1570:                            pointeur_caractere_courant = (*s_etat_processus)
        !          1571:                                    .definitions_chainees + (*s_etat_processus)
        !          1572:                                    .position_courante;
        !          1573: 
        !          1574:                            free((*s_etat_processus).instruction_courante);
        !          1575:                        }
        !          1576:                    }
        !          1577: 
        !          1578:                    if (drapeau_fin_objet == d_faux)
        !          1579:                    {
        !          1580:                        erreur_analyse = d_ex_syntaxe;
        !          1581:                        drapeau_fin_objet = d_vrai;
        !          1582:                    }
        !          1583:                }
        !          1584: 
        !          1585:                break;
        !          1586:            }
        !          1587:        }
        !          1588:    }
        !          1589: 
        !          1590:    pointeur_fin_instruction = pointeur_caractere_courant;
        !          1591: 
        !          1592:    (*s_etat_processus).instruction_courante = (unsigned char *)
        !          1593:                malloc(((pointeur_fin_instruction - pointeur_debut_instruction)
        !          1594:                + 1) * sizeof(unsigned char));
        !          1595: 
        !          1596:    if ((*s_etat_processus).instruction_courante == NULL)
        !          1597:    {
        !          1598:        erreur = d_erreur;
        !          1599:        (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
        !          1600:    }
        !          1601:    else if (pointeur_fin_instruction != pointeur_debut_instruction)
        !          1602:    {
        !          1603:        pointeur_caractere_courant = pointeur_debut_instruction;
        !          1604:        pointeur_caractere_destination =
        !          1605:                (*s_etat_processus).instruction_courante;
        !          1606: 
        !          1607:        do
        !          1608:        {
        !          1609:            *pointeur_caractere_destination++ = *pointeur_caractere_courant++;
        !          1610:        } while(pointeur_caractere_courant < pointeur_fin_instruction);
        !          1611: 
        !          1612:        (*pointeur_caractere_destination) = d_code_fin_chaine;
        !          1613: 
        !          1614:        erreur = ((erreur_analyse == d_ex) && (erreur_format == d_ex))
        !          1615:                ? d_absence_erreur : d_erreur;
        !          1616:        (*s_etat_processus).erreur_execution = erreur_analyse;
        !          1617:    }
        !          1618:    else
        !          1619:    {
        !          1620:        (*(*s_etat_processus).instruction_courante) = d_code_fin_chaine;
        !          1621:    }
        !          1622: 
        !          1623:    (*s_etat_processus).position_courante = pointeur_fin_instruction
        !          1624:            - (*s_etat_processus).definitions_chainees;
        !          1625: 
        !          1626:    return(erreur);
        !          1627: }
        !          1628: 
        !          1629: 
        !          1630: /*
        !          1631: ================================================================================
        !          1632:   Routine mettant la chaine d'entrée en majuscule
        !          1633: ================================================================================
        !          1634:   Entrée : pointeur sur une chaine en minuscules.
        !          1635: --------------------------------------------------------------------------------
        !          1636:   Sortie : pointeur sur la chaine en majuscules. Si le pointeur retourné
        !          1637:    est nul, il s'est produit une erreur. L'allocation est faite dans la
        !          1638:    routine.
        !          1639: --------------------------------------------------------------------------------
        !          1640:   Effets de bord : néant.
        !          1641: ================================================================================
        !          1642: */
        !          1643: 
        !          1644: unsigned char *
        !          1645: conversion_majuscule(unsigned char *chaine)
        !          1646: {
        !          1647:    register unsigned char      *caractere_courant;
        !          1648:    register unsigned char      *caractere_courant_converti;
        !          1649:    register unsigned char      *chaine_convertie;
        !          1650: 
        !          1651:    unsigned long               longueur_chaine_plus_terminaison;
        !          1652: 
        !          1653:    longueur_chaine_plus_terminaison = 0;
        !          1654:    caractere_courant = chaine;
        !          1655: 
        !          1656:    while((*caractere_courant) != d_code_fin_chaine)
        !          1657:    {
        !          1658:        caractere_courant++;
        !          1659:        longueur_chaine_plus_terminaison++;
        !          1660:    }
        !          1661: 
        !          1662:    caractere_courant = chaine;
        !          1663:    caractere_courant_converti = chaine_convertie = (unsigned char *) malloc(
        !          1664:            (longueur_chaine_plus_terminaison + 1) * sizeof(unsigned char));
        !          1665: 
        !          1666:    if (chaine_convertie != NULL)
        !          1667:    {
        !          1668:        while((*caractere_courant) != d_code_fin_chaine)
        !          1669:        {
        !          1670:            if (isalpha((*caractere_courant)))
        !          1671:            {
        !          1672:                (*caractere_courant_converti) = (unsigned char)
        !          1673:                        toupper((*caractere_courant));
        !          1674:            }
        !          1675:            else
        !          1676:            {
        !          1677:                (*caractere_courant_converti) = (*caractere_courant);
        !          1678:            }
        !          1679: 
        !          1680:            caractere_courant++;
        !          1681:            caractere_courant_converti++;
        !          1682:        }
        !          1683: 
        !          1684:        (*caractere_courant_converti) = d_code_fin_chaine;
        !          1685:    }
        !          1686: 
        !          1687:    return(chaine_convertie);
        !          1688: }
        !          1689: 
        !          1690: 
        !          1691: /*
        !          1692: ================================================================================
        !          1693:   Initialisation de l'état du calculateur
        !          1694:    Configuration par défaut d'un calculateur HP-28S
        !          1695: ================================================================================
        !          1696:   Entrée : pointeur sur la structure struct_processus
        !          1697: --------------------------------------------------------------------------------
        !          1698:   Sortie : néant
        !          1699: --------------------------------------------------------------------------------
        !          1700:   Effets de bord : néant
        !          1701: ================================================================================
        !          1702: */
        !          1703: 
        !          1704: void
        !          1705: initialisation_drapeaux(struct_processus *s_etat_processus)
        !          1706: {
        !          1707:    unsigned long                   i;
        !          1708: 
        !          1709:    for(i = 0; i < 31; cf(s_etat_processus, i++));
        !          1710: 
        !          1711:    if ((*s_etat_processus).lancement_interactif == d_vrai)
        !          1712:    {
        !          1713:        sf(s_etat_processus, 31);
        !          1714:                                /* LAST autorisé                            */
        !          1715:    }
        !          1716:    else
        !          1717:    {
        !          1718:        cf(s_etat_processus, 31);
        !          1719:                                /* LAST invalidé                            */
        !          1720:    }
        !          1721: 
        !          1722:    cf(s_etat_processus, 32);   /* Impression automatique                   */
        !          1723:    cf(s_etat_processus, 33);   /* CR automatique (disp)                    */
        !          1724:    cf(s_etat_processus, 34);   /* Valeur principale (intervalle de déf.)   */
        !          1725:    sf(s_etat_processus, 35);   /* Evaluation symbolique des constantes     */
        !          1726:    sf(s_etat_processus, 36);   /* Evaluation symbolique des fonctions      */
        !          1727:    sf(s_etat_processus, 37);   /* Taille de mot pour les entiers binaires  */
        !          1728:    sf(s_etat_processus, 38);   /* Taille de mot pour les entiers binaires  */
        !          1729:    sf(s_etat_processus, 39);   /* Taille de mot pour les entiers binaires  */
        !          1730:    sf(s_etat_processus, 40);   /* Taille de mot pour les entiers binaires  */
        !          1731:    sf(s_etat_processus, 41);   /* Taille de mot pour les entiers binaires  */
        !          1732:    sf(s_etat_processus, 42);   /* Taille de mot pour les entiers binaires  */
        !          1733: /*
        !          1734: 37 : bit de poids faible
        !          1735: 42 : bit de poids fort
        !          1736: Les six drapeaux peuvent être nuls. Dans ce cas, la longueur des mots
        !          1737: binaires reste de un bit.
        !          1738: */
        !          1739:    cf(s_etat_processus, 43);   /* Base de numération binaire               */
        !          1740:    cf(s_etat_processus, 44);   /* Base de numération binaire               */
        !          1741: /*
        !          1742: 43 44 = 00 => décimal
        !          1743: 43 44 = 01 => binaire
        !          1744: 43 44 = 10 => octal
        !          1745: 43 44 = 11 => hexadécimal
        !          1746: */
        !          1747:    sf(s_etat_processus, 45);   /* Affichage multiligne du niveau 1         */
        !          1748:    cf(s_etat_processus, 46);   /* Réservé                                  */
        !          1749:    cf(s_etat_processus, 47);   /* Réservé                                  */
        !          1750: /*
        !          1751: 46 et 47 réservés sur le calculateur HP28S
        !          1752: 46 47 = 00 => système rectangulaire
        !          1753: 46 47 = 01 => système cylindrique
        !          1754: 46 47 = 10 => système sphérique
        !          1755: */
        !          1756:    cf(s_etat_processus, 48);   /* Séparateur décimal                       */
        !          1757:    cf(s_etat_processus, 49);   /* Format des nombres réels                 */
        !          1758:    cf(s_etat_processus, 50);   /* Format des nombres réels                 */
        !          1759: /*
        !          1760: 49 50 = 00 => standard
        !          1761: 49 50 = 01 => scientifique
        !          1762: 49 50 = 10 => virgule fixe
        !          1763: 49 50 = 11 => ingénieur
        !          1764: */
        !          1765:    cf(s_etat_processus, 51);   /* Tonalité                                 */
        !          1766:    cf(s_etat_processus, 52);   /* REDRAW automatique                       */
        !          1767:    cf(s_etat_processus, 53);   /* Nombre de chiffres décimaux              */
        !          1768:    cf(s_etat_processus, 54);   /* Nombre de chiffres décimaux              */
        !          1769:    cf(s_etat_processus, 55);   /* Nombre de chiffres décimaux              */
        !          1770:    cf(s_etat_processus, 56);   /* Nombre de chiffres décimaux              */
        !          1771: /*
        !          1772: 53 : bit de poids faible
        !          1773: 56 : bit de poids fort
        !          1774: */
        !          1775:    cf(s_etat_processus, 57);   /* Underflow traité normalement             */
        !          1776:    cf(s_etat_processus, 58);   /* Overflow traité normalement              */
        !          1777:    sf(s_etat_processus, 59);   /* Infinite result traité normalement       */
        !          1778:    sf(s_etat_processus, 60);   /* Angles                                   */
        !          1779: /*
        !          1780: 60 = 0 => degrés
        !          1781: 60 = 1 => radians
        !          1782: */
        !          1783:    cf(s_etat_processus, 61);   /* Underflow- traité en exception           */
        !          1784:    cf(s_etat_processus, 62);   /* Underflow+ traité en exception           */
        !          1785:    cf(s_etat_processus, 63);   /* Overflow traité en exception             */
        !          1786:    cf(s_etat_processus, 64);   /* Infinite result traité en exception      */
        !          1787: }
        !          1788: 
        !          1789: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>