Changeset 621 for trunk/zoo-project/zoo-kernel/main_conf_read.l
- Timestamp:
- Apr 9, 2015, 5:23:06 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/main_conf_read.l
r378 r621 1 /* Line number from bison */ 1 /* 2 * Zoo main configuration file parser 3 * 4 * Author : Gérald FENOY 5 * 6 * Copyright (c) 209-2015 GeoLabs SARL 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a copy 9 * of this software and associated documentation files (the "Software"), to deal 10 * in the Software without restriction, including without limitation the rights 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 * copies of the Software, and to permit persons to whom the Software is 13 * furnished to do so, subject to the following conditions: 14 * 15 * The above copyright notice and this permission notice shall be included in 16 * all copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 * THE SOFTWARE. 25 */ 2 26 %option yylineno 3 27 4 28 %{ 5 //======================================================6 /**7 Zoo main configuration file parser8 **/9 //======================================================10 11 29 12 30 #include <string.h> 13 31 #include "main_conf_read.tab.h" 14 32 static int affichetrace = 0 ; 15 static int attentionImpossibleDeTrouverXMLDeclapres = 0 ;16 static int attentionImpossibleDeTrouverPIapres = 0 ;17 33 18 34 %} 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 35 31 36 attname [a-zA-Z0-9_\-:]+ … … 33 38 attvalue1 [%\*,;@a-zA-Z0-9_\-.:" "\"\'/\\\(\)\+\x41-\xff]+ 34 39 35 attvalue \"[^"]*\"|\'[^']*\'36 37 virgule [,]+38 39 whitespace [ ]{0,}40 40 whitesp [ ] 41 41 newline [\r\n]|[\n] 42 newlines [\r\n]{1,}|[\n]{1,}43 44 45 42 46 43 %x DANSBALISE HORSBALISE PAIRSTART 47 48 49 50 44 51 45 %% … … 65 59 <PAIRSTART,INITIAL,HORSBALISE,DANSBALISE>{newline}+{whitesp}* {if (affichetrace==1) printf ("\n\nNEWLINE 2\n") ; BEGIN(INITIAL); return NEWLINE;} 66 60 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 61 %% 116 62
Note: See TracChangeset
for help on using the changeset viewer.