/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        M I S E   E N   P L A C E   D E   F I N S   D E   C O M M E N T A I R E S   S Y S T E M A T I Q U E S                      */
/*        S U R   C H A Q U E   L I G N E   O U   C O M M E N C E   U N   C O M M E N T A I R E  :                                   */
/*                                                                                                                                   */
/*                                                                                                                                   */
/*        Author of '$xcp/adjustK.03$K' :                                                                                            */
/*                                                                                                                                   */
/*                    Jean-Francois COLONNA (LACTAMME, 1988??????????).                                                              */
/*                                                                                                                                   */
/*************************************************************************************************************************************/

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        I N T E R F A C E   ' listG '  :                                                                                           */
/*                                                                                                                                   */
/*                                                                                                                                   */
/*        :Debut_listG:                                                                                                              */
/*        :Fin_listG:                                                                                                                */
/*                                                                                                                                   */
/*************************************************************************************************************************************/

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        D I R E C T I V E S   S P E C I F I Q U E S   D E   C O M P I L A T I O N  :                                               */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
@define   PRAGMA_CL_____PAS_DE_LIBRAIRIES_DYNAMIQUES
                                        /* Introduit le 20070713162021 a cause de 'v $xcg/gen$ARG$Z 20070713163308'...               */

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        F I C H I E R S   D ' I N C L U D E S  :                                                                                   */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#include  INCLUDES_MINI

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        P A R A M E T R E S  :                                                                                                     */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#define   LONGUEUR_D_UNE_LIGNE_SOURCE_03                                                                                                \
                    LONGUEUR_D_UNE_LIGNE_SOURCE_ETOILE

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        M A C R O S   U T I L E S  :                                                                                               */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#define   SEND_CARACTERE(caractere)                                                                                                     \
                    Bblock                                                                                                              \
                    CALS(Putchar(caractere));                                                                                           \
                                        /* Emission du caractere courant.                                                            */ \
                                                                                                                                        \
                    Test(IFEQ(caractere,K_LF))                                                                                          \
                         Bblock                                                                                                         \
                         CLIR(compteur_des_caracteres_sur_la_ligne);                                                                    \
                                        /* Reinitialisation du comptage des caracteres sur la nouvelle ligne courante.               */ \
                         Eblock                                                                                                         \
                    ATes                                                                                                                \
                         Bblock                                                                                                         \
                         Eblock                                                                                                         \
                    ETes                                                                                                                \
                                                                                                                                        \
                    INCR(compteur_des_caracteres_sur_la_ligne,I);                                                                       \
                                        /* Comptage des caracteres sur la ligne courante.                                            */ \
                    Eblock

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        M I S E   E N   P L A C E   D E   F I N S   D E   C O M M E N T A I R E S   S Y S T E M A T I Q U E S                      */
/*        S U R   C H A Q U E   L I G N E   O U   C O M M E N C E   U N   C O M M E N T A I R E  :                                   */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
BCommande(nombre_d_arguments,arguments)
/*-----------------------------------------------------------------------------------------------------------------------------------*/
     Bblock
     DEFV(Int,INIT(compteur_des_caracteres_sur_la_ligne,UN));
                                        /* Ce compteur permet de savoir ou l'on en est a chaque instant sur la ligne courante...     */
     DEFV(Logical,INIT(on_a_trouve_un_commentaire,FAUX));
                                        /* Cet indicateur permet de savoir si l'on est ou pas a l'interieur d'un commentaire ; il    */
                                        /* est mis a 'FAUX' a la fin de chaque ligne...                                              */
     DEFV(Char,INIT(caractere_courant_00,K_NULL));
                                        /* Caractere courant (00),                                                                   */
     DEFV(Char,INIT(caractere_courant_01,K_NULL));
                                        /* Caractere precedent (01),                                                                 */
     /*..............................................................................................................................*/
     GET_ARGUMENTS_(nombre_d_arguments
                   ,BLOC(VIDE;
                         )
                    );

     Tant(GetcharT(caractere_courant_00))
          Bblock
                                        /* Le caractere courant de l'entree courante est recupere ; et on boucle                     */
                                        /* sur cette recuperation tant que l'on n'est pas au bout du fichier.                        */
          Test(IFET(IFEQ(caractere_courant_01,K_SLASH),IFEQ(caractere_courant_00,K_ETOILE)))
               Bblock
               EGAL(on_a_trouve_un_commentaire,VRAI);
               Eblock
          ATes
               Bblock
               Eblock
          ETes

          Test(IFET(IFEQ(caractere_courant_01,K_ETOILE),IFEQ(caractere_courant_00,K_SLASH)))
               Bblock
               EGAL(on_a_trouve_un_commentaire,FAUX);
               Eblock
          ATes
               Bblock
               Eblock
          ETes

          Test(IFET(EST_VRAI(on_a_trouve_un_commentaire)
                   ,IFEQ(caractere_courant_00,K_LF)
                    )
               )
               Bblock
               Tant(IFLT(compteur_des_caracteres_sur_la_ligne,LONGUEUR_D_UNE_LIGNE_SOURCE_03))
                    Bblock
                    SEND_CARACTERE(K_BLANC);
                                        /* Insertion de caracteres 'ESPACE' avant la fin de commentaire a inserer...                 */
                    Eblock
               ETan

               SEND_CARACTERE(K_ETOILE);
               SEND_CARACTERE(K_SLASH);

               Test(IFEQ(caractere_courant_01,K_ANTI_SLASH))
                    Bblock
                    SEND_CARACTERE(caractere_courant_01);
                                        /* Emission differee des caracteres 'ANTI-SLASH'.                                            */
                    Eblock
               ATes
                    Bblock
                    Eblock
               ETes

               SEND_CARACTERE(caractere_courant_00);
                                        /* Puis, apres les 'ESPACE's on envoie une fin de commentaire...                             */
               Eblock
          ATes
               Bblock
               Test(IFEQ(caractere_courant_01,K_ANTI_SLASH))
                    Bblock
                    SEND_CARACTERE(caractere_courant_01);
                                        /* Emission differee des caracteres 'ANTI-SLASH'.                                            */
                    Eblock
               ATes
                    Bblock
                    Eblock
               ETes

               Test(IFNE(caractere_courant_00,K_ANTI_SLASH))
                    Bblock
                    SEND_CARACTERE(caractere_courant_00);
                                        /* Re-emission de tous les caracteres, sauf le caractere  'ANTI-SLASH' que l'on              */
                                        /* differe au cas ou il seriat dans un commentaire...                                        */
                    Eblock
               ATes
                    Bblock
                    Eblock
               ETes
               Eblock
          ETes

          Test(IFEQ(caractere_courant_00,K_LF))
               Bblock
               EGAL(on_a_trouve_un_commentaire,FAUX);
               Eblock
          ATes
               Bblock
               Eblock
          ETes

          Test(IFEQ(caractere_courant_00,K_LF))
               Bblock
               EGAL(caractere_courant_01,K_NULL);
                                        /* En bout de ligne, on reinitialise...                                                      */
               Eblock
          ATes
               Bblock
               EGAL(caractere_courant_01,caractere_courant_00);
                                        /* Decalage des derniers caracteres memorises lorsque l'on n'est pas en bout de ligne.       */
               Eblock
          ETes

          EGAL(caractere_courant_00,K_NULL);
          Eblock
     ETan

     RETU_Commande;
     Eblock
ECommande



Copyright © Jean-François COLONNA, 2019-2024.
Copyright © CMAP (Centre de Mathématiques APpliquées) UMR CNRS 7641 / École polytechnique, Institut Polytechnique de Paris, 2019-2024.