/*************************************************************************************************************************************/ /* */ /* I N D E X A T I O N D E S P A R E N T H E S E S D ' U N E L I S T E */ /* S A N S G E R E R L E S I M B R I C A T I O N S A V E C L E S Q U O T E S : */ /* */ /* */ /* Author of '$xcp/listes.01$K' : */ /* */ /* Jean-Francois COLONNA (LACTAMME, 1995??????????). */ /* */ /*************************************************************************************************************************************/ /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* 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 : */ /* */ /*************************************************************************************************************************************/ /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* 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 MARQUER_LE_NIVEAU_DE_PARENTHESAGE \ VRAI \ /* Faut-il marquer le niveau de parenthesage ('VRAI') ou pas ('FAUX'), la valeur par */ \ /* defaut assurant la compatibilite anterieure... par */ #define MARQUEUR_DE_NIVEAU_DE_PARENTHESAGE \ K_EGAL \ /* Caractere introduisant le niveau des parentheses courantes. */ #define NOMBRE_DE_CHIFFRES_A_EDITER \ NOMBRE_DE_CHIFFRES \ /* Nombre de chiffres a editer pour les niveaux de parenthesage. */ #define ALLER_A_LA_LIGNE_AVANT_LES_K_PG \ VRAI #define ALLER_A_LA_LIGNE_APRES_LES_K_PD \ VRAI /* Gestion des changements de ligne... */ #define TABULER \ VRAI \ /* Faut-il tabuler ('VRAI') apres chaque changement de ligne ou pas ('FAUX'). */ #define TABULATION \ CINQ \ /* "Unite" de tabulation... */ /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* M A C R O S U T I L E S : */ /* */ /*************************************************************************************************************************************/ #define MARQUAGE_DU_NIVEAU_DE_PARENTHESAGE \ Bblock \ Test(IL_FAUT(marquer_le_niveau_de_parenthesage)) \ /* Test introduit le 20221201153854... */ \ Bblock \ DEFV(Int,INIT(index,PREMIER_CARACTERE)); \ DEFV(CHAR,INIT(POINTERc(niveau_de_parenthesage) \ ,chain_numero(compteur_des_parentheses,nombre_de_chiffres_a_editer) \ ) \ ); \ /* Conversion du niveau de parenthesage en une chaine de caracteres et son index... */ \ \ CALS(Putchar(marqueur_de_niveau_de_parenthesage)); \ /* Lorsqu'une parenthese ouvrante ou fermante est rencontree, on la marque... */ \ \ Repe(nombre_de_chiffres_a_editer) \ Bblock \ CALS(Putchar(ITb0(niveau_de_parenthesage,INDX(index,PREMIER_CARACTERE)))); \ INCR(index,I); \ /* Edition du niveau de parenthesage... */ \ Eblock \ ERep \ \ CALS(Putchar(marqueur_de_niveau_de_parenthesage)); \ /* Puis enfin, remarquage apres l'edition du niveau de parenthesage... */ \ Eblock \ ATes \ Bblock \ Eblock \ ETes \ Eblock #define CHANGEMENT_DE_LIGNE(changer_de_ligne) \ Bblock \ Test(IL_FAUT(changer_de_ligne)) \ Bblock \ CALS(Putchar(K_LF)); \ Eblock \ ATes \ Bblock \ Eblock \ ETes \ \ Test(IL_FAUT(tabuler)) \ Bblock \ Repe(MUL2(compteur_des_parentheses,tabulation)) \ Bblock \ CALS(Putchar(K_BLANC)); \ Eblock \ ERep \ Eblock \ ATes \ Bblock \ Eblock \ ETes \ Eblock /*===================================================================================================================================*/ /*************************************************************************************************************************************/ /* */ /* I N D E X A T I O N D E S P A R E N T H E S E S D ' U N E L I S T E */ /* S A N S G E R E R L E S I M B R I C A T I O N S A V E C L E S Q U O T E S : */ /* */ /*************************************************************************************************************************************/ BCommande(nombre_d_arguments,arguments) /*-----------------------------------------------------------------------------------------------------------------------------------*/ Bblock DEFV(Logical,INIT(marquer_le_niveau_de_parenthesage,MARQUER_LE_NIVEAU_DE_PARENTHESAGE)); /* Faut-il marquer le niveau de parenthesage ('VRAI') ou pas ('FAUX'), la valeur par */ /* defaut assurant la compatibilite anterieure... par */ DEFV(Char,INIT(marqueur_de_niveau_de_parenthesage,MARQUEUR_DE_NIVEAU_DE_PARENTHESAGE)); /* Caractere introduisant le niveau des parentheses courantes. */ DEFV(Positive,INIT(nombre_de_chiffres_a_editer,NOMBRE_DE_CHIFFRES_A_EDITER)); /* Nombre de chiffres a editer pour les niveaux de parenthesage. */ DEFV(Logical,INIT(aller_a_la_ligne_avant_les_K_PG,ALLER_A_LA_LIGNE_AVANT_LES_K_PG)); DEFV(Logical,INIT(aller_a_la_ligne_apres_les_K_PD,ALLER_A_LA_LIGNE_APRES_LES_K_PD)); /* Gestion des changements de ligne... */ DEFV(Logical,INIT(tabuler,TABULER)); /* Faut-il tabuler ('VRAI') apres chaque changement de ligne ou pas ('FAUX'). */ DEFV(Int,INIT(tabulation,TABULATION)); /* "Unite" de tabulation... */ DEFV(Int,INIT(compteur_des_parentheses,ZERO)); /* Ce compteur est incremente d'une unite a la rencontre d'une parenthese ouvrante, et */ /* decremente d'une unite a la rencontre d'une parenthese fermante. */ DEFV(Char,INIT(caractere_courant,K_UNDEF)); /* Caractere courant. */ /*..............................................................................................................................*/ GET_ARGUMENTS_(nombre_d_arguments ,GET_ARGUMENT_L("marquer=",marquer_le_niveau_de_parenthesage); GET_ARGUMENT_K("marqueur=",marqueur_de_niveau_de_parenthesage); GET_ARGUMENT_I("nombre=""n=""chiffres=",nombre_de_chiffres_a_editer); GET_ARGUMENT_L("K_PG=",aller_a_la_ligne_avant_les_K_PG); GET_ARGUMENT_L("K_PD=",aller_a_la_ligne_apres_les_K_PD); GET_ARGUMENT_L("tabuler=",tabuler); GET_ARGUMENT_I("tabulation=",tabulation); ); Tant(GetcharT(caractere_courant)) 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(IFNE(caractere_courant,K_PG),IFNE(caractere_courant,K_PD))) Bblock CALS(Putchar(caractere_courant)); /* Tous les caracteres sont a priori transmis sauf les parentheses... */ Eblock ATes Bblock Eblock ETes Test(IFEQ(caractere_courant,K_PG)) Bblock MARQUAGE_DU_NIVEAU_DE_PARENTHESAGE; INCR(compteur_des_parentheses,I); /* Comptage des parentheses... */ CHANGEMENT_DE_LIGNE(aller_a_la_ligne_avant_les_K_PG); CALS(Putchar(caractere_courant)); /* Transmission des parentheses ouvrantes... */ Eblock ATes Bblock Eblock ETes Test(IFOU(IFEQ(caractere_courant,K_PG),IFEQ(caractere_courant,K_PD))) Bblock MARQUAGE_DU_NIVEAU_DE_PARENTHESAGE; Eblock ATes Bblock Eblock ETes Test(IFEQ(caractere_courant,K_PD)) Bblock Test(IZGT(compteur_des_parentheses)) Bblock CALS(Putchar(caractere_courant)); /* Transmission des parentheses fermantes... */ DECR(compteur_des_parentheses,I); /* Decomptage des parentheses... */ CHANGEMENT_DE_LIGNE(aller_a_la_ligne_apres_les_K_PD); MARQUAGE_DU_NIVEAU_DE_PARENTHESAGE; Eblock ATes Bblock PRINT_ERREUR("les parentheses sont mal equilibrees : il a trop de parentheses '$K_PD')"); Eblock ETes Eblock ATes Bblock Eblock ETes Eblock ETan Test(IZNE(compteur_des_parentheses)) Bblock PRINT_ERREUR("les parentheses sont mal equilibrees : il a trop de parentheses '$K_PG'"); Eblock ATes Bblock Eblock ETes RETU_Commande; Eblock ECommande