--- rpl/src/compilation.c 2013/02/27 17:11:39 1.55 +++ rpl/src/compilation.c 2013/03/17 22:26:43 1.56 @@ -1080,6 +1080,10 @@ recherche_instruction_suivante(struct_pr { case ']' : case '}' : + { + break; + } + case ')' : { erreur_format = d_ex_syntaxe; @@ -1418,100 +1422,109 @@ recherche_instruction_suivante(struct_pr while((niveau != 0) && ((*pointeur_caractere_courant) != d_code_fin_chaine)) { - switch(*pointeur_caractere_courant) + (*s_etat_processus).position_courante = + pointeur_caractere_courant + - (*s_etat_processus).definitions_chainees; + + if (recherche_instruction_suivante(s_etat_processus) + == d_erreur) { - case '{' : + if ((*s_etat_processus).instruction_courante + != NULL) { - if (niveau_annexe == 0) - { - niveau++; - } - else - { - erreur_analyse = d_ex_syntaxe; - } - - break; + free((*s_etat_processus).instruction_courante); } - case '}' : - { - if (niveau_annexe == 0) - { - niveau--; - } - else - { - erreur_analyse = d_ex_syntaxe; - } + return(d_erreur); + } - break; - } + pointeur_caractere_courant = + (*s_etat_processus).definitions_chainees + + (*s_etat_processus).position_courante; - case '[' : + if (strcmp((*s_etat_processus).instruction_courante, "{") + == 0) + { + if (niveau_annexe == 0) { - niveau_annexe++; - - if (niveau_annexe > 2) - { - erreur_analyse = d_ex_syntaxe; - } - - break; + niveau++; } - - case ']' : + else { - niveau_annexe--; - - if (niveau_annexe < 0) - { - erreur_analyse = d_ex_syntaxe; - } + erreur_analyse = d_ex_syntaxe; + } + } + else if (strcmp((*s_etat_processus).instruction_courante, + "}") == 0) + { + if (niveau_annexe == 0) + { + niveau--; + } + else + { + erreur_analyse = d_ex_syntaxe; + } + } + else if (strcmp((*s_etat_processus).instruction_courante, + "<[") == 0) + { + niveau++; + } + else if (strcmp((*s_etat_processus).instruction_courante, + "]>") == 0) + { + niveau--; + } + else if (strcmp((*s_etat_processus).instruction_courante, + "[") == 0) + { + niveau_annexe++; - break; + if (niveau_annexe > 2) + { + erreur_analyse = d_ex_syntaxe; } + } + else if (strcmp((*s_etat_processus).instruction_courante, + "[[") == 0) + { + niveau_annexe += 2; - case '"' : + if (niveau_annexe > 2) { - if (niveau_annexe == 0) - { - pointeur_caractere_courant++; + erreur_analyse = d_ex_syntaxe; + } + } + else if (strcmp((*s_etat_processus).instruction_courante, + "]") == 0) + { + niveau_annexe--; - while((*pointeur_caractere_courant != '"') && - ((*pointeur_caractere_courant) != - d_code_fin_chaine)) - { - if (*pointeur_caractere_courant == '\\') - { - pointeur_caractere_courant++; - - switch(*pointeur_caractere_courant) - { - case '\\' : - case '"' : - { - pointeur_caractere_courant++; - break; - } - } - } - else - { - pointeur_caractere_courant++; - } - } - } - else - { - erreur_analyse = d_ex_syntaxe; - } + if (niveau_annexe < 0) + { + erreur_analyse = d_ex_syntaxe; + } + } + else if (strcmp((*s_etat_processus).instruction_courante, + "]]") == 0) + { + niveau_annexe -= 2; - break; + if (niveau_annexe < 0) + { + erreur_analyse = d_ex_syntaxe; + } + } + else if ((*s_etat_processus).instruction_courante[0] == '"') + { + if (niveau_annexe != 0) + { + erreur_analyse = d_ex_syntaxe; } } - pointeur_caractere_courant++; + free((*s_etat_processus).instruction_courante); } if ((niveau != 0) || (niveau_annexe != 0)) @@ -1605,7 +1618,7 @@ recherche_instruction_suivante(struct_pr { if (((*s_etat_processus).autorisation_empilement_programme == 'Y') && ((*pointeur_caractere_courant) == '<')) - { + { // Cas << >> if (pointeur_debut_instruction != (pointeur_caractere_courant - 1)) { @@ -1617,48 +1630,38 @@ recherche_instruction_suivante(struct_pr while((niveau != 0) && ((*pointeur_caractere_courant) != d_code_fin_chaine)) { - if (((*pointeur_caractere_courant) == '<') && - ((*(pointeur_caractere_courant + 1)) == '<')) + (*s_etat_processus).position_courante = + pointeur_caractere_courant + - (*s_etat_processus).definitions_chainees; + + if (recherche_instruction_suivante(s_etat_processus) + == d_erreur) { - niveau++; - pointeur_caractere_courant++; + if ((*s_etat_processus).instruction_courante + != NULL) + { + free((*s_etat_processus).instruction_courante); + } + + return(d_erreur); } - else if (((*pointeur_caractere_courant) == '>') && - ((*(pointeur_caractere_courant + 1)) == '>')) + + pointeur_caractere_courant = + (*s_etat_processus).definitions_chainees + + (*s_etat_processus).position_courante; + + if (strcmp((*s_etat_processus).instruction_courante, + "<<") == 0) { - niveau--; - pointeur_caractere_courant++; + niveau++; } - else if ((*pointeur_caractere_courant) == '"') + else if (strcmp((*s_etat_processus) + .instruction_courante, ">>") == 0) { - pointeur_caractere_courant++; - - while((*pointeur_caractere_courant != '"') && - ((*pointeur_caractere_courant) != - d_code_fin_chaine)) - { - if (*pointeur_caractere_courant == '\\') - { - pointeur_caractere_courant++; - - switch(*pointeur_caractere_courant) - { - case '\\' : - case '"' : - { - pointeur_caractere_courant++; - break; - } - } - } - else - { - pointeur_caractere_courant++; - } - } + niveau--; } - pointeur_caractere_courant++; + free((*s_etat_processus).instruction_courante); } if (niveau != 0) @@ -1669,7 +1672,7 @@ recherche_instruction_suivante(struct_pr drapeau_fin_objet = d_vrai; } else if ((*pointeur_caractere_courant) == '[') - { + { // Cas <[ ]> if (pointeur_debut_instruction != (pointeur_caractere_courant - 1)) {