source: trunk/zoo-kernel/main_conf_read.l @ 11

Last change on this file since 11 was 11, checked in by djay, 14 years ago

Small fix for ticket #7. Thanks to relet for his feedbacks.

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

Search

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png