[1] | 1 | /* pour pouvoir acceder au numero de ligne dans bison */ |
---|
| 2 | %option yylineno |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | %{ |
---|
| 6 | //====================================================== |
---|
| 7 | /** |
---|
| 8 | Zoo main configuration file parser |
---|
| 9 | **/ |
---|
| 10 | //====================================================== |
---|
| 11 | |
---|
| 12 | |
---|
| 13 | #include <string.h> |
---|
| 14 | #include "main_conf_read.tab.h" |
---|
| 15 | static int affichetrace = 0 ; |
---|
| 16 | static int attentionImpossibleDeTrouverXMLDeclapres = 0 ; |
---|
| 17 | static int attentionImpossibleDeTrouverPIapres = 0 ; |
---|
| 18 | |
---|
| 19 | %} |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | /*====================================================*/ |
---|
| 23 | /*====================================================*/ |
---|
| 24 | /* Les Separateurs xml */ |
---|
| 25 | /*====================================================*/ |
---|
| 26 | S [ \t\r\n]+ |
---|
| 27 | /*====================================================*/ |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | /*====================================================*/ |
---|
| 33 | /* CharRef regle 66 */ |
---|
| 34 | /*====================================================*/ |
---|
| 35 | CharRef "&#"[0-9]+";"|"&#x"[0-9a-fA-F]+";" |
---|
| 36 | /*====================================================*/ |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | /*====================================================*/ |
---|
| 42 | /* espaces? '=' espaces? regle 25 */ |
---|
| 43 | /* si on veut pouvoir utiliser S dans bison, */ |
---|
| 44 | /* il faut cr�r au moins une autre start condition */ |
---|
| 45 | /* comme on n'utilise "egalevolue" que pour version et encoding */ |
---|
| 46 | /* il est pr��able de rajouter cette macro */ |
---|
| 47 | /*====================================================*/ |
---|
| 48 | egalevolue {S}?"="{S}? |
---|
| 49 | /*====================================================*/ |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | /*====================================================*/ |
---|
| 55 | /* Name regle 5 */ |
---|
| 56 | /*====================================================*/ |
---|
| 57 | /*** Name [a-zA-Z_:][a-zA-Z0-9.\-_:]* ***/ |
---|
| 58 | Name ([_:]|[\x41-\x5A]|[\x61-\x7A]|[\xC0-\xD6]|[\xD8-\xF6]|[\xF8-\xFF])(([\x41-\x5A]|[\x61-\x7A]|[\xC0-\xD6]|[\xD8-\xF6]|[\xF8-\xFF])|[0-9.\-_:])* |
---|
| 59 | /*====================================================*/ |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | /*====================================================*/ |
---|
| 66 | /* chardata regle 14 */ |
---|
| 67 | /*====================================================*/ |
---|
| 68 | /**chardata [a-zA-Z0-9_\-.:" "\"\'\\]***/ |
---|
| 69 | chardata [^<]* |
---|
| 70 | /*====================================================*/ |
---|
| 71 | attname [a-zA-Z0-9_\-:]+ |
---|
| 72 | attvalue1 [,@a-zA-Z0-9_\-.:" "\"\'/\\]+ |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | /*====================================================*/ |
---|
| 79 | /* attvalue regle 10 */ |
---|
| 80 | /*====================================================*/ |
---|
| 81 | /* attvalue \"([^"&]|{CharRef})*\"|\'([^'&]|{CharRef})*\' */ |
---|
| 82 | /* pas tr� classe mais ca marche . */ |
---|
| 83 | attvalue \"[^"]*\"|\'[^']*\' |
---|
| 84 | /*====================================================*/ |
---|
| 85 | |
---|
| 86 | virgule [,]+ |
---|
| 87 | whitespace [ ]{0,} |
---|
| 88 | whitesp [ ] |
---|
| 89 | newline [\r\n]|[\n] |
---|
| 90 | newlines [\r\n]{1,}|[\n]{1,} |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | /*====================================================*/ |
---|
| 102 | /* initial = de debut a ?> du prolog ; DANSBALISE = dans une balise ; HORSBALISE = hors d'une balise */ |
---|
| 103 | /*====================================================*/ |
---|
| 104 | %x DANSBALISE HORSBALISE PAIRSTART |
---|
| 105 | /*====================================================*/ |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | %% |
---|
| 111 | |
---|
| 112 | "\n" {if (affichetrace==1) printf ("\n\nNEWLINE\n") ; return NEWLINE;} |
---|
| 113 | |
---|
| 114 | {newline}+{whitesp}* {if (affichetrace==1) printf ("\n\nNEWLINE 1\n") ; return NEWLINE;} |
---|
| 115 | |
---|
| 116 | <INITIAL,HORSBALISE>"["{attname}"]" {if (affichetrace==1) printf ("\n\nANID:%s\n",yytext); crlval.chaine=strdup(yytext);crlval.chaine[strlen(crlval.chaine)-1]=0;crlval.chaine+=1;return ANID; } |
---|
| 117 | |
---|
| 118 | <INITIAL,HORSBALISE>{attname} {if (affichetrace==1) printf ("\n\nATT_NAME:%s\n",yytext); crlval.chaine=strdup(yytext); return SPAIR; } |
---|
| 119 | |
---|
| 120 | <PAIRSTART,HORSBALISE>{attvalue1} {if (affichetrace==1) printf ("\n\nATT_VALUE:%s\n",yytext);crlval.chaine=strdup(yytext);BEGIN(INITIAL);return EPAIR;} |
---|
| 121 | |
---|
| 122 | <PAIRSTART,INITIAL,HORSBALISE>{whitesp}*"="{whitesp}* {BEGIN(PAIRSTART);} |
---|
| 123 | |
---|
| 124 | <PAIRSTART,INITIAL,HORSBALISE,DANSBALISE>{newline}+{whitesp}* {if (affichetrace==1) printf ("\n\nNEWLINE 2\n") ; BEGIN(INITIAL); return NEWLINE;} |
---|
| 125 | |
---|
| 126 | <INITIAL>"<?"[Xx][Mm][Ll] { if (attentionImpossibleDeTrouverXMLDeclapres == 1 || attentionImpossibleDeTrouverPIapres == 1) {/* il y a eut un commentaire ou une balise applicative avant la declaration xml */ printf("\nerror : a la ligne %d : il y a eut un commentaire ou un PI avant la declaration xml\n",yylineno); exit (10) ; } ; if (affichetrace==1) printf ("\n\nSTARTXMLDECL:%s\n",yytext) ;return STARTXMLDECL;} |
---|
| 127 | |
---|
| 128 | <INITIAL>"version"{egalevolue}\"1.0\"|"version"{egalevolue}\'1.0\' {if (affichetrace==1) printf ("\n\nVERSIONDECL:%s\n",yytext) ;return VERSIONDECL;} |
---|
| 129 | <INITIAL>"version"{egalevolue}\"[^"]*\"|"version"{egalevolue}\'[^']*\' {/* erreur de version encoding */ printf("\nerror : a la ligne %d : la version xml n est pas reconnue : %s\n",yylineno,yytext); exit (9) ; } |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | <INITIAL>"encoding"{egalevolue}\"[Ii][Ss][Oo]"-8859-1"\"|"encoding"{egalevolue}\'[Ii][Ss][Oo]"-8859-1"\' {if (affichetrace==1) printf ("\n\nENCODINGDECL:%s\n",yytext) ; return ENCODINGDECL;} |
---|
| 133 | <INITIAL>"encoding"{egalevolue}\"[^"]*\"|"encoding"{egalevolue}\'[^']*\' {/* erreur de version encoding */ printf("\nerror : a la ligne %d : la version d encodage n est pas reconnue : %s\n",yylineno,yytext); exit (8) ; } |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | <INITIAL>"standalone"{egalevolue}\"yes\"|"standalone"{egalevolue}\'yes\'|"standalone"{egalevolue}\"no\"|"standalone"{egalevolue}\'no\' {if (affichetrace==1) printf ("\n\nSDDECL:%s\n",yytext) ; return SDDECL;} |
---|
| 137 | |
---|
| 138 | <INITIAL>"standalone"{egalevolue}\"[^"]*\"|"standalone"{egalevolue}\'[^']*\'|"standalone"{egalevolue}\"[^"]*\"|"standalone"{egalevolue}\'[^']*\' {/* erreur de version encoding */ printf("\nerror : a la ligne %d : la version standalone n est pas reconnue : %s\n",yylineno,yytext); exit (7) ; } |
---|
| 139 | |
---|
| 140 | |
---|
| 141 | <INITIAL>"?>" {if (affichetrace==1) printf ("\n\nENDXMLDECL:%s\n",yytext) ; BEGIN(HORSBALISE);return ENDXMLDECL;} |
---|
| 142 | |
---|
| 143 | |
---|
| 144 | <DANSBALISE,INITIAL,HORSBALISE>{S} {if (affichetrace==1) printf ("\n\nS:'%s'\n",yytext) ; } |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | <HORSBALISE>"<?"[Xx][Mm][Ll]{S}({S}|{chardata})*"?>"|"<?"[Xx][Mm][Ll]"?>" {if (affichetrace==1) printf ("\n\nPIERROR:%s\n",yytext) ; return PIERROR;} |
---|
| 148 | <INITIAL,HORSBALISE>"<?"([^xX]|([xX][^mM])|([xX][mM][^lL]))({S}|([^?]|("?"[^>])))*"?>" {attentionImpossibleDeTrouverPIapres=1 ; if (affichetrace==1) printf ("\n\nPI:%s\n",yytext) ; return PI;} |
---|
| 149 | |
---|
| 150 | |
---|
| 151 | <INITIAL,HORSBALISE>{newline}*"<" {if (affichetrace==1) printf ("\n\nINFCAR:%s\n",yytext) ; BEGIN(DANSBALISE);return INFCAR;} |
---|
| 152 | |
---|
| 153 | |
---|
| 154 | <DANSBALISE>">" {if (affichetrace==1) printf ("\n\nSUPCAR:%s\n",yytext) ; BEGIN(HORSBALISE);return SUPCAR;} |
---|
| 155 | |
---|
| 156 | |
---|
| 157 | <DANSBALISE>"/" {if (affichetrace==1) printf ("\n\nSLASH:%s\n",yytext) ; return SLASH;} |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | <DANSBALISE>{egalevolue} {if (affichetrace==1) printf ("\n\nEq:'%s'\n",yytext) ; return Eq;} |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | <DANSBALISE>{Name} {if (affichetrace==1) printf ("\n\nID:%s\n",yytext) ; crlval.s=strdup(yytext);return ID;} |
---|
| 164 | |
---|
| 165 | |
---|
| 166 | <DANSBALISE>{attvalue} {if (affichetrace==1) printf ("\n\nATTVALUE:%s\n",yytext) ; return ATTVALUE;} |
---|
| 167 | |
---|
| 168 | |
---|
| 169 | <INITIAL,HORSBALISE>"<!--"([^-]|"-"[^-])*"-->" {attentionImpossibleDeTrouverXMLDeclapres=1; } |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | <INITIAL,DANSBALISE,HORSBALISE>.|\n {if (affichetrace==1)printf("error : ligne %d : caractere non reconnu '%s'\n",yylineno,yytext); } |
---|
| 173 | |
---|
| 174 | %% |
---|
| 175 | |
---|
| 176 | |
---|
| 177 | int yywrap() |
---|
| 178 | {return 1;} |
---|