[1] | 1 | /* pour pouvoir acceder au numero de ligne dans bison */ |
---|
| 2 | %option noyywrap |
---|
| 3 | %option yylineno |
---|
| 4 | |
---|
| 5 | |
---|
| 6 | %{ |
---|
| 7 | //====================================================== |
---|
| 8 | /** |
---|
| 9 | |
---|
| 10 | fichier flex de verification xml |
---|
| 11 | ter d'analyse syntaxique 2006-2007 |
---|
| 12 | ================================== |
---|
| 13 | |
---|
| 14 | auteurs: |
---|
| 15 | Jean-Marie CODOL |
---|
| 16 | & |
---|
| 17 | Naitan GROLLEMUND |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | ====== |
---|
| 23 | ce fichier est li�a 3 autres fichiers : |
---|
| 24 | parser.y |
---|
| 25 | makefile |
---|
| 26 | README |
---|
| 27 | |
---|
| 28 | pour compiler ce projet : |
---|
| 29 | linux : taper $make all |
---|
| 30 | windows : ouvrir avec dev-c++, configurer le makefile du projet et compiler |
---|
| 31 | naviguer avec la ligne de commande jusqu'au repertoire. |
---|
| 32 | ====== |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | pour plus d'informations, voir le README |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | **/ |
---|
| 39 | //====================================================== |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | //====================================================== |
---|
| 43 | /* pour avoir acces a strdup() */ |
---|
| 44 | /* en effet, il faut garder une trace de la valeur */ |
---|
| 45 | /* car yytext va varier et on ne pourra plus reconnaitre les */ |
---|
| 46 | /* identifiants si on ne copie pas ces valeurs */ |
---|
| 47 | #include <string.h> |
---|
| 48 | |
---|
| 49 | //====================================================== |
---|
| 50 | /* pour la liaison avec bison */ |
---|
| 51 | #include "service_conf.tab.h" |
---|
| 52 | |
---|
| 53 | //====================================================== |
---|
| 54 | /* afficher ou pas une trace : */ |
---|
| 55 | #ifdef DEBUG_SERVICE_CONF |
---|
| 56 | int affichetrace = 1; |
---|
| 57 | #else |
---|
| 58 | int affichetrace = 0; |
---|
| 59 | #endif |
---|
| 60 | //====================================================== |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | //====================================================== |
---|
| 64 | /* on a l interdiction de mettre un commentaire avant une declaration : */ |
---|
| 65 | int attentionImpossibleDeTrouverXMLDeclapres = 0 ; |
---|
| 66 | //====================================================== |
---|
| 67 | |
---|
| 68 | //====================================================== |
---|
| 69 | /* on a l interdiction de mettre un pi avant une declaration : */ |
---|
| 70 | int attentionImpossibleDeTrouverPIapres = 0 ; |
---|
| 71 | //====================================================== |
---|
| 72 | |
---|
| 73 | %} |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | /*====================================================*/ |
---|
| 77 | /*====================================================*/ |
---|
| 78 | /* Les Separateurs xml */ |
---|
| 79 | /*====================================================*/ |
---|
| 80 | S [ \t\r\n]+ |
---|
| 81 | /*====================================================*/ |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | /*====================================================*/ |
---|
| 87 | /* CharRef regle 66 */ |
---|
| 88 | /*====================================================*/ |
---|
| 89 | CharRef "&#"[0-9]+";"|"&#x"[0-9a-fA-F]+";" |
---|
| 90 | /*====================================================*/ |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | /*====================================================*/ |
---|
| 96 | /* espaces? '=' espaces? regle 25 */ |
---|
| 97 | /* si on veut pouvoir utiliser S dans bison, */ |
---|
| 98 | /* il faut cr�r au moins une autre start condition */ |
---|
| 99 | /* comme on n'utilise "egalevolue" que pour version et encoding */ |
---|
| 100 | /* il est pr��able de rajouter cette macro */ |
---|
| 101 | /*====================================================*/ |
---|
| 102 | egalevolue {S}?"="{S}? |
---|
| 103 | /*====================================================*/ |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | /*====================================================*/ |
---|
| 109 | /* Name regle 5 */ |
---|
| 110 | /*====================================================*/ |
---|
| 111 | /*** Name [a-zA-Z_:][a-zA-Z0-9.\-_:]* ***/ |
---|
| 112 | Name ([_:]|[\x41-\x5A]|[\x61-\x7A]|[\xC0-\xD6]|[\xD8-\xF6]|[\xF8-\xFF])(([\x41-\x5A]|[\x61-\x7A]|[\xC0-\xD6]|[\xD8-\xF6]|[\xF8-\xFF])|[0-9.\-_:])* |
---|
| 113 | /*====================================================*/ |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | /*====================================================*/ |
---|
| 120 | /* chardata regle 14 */ |
---|
| 121 | /*====================================================*/ |
---|
| 122 | /**chardata [a-zA-Z0-9_\-.:" "\"\'\\]***/ |
---|
| 123 | chardata [^<]* |
---|
| 124 | /*====================================================*/ |
---|
| 125 | attname [a-zA-Z0-9_\-]+ |
---|
[9] | 126 | attvalue1 [\*\+,;@a-zA-Z0-9_\-::.:" "\"\'/\\\(\)]+ |
---|
[1] | 127 | |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | /*====================================================*/ |
---|
| 133 | /* attvalue regle 10 */ |
---|
| 134 | /*====================================================*/ |
---|
| 135 | /* attvalue \"([^"&]|{CharRef})*\"|\'([^'&]|{CharRef})*\' */ |
---|
| 136 | /* pas tr� classe mais ca marche . */ |
---|
| 137 | attvalue \"[^"]*\"|\'[^']*\'\(\) |
---|
| 138 | /*====================================================*/ |
---|
| 139 | |
---|
| 140 | whitespace [ ]{0,} |
---|
| 141 | whitesp [ ] |
---|
| 142 | newline [\r\n]|[\n] |
---|
| 143 | newlines [\r\n]{1,}|[\n]{1,} |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | /*====================================================*/ |
---|
| 147 | /* initial = de debut a ?> du prolog ; DANSBALISE = dans une balise ; HORSBALISE = hors d'une balise */ |
---|
| 148 | /*====================================================*/ |
---|
| 149 | %x DANSBALISE HORSBALISE PAIRSTART |
---|
| 150 | /*====================================================*/ |
---|
| 151 | |
---|
| 152 | |
---|
| 153 | |
---|
| 154 | |
---|
| 155 | %% |
---|
| 156 | |
---|
| 157 | "\n" { if (affichetrace==1) fprintf (stderr,"\n\nNEWLINE\n") ;return NEWLINE;} |
---|
| 158 | |
---|
| 159 | {newline}+{whitesp}* { if (affichetrace==1) fprintf (stderr,"\n\nNEWLINE 1\n") ; return NEWLINE;} |
---|
| 160 | |
---|
[9] | 161 | <INITIAL,HORSBALISE>"["{attname}"]" { srlval.chaine=yytext;return ANID; } |
---|
[1] | 162 | |
---|
[9] | 163 | <INITIAL,HORSBALISE>{attname} { srlval.chaine=yytext; return SPAIR; } |
---|
[1] | 164 | |
---|
[9] | 165 | <PAIRSTART,HORSBALISE>{attvalue1} { srlval.chaine=yytext;/*BEGIN(INITIAL);*/ return EPAIR;} |
---|
[1] | 166 | |
---|
| 167 | <PAIRSTART,INITIAL,HORSBALISE>{whitesp}*"="{whitesp}* { BEGIN(PAIRSTART);} |
---|
| 168 | |
---|
[9] | 169 | <PAIRSTART,INITIAL,HORSBALISE,DANSBALISE>{newline}+{whitesp}* { BEGIN(INITIAL); return NEWLINE;} |
---|
[1] | 170 | |
---|
[9] | 171 | <INITIAL>"<?"[Xx][Mm][Ll] { if (attentionImpossibleDeTrouverXMLDeclapres == 1 || attentionImpossibleDeTrouverPIapres == 1) {/* il y a eut un commentaire ou une balise applicative avant la declaration xml */ fprintf(stderr,"\nerror : a la ligne %d : il y a eut un commentaire ou un PI avant la declaration xml\n",srlineno); exit (10) ; } ; return STARTXMLDECL;} |
---|
[1] | 172 | |
---|
[9] | 173 | <INITIAL>"version"{egalevolue}\"1.0\"|"version"{egalevolue}\'1.0\' { return VERSIONDECL; } |
---|
[1] | 174 | <INITIAL>"version"{egalevolue}\"[^"]*\"|"version"{egalevolue}\'[^']*\' {/* erreur de version encoding */ fprintf(stderr,"\nerror : a la ligne %d : la version xml n est pas reconnue : %s\n",srlineno,yytext); exit (9) ; } |
---|
| 175 | |
---|
| 176 | |
---|
[9] | 177 | <INITIAL>"encoding"{egalevolue}\"[Ii][Ss][Oo]"-8859-1"\"|"encoding"{egalevolue}\'[Ii][Ss][Oo]"-8859-1"\' { return ENCODINGDECL;} |
---|
[1] | 178 | <INITIAL>"encoding"{egalevolue}\"[^"]*\"|"encoding"{egalevolue}\'[^']*\' {/* erreur de version encoding */ fprintf(stderr,"\nerror : a la ligne %d : la version d encodage n est pas reconnue : %s\n",srlineno,yytext); exit (8) ; } |
---|
| 179 | |
---|
| 180 | |
---|
[9] | 181 | <INITIAL>"standalone"{egalevolue}\"yes\"|"standalone"{egalevolue}\'yes\'|"standalone"{egalevolue}\"no\"|"standalone"{egalevolue}\'no\' { return SDDECL;} |
---|
[1] | 182 | |
---|
| 183 | <INITIAL>"standalone"{egalevolue}\"[^"]*\"|"standalone"{egalevolue}\'[^']*\'|"standalone"{egalevolue}\"[^"]*\"|"standalone"{egalevolue}\'[^']*\' { /* erreur de version encoding */ fprintf(stderr,"\nerror : a la ligne %d : la version standalone n est pas reconnue : %s\n",srlineno,yytext); exit (7) ; } |
---|
| 184 | |
---|
| 185 | |
---|
[9] | 186 | <INITIAL>"?>" { BEGIN(HORSBALISE); return ENDXMLDECL;} |
---|
[1] | 187 | |
---|
| 188 | |
---|
[9] | 189 | <DANSBALISE,INITIAL,HORSBALISE>{S} { } |
---|
[1] | 190 | |
---|
| 191 | |
---|
[9] | 192 | <HORSBALISE>"<?"[Xx][Mm][Ll]{S}({S}|{chardata})*"?>"|"<?"[Xx][Mm][Ll]"?>" { return PIERROR;} |
---|
| 193 | <INITIAL,HORSBALISE>"<?"([^xX]|([xX][^mM])|([xX][mM][^lL]))({S}|([^?]|("?"[^>])))*"?>" { attentionImpossibleDeTrouverPIapres=1 ; return PI;} |
---|
[1] | 194 | |
---|
| 195 | |
---|
[9] | 196 | <INITIAL,HORSBALISE>{newline}*"<" { BEGIN(DANSBALISE); return INFCAR;} |
---|
[1] | 197 | |
---|
| 198 | |
---|
[9] | 199 | <DANSBALISE>">" { BEGIN(HORSBALISE);return SUPCAR;} |
---|
[1] | 200 | |
---|
| 201 | |
---|
[9] | 202 | <DANSBALISE>"/" {return SLASH;} |
---|
[1] | 203 | |
---|
| 204 | |
---|
[9] | 205 | <DANSBALISE>{egalevolue} {return Eq;} |
---|
[1] | 206 | |
---|
| 207 | |
---|
[9] | 208 | <DANSBALISE>{Name} {srlval.chaine=strdup(yytext);return ID;} |
---|
[1] | 209 | |
---|
| 210 | |
---|
[9] | 211 | <DANSBALISE>{attvalue} {return ATTVALUE;} |
---|
[1] | 212 | |
---|
| 213 | |
---|
| 214 | <INITIAL,HORSBALISE>"<!--"([^-]|"-"[^-])*"-->" {attentionImpossibleDeTrouverXMLDeclapres=1; } |
---|
| 215 | |
---|
| 216 | |
---|
[9] | 217 | <INITIAL,DANSBALISE,HORSBALISE>.|\n {fprintf(stderr,"error : ligne %d : caractere non reconnu '%s'\n",srlineno,yytext);} |
---|
[1] | 218 | |
---|
| 219 | %% |
---|
| 220 | |
---|