1 | /* Line number from bison */ |
---|
2 | %option yylineno |
---|
3 | |
---|
4 | %{ |
---|
5 | //====================================================== |
---|
6 | /** |
---|
7 | Zoo main configuration file parser |
---|
8 | **/ |
---|
9 | //====================================================== |
---|
10 | |
---|
11 | |
---|
12 | #include <string.h> |
---|
13 | #include "main_conf_read.tab.h" |
---|
14 | static int affichetrace = 0 ; |
---|
15 | static int attentionImpossibleDeTrouverXMLDeclapres = 0 ; |
---|
16 | static int attentionImpossibleDeTrouverPIapres = 0 ; |
---|
17 | |
---|
18 | %} |
---|
19 | |
---|
20 | |
---|
21 | S [ \t\r\n]+ |
---|
22 | |
---|
23 | CharRef "&#"[0-9]+";"|"&#x"[0-9a-fA-F]+";" |
---|
24 | |
---|
25 | egalevolue {S}?"="{S}? |
---|
26 | |
---|
27 | Name ([_:]|[\x41-\x5A]|[\x61-\x7A]|[\xC0-\xD6]|[\xD8-\xF6]|[\xF8-\xFF])(([\x41-\x5A]|[\x61-\x7A]|[\xC0-\xD6]|[\xD8-\xF6]|[\xF8-\xFF])|[0-9.\-_:])* |
---|
28 | |
---|
29 | chardata [^<]* |
---|
30 | |
---|
31 | attname [a-zA-Z0-9_\-:]+ |
---|
32 | |
---|
33 | attvalue1 [,@a-zA-Z0-9_\-.:" "\"\'/\\\(\)\+\x41-\xff]+ |
---|
34 | |
---|
35 | attvalue \"[^"]*\"|\'[^']*\' |
---|
36 | |
---|
37 | virgule [,]+ |
---|
38 | |
---|
39 | whitespace [ ]{0,} |
---|
40 | whitesp [ ] |
---|
41 | newline [\r\n]|[\n] |
---|
42 | newlines [\r\n]{1,}|[\n]{1,} |
---|
43 | |
---|
44 | |
---|
45 | |
---|
46 | %x DANSBALISE HORSBALISE PAIRSTART |
---|
47 | |
---|
48 | |
---|
49 | |
---|
50 | |
---|
51 | %% |
---|
52 | |
---|
53 | "\n" {if (affichetrace==1) printf ("\n\nNEWLINE\n") ; return NEWLINE;} |
---|
54 | |
---|
55 | {newline}+{whitesp}* {if (affichetrace==1) printf ("\n\nNEWLINE 1\n") ; return NEWLINE;} |
---|
56 | |
---|
57 | <INITIAL,HORSBALISE>"["{attname}"]" {if (affichetrace==1) printf ("\n\nANID:%s\n",yytext); crlval.chaine=yytext;crlval.chaine[strlen(crlval.chaine)-1]=0;crlval.chaine+=1;return ANID; } |
---|
58 | |
---|
59 | <INITIAL,HORSBALISE>{attname} {if (affichetrace==1) printf ("\n\nATT_NAME:%s\n",yytext); crlval.chaine=yytext; return SPAIR; } |
---|
60 | |
---|
61 | <PAIRSTART,HORSBALISE>{attvalue1} {if (affichetrace==1) printf ("\n\nATT_VALUE:%s\n",yytext);crlval.chaine=yytext;BEGIN(INITIAL);return EPAIR;} |
---|
62 | |
---|
63 | <PAIRSTART,INITIAL,HORSBALISE>{whitesp}*"="{whitesp}* {BEGIN(PAIRSTART);} |
---|
64 | |
---|
65 | <PAIRSTART,INITIAL,HORSBALISE,DANSBALISE>{newline}+{whitesp}* {if (affichetrace==1) printf ("\n\nNEWLINE 2\n") ; BEGIN(INITIAL); return NEWLINE;} |
---|
66 | |
---|
67 | <INITIAL>"<?"[Xx][Mm][Ll] { if (attentionImpossibleDeTrouverXMLDeclapres == 1 || attentionImpossibleDeTrouverPIapres == 1) { printf("\nerror : LINE %d : comment ot PI before xml declaration\n",yylineno); exit (10) ; } ; if (affichetrace==1) printf ("\n\nSTARTXMLDECL:%s\n",yytext) ;return STARTXMLDECL;} |
---|
68 | |
---|
69 | <INITIAL>"version"{egalevolue}\"1.0\"|"version"{egalevolue}\'1.0\' {if (affichetrace==1) printf ("\n\nVERSIONDECL:%s\n",yytext) ;return VERSIONDECL;} |
---|
70 | <INITIAL>"version"{egalevolue}\"[^"]*\"|"version"{egalevolue}\'[^']*\' {/* erreur de version encoding */ printf("\nerror : LINE %d : XML Version not supported : %s\n",yylineno,yytext); exit (9) ; } |
---|
71 | |
---|
72 | |
---|
73 | <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;} |
---|
74 | <INITIAL>"encoding"{egalevolue}\"[^"]*\"|"encoding"{egalevolue}\'[^']*\' {/* erreur de version encoding */ printf("\nerror : LINE %d : encoding version not supported : %s\n",yylineno,yytext); exit (8) ; } |
---|
75 | |
---|
76 | |
---|
77 | <INITIAL>"standalone"{egalevolue}\"yes\"|"standalone"{egalevolue}\'yes\'|"standalone"{egalevolue}\"no\"|"standalone"{egalevolue}\'no\' {if (affichetrace==1) printf ("\n\nSDDECL:%s\n",yytext) ; return SDDECL;} |
---|
78 | |
---|
79 | <INITIAL>"standalone"{egalevolue}\"[^"]*\"|"standalone"{egalevolue}\'[^']*\'|"standalone"{egalevolue}\"[^"]*\"|"standalone"{egalevolue}\'[^']*\' {/* erreur de version encoding */ printf("\nerror : LINE %d : standalone version not supported : %s\n",yylineno,yytext); exit (7) ; } |
---|
80 | |
---|
81 | |
---|
82 | <INITIAL>"?>" {if (affichetrace==1) printf ("\n\nENDXMLDECL:%s\n",yytext) ; BEGIN(HORSBALISE);return ENDXMLDECL;} |
---|
83 | |
---|
84 | |
---|
85 | <DANSBALISE,INITIAL,HORSBALISE>{S} {if (affichetrace==1) printf ("\n\nS:'%s'\n",yytext) ; } |
---|
86 | |
---|
87 | |
---|
88 | <HORSBALISE>"<?"[Xx][Mm][Ll]{S}({S}|{chardata})*"?>"|"<?"[Xx][Mm][Ll]"?>" {if (affichetrace==1) printf ("\n\nPIERROR:%s\n",yytext) ; return PIERROR;} |
---|
89 | <INITIAL,HORSBALISE>"<?"([^xX]|([xX][^mM])|([xX][mM][^lL]))({S}|([^?]|("?"[^>])))*"?>" {attentionImpossibleDeTrouverPIapres=1 ; if (affichetrace==1) printf ("\n\nPI:%s\n",yytext) ; return PI;} |
---|
90 | |
---|
91 | |
---|
92 | <INITIAL,HORSBALISE>{newline}*"<" {if (affichetrace==1) printf ("\n\nINFCAR:%s\n",yytext) ; BEGIN(DANSBALISE);return INFCAR;} |
---|
93 | |
---|
94 | |
---|
95 | <DANSBALISE>">" {if (affichetrace==1) printf ("\n\nSUPCAR:%s\n",yytext) ; BEGIN(HORSBALISE);return SUPCAR;} |
---|
96 | |
---|
97 | |
---|
98 | <DANSBALISE>"/" {if (affichetrace==1) printf ("\n\nSLASH:%s\n",yytext) ; return SLASH;} |
---|
99 | |
---|
100 | |
---|
101 | <DANSBALISE>{egalevolue} {if (affichetrace==1) printf ("\n\nEq:'%s'\n",yytext) ; return Eq;} |
---|
102 | |
---|
103 | |
---|
104 | <DANSBALISE>{Name} {if (affichetrace==1) printf ("\n\nID:%s\n",yytext) ; crlval.s=yytext;return ID;} |
---|
105 | |
---|
106 | |
---|
107 | <DANSBALISE>{attvalue} {if (affichetrace==1) printf ("\n\nATTVALUE:%s\n",yytext) ; return ATTVALUE;} |
---|
108 | |
---|
109 | |
---|
110 | <INITIAL,HORSBALISE>"<!--"([^-]|"-"[^-])*"-->" {attentionImpossibleDeTrouverXMLDeclapres=1; } |
---|
111 | |
---|
112 | |
---|
113 | <INITIAL,DANSBALISE,HORSBALISE>.|\n {if (affichetrace==1)printf("error : LINE %d : character not supported '%s'\n",yylineno,yytext); } |
---|
114 | |
---|
115 | %% |
---|
116 | |
---|
117 | |
---|
118 | int crwrap() |
---|
119 | {return 1;} |
---|