Ignore:
Timestamp:
Apr 9, 2015, 5:23:06 AM (8 years ago)
Author:
djay
Message:

Major update. Creation of a basic parsing api. Call validateRequest after fork if any.

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 */
    226%option yylineno
    327
    428%{
    5 //======================================================
    6 /**
    7 Zoo main configuration file parser
    8 **/
    9 //======================================================
    10 
    1129
    1230#include <string.h>
    1331#include "main_conf_read.tab.h"
    1432static int affichetrace = 0 ;
    15 static int attentionImpossibleDeTrouverXMLDeclapres = 0 ;
    16 static int attentionImpossibleDeTrouverPIapres = 0 ;
    1733
    1834%}
    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        [^<]*
    3035
    3136attname [a-zA-Z0-9_\-:]+
     
    3338attvalue1       [%\*,;@a-zA-Z0-9_\-.:" "\"\'/\\\(\)\+\x41-\xff]+
    3439
    35 attvalue                \"[^"]*\"|\'[^']*\'
    36 
    37 virgule [,]+
    38 
    39 whitespace                      [ ]{0,}
    4040whitesp                      [ ]
    4141newline                 [\r\n]|[\n]
    42 newlines                 [\r\n]{1,}|[\n]{1,}
    43 
    44 
    4542
    4643%x DANSBALISE HORSBALISE PAIRSTART
    47 
    48 
    49 
    5044
    5145%%
     
    6559<PAIRSTART,INITIAL,HORSBALISE,DANSBALISE>{newline}+{whitesp}*                   {if (affichetrace==1) printf ("\n\nNEWLINE 2\n") ; BEGIN(INITIAL); return NEWLINE;}
    6660
    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 
    11561%%
    11662
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

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