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_\-]+ |
---|
126 | attvalue1 [a-zA-Z0-9_\-.:" "\"\'/\\\(\)]+ |
---|
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 | |
---|
161 | <INITIAL,HORSBALISE>"["{attname}"]" { if (affichetrace==1){ fprintf (stderr,"\n\nANID:%s\n",yytext); fprintf(stderr,"[ZOO: service_conf.l line 161 srlval.chaine=strdup(%s), srlval.chaine=%s]\n",yytext,srlval.chaine);fflush(stderr);}srlval.chaine=strdup(yytext);srlval.chaine[strlen(srlval.chaine)-1]=0;srlval.chaine+=1;if (affichetrace==1){fprintf(stderr,"[ZOO: service_conf.l line 161 srlval.chaine=strdup(%s) done]\n",yytext);fflush(stderr);} return ANID; } |
---|
162 | |
---|
163 | <INITIAL,HORSBALISE>{attname} { if (affichetrace==1){fprintf (stderr,"\n\nATT_NAME:%s\n",yytext); fprintf(stderr,"[ZOO: service_conf.l line 163 srlval.chaine=strdup(%s)]\n",yytext);fflush(stderr);}srlval.chaine=strdup(yytext); if (affichetrace==1){fprintf(stderr,"[ZOO: service_conf.l line 163 srlval.chaine=strdup(%s) done]\n",yytext);fflush(stderr);} return SPAIR; } |
---|
164 | |
---|
165 | <PAIRSTART,HORSBALISE>{attvalue1} { if (affichetrace==1){ fprintf (stderr,"\n\nATT_VALUE:%s\n",yytext);fprintf(stderr,"[ZOO: service_conf.l line 165 srlval.chaine=strdup(%s)]\n",yytext);fflush(stderr);}srlval.chaine=strdup(yytext);if (affichetrace==1){fprintf(stderr,"[ZOO: service_conf.l line 165 srlval.chaine=strdup(%s)]\n",yytext);fflush(stderr);BEGIN(INITIAL);} return EPAIR;} |
---|
166 | |
---|
167 | <PAIRSTART,INITIAL,HORSBALISE>{whitesp}*"="{whitesp}* { BEGIN(PAIRSTART);} |
---|
168 | |
---|
169 | <PAIRSTART,INITIAL,HORSBALISE,DANSBALISE>{newline}+{whitesp}* { if (affichetrace==1) fprintf (stderr,"\n\nNEWLINE 2\n") ; BEGIN(INITIAL); return NEWLINE;} |
---|
170 | |
---|
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) ; } ; if (affichetrace==1) fprintf (stderr,"\n\nSTARTXMLDECL:%s\n",srtext) ; return STARTXMLDECL;} |
---|
172 | |
---|
173 | <INITIAL>"version"{egalevolue}\"1.0\"|"version"{egalevolue}\'1.0\' { if (affichetrace==1) fprintf (stderr,"\n\nVERSIONDECL:%s\n",srtext) ;return VERSIONDECL; } |
---|
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 | |
---|
177 | <INITIAL>"encoding"{egalevolue}\"[Ii][Ss][Oo]"-8859-1"\"|"encoding"{egalevolue}\'[Ii][Ss][Oo]"-8859-1"\' { if (affichetrace==1) fprintf (stderr,"\n\nENCODINGDECL:%s\n",yytext) ; return ENCODINGDECL;} |
---|
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 | |
---|
181 | <INITIAL>"standalone"{egalevolue}\"yes\"|"standalone"{egalevolue}\'yes\'|"standalone"{egalevolue}\"no\"|"standalone"{egalevolue}\'no\' { if (affichetrace==1) fprintf (stderr,"\n\nSDDECL:%s\n",yytext) ; return SDDECL;} |
---|
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 | |
---|
186 | <INITIAL>"?>" { if (affichetrace==1) fprintf (stderr,"\n\nENDXMLDECL:%s\n",yytext) ; BEGIN(HORSBALISE); return ENDXMLDECL;} |
---|
187 | |
---|
188 | |
---|
189 | <DANSBALISE,INITIAL,HORSBALISE>{S} { if (affichetrace==1) fprintf (stderr,"\n\nS:'%s'\n",yytext) ; } |
---|
190 | |
---|
191 | |
---|
192 | <HORSBALISE>"<?"[Xx][Mm][Ll]{S}({S}|{chardata})*"?>"|"<?"[Xx][Mm][Ll]"?>" { if (affichetrace==1) fprintf (stderr,"\n\nPIERROR:%s\n",yytext) ; return PIERROR;} |
---|
193 | <INITIAL,HORSBALISE>"<?"([^xX]|([xX][^mM])|([xX][mM][^lL]))({S}|([^?]|("?"[^>])))*"?>" { attentionImpossibleDeTrouverPIapres=1 ; if (affichetrace==1) fprintf (stderr,"\n\nPI:%s\n",yytext) ; return PI;} |
---|
194 | |
---|
195 | |
---|
196 | <INITIAL,HORSBALISE>{newline}*"<" { if (affichetrace==1) fprintf (stderr,"\n\nINFCAR:%s\n",yytext) ; BEGIN(DANSBALISE); return INFCAR;} |
---|
197 | |
---|
198 | |
---|
199 | <DANSBALISE>">" { if (affichetrace==1) fprintf (stderr,"\n\nSUPCAR:%s\n",yytext) ; BEGIN(HORSBALISE);return SUPCAR;} |
---|
200 | |
---|
201 | |
---|
202 | <DANSBALISE>"/" {if (affichetrace==1) fprintf (stderr,"\n\nSLASH:%s\n",yytext) ; return SLASH;} |
---|
203 | |
---|
204 | |
---|
205 | <DANSBALISE>{egalevolue} {if (affichetrace==1) fprintf (stderr,"\n\nEq:'%s'\n",yytext) ; return Eq;} |
---|
206 | |
---|
207 | |
---|
208 | <DANSBALISE>{Name} {if (affichetrace==1){fprintf (stderr,"\n\nID:%s\n",yytext) ; fprintf(stderr,"[ZOO: service_conf.l line 208 srlval.chaine=strdup(%s)]\n",yytext);fflush(stderr);}srlval.s=strdup(yytext);if (affichetrace==1){fprintf(stderr,"[ZOO: service_conf.l line 208 srlval.chaine=strdup(%s)]\n",yytext);fflush(stderr);}return ID;} |
---|
209 | |
---|
210 | |
---|
211 | <DANSBALISE>{attvalue} {if (affichetrace==1) fprintf (stderr,"\n\nATTVALUE:%s\n",yytext) ; return ATTVALUE;} |
---|
212 | |
---|
213 | |
---|
214 | <INITIAL,HORSBALISE>"<!--"([^-]|"-"[^-])*"-->" {attentionImpossibleDeTrouverXMLDeclapres=1; } |
---|
215 | |
---|
216 | |
---|
217 | <INITIAL,DANSBALISE,HORSBALISE>.|\n {if (affichetrace==1) fprintf(stderr,"error : ligne %d : caractere non reconnu '%s'\n",srlineno,yytext);} |
---|
218 | |
---|
219 | %% |
---|
220 | |
---|