1 | /* |
---|
2 | * Author : Gérald FENOY |
---|
3 | * |
---|
4 | * Copyright (c) 209-2015 GeoLabs SARL |
---|
5 | * |
---|
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
7 | * of this software and associated documentation files (the "Software"), to deal |
---|
8 | * in the Software without restriction, including without limitation the rights |
---|
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
10 | * copies of the Software, and to permit persons to whom the Software is |
---|
11 | * furnished to do so, subject to the following conditions: |
---|
12 | * |
---|
13 | * The above copyright notice and this permission notice shall be included in |
---|
14 | * all copies or substantial portions of the Software. |
---|
15 | * |
---|
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
22 | * THE SOFTWARE. |
---|
23 | */ |
---|
24 | %option noyywrap |
---|
25 | %option yylineno |
---|
26 | |
---|
27 | |
---|
28 | %{ |
---|
29 | |
---|
30 | #include <string.h> |
---|
31 | #include "service_conf.tab.h" |
---|
32 | |
---|
33 | char *lmsg=NULL; |
---|
34 | |
---|
35 | %} |
---|
36 | |
---|
37 | S [ \t\r\n]+ |
---|
38 | |
---|
39 | CharRef "&#"[0-9]+";"|"&#x"[0-9a-fA-F]+";" |
---|
40 | |
---|
41 | egalevolue {S}?"="{S}? |
---|
42 | |
---|
43 | Name ([_:]|[\x41-\x5A]|[\x61-\x7A]|[\xC0-\xD6]|[\xD8-\xF6]|[\xF8-\xFF])(([\x41-\x5A]|[\x61-\x7A]|[\xC0-\xD6]|[\xD8-\xF6]|[\xF8-\xFF])|[0-9.\-_:])* |
---|
44 | |
---|
45 | chardata [^<]* |
---|
46 | |
---|
47 | attname [a-zA-Z0-9._\-]+ |
---|
48 | attvalue1 [\x80-\xbf\xc2-\xdf\xe0-\xef\xf0-\xf4#°²θé\^\*\+\,\;?!~`ú@a-zA-Z0-9%_\-:\:.:" "\"\'/\\\(\)\t\|\$\&>\[\]]+ |
---|
49 | |
---|
50 | attvalue \"[^"]*\"|\'[^']*\'\(\) |
---|
51 | |
---|
52 | whitespace [\t]{0,}|[ ]{0,} |
---|
53 | whitesp [\t]|[ ] |
---|
54 | newline [\r\n]|[\n] |
---|
55 | newlines [\r\n]{1,}|[\n]{1,} |
---|
56 | |
---|
57 | |
---|
58 | %x DANSBALISE HORSBALISE PAIRSTART |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | %% |
---|
64 | |
---|
65 | "\n" { } |
---|
66 | |
---|
67 | {newline}+{whitesp}* { return NEWLINE; } |
---|
68 | |
---|
69 | <INITIAL,HORSBALISE>"["{attname}"]" { srlval.chaine=yytext;return ANID; } |
---|
70 | |
---|
71 | <INITIAL,HORSBALISE>{attname} { srlval.chaine=yytext; return SPAIR; } |
---|
72 | |
---|
73 | <PAIRSTART,HORSBALISE>{attvalue1} { srlval.chaine=yytext;/*BEGIN(INITIAL);*/ return EPAIR;} |
---|
74 | |
---|
75 | <PAIRSTART,INITIAL,HORSBALISE>{whitesp}*"="{whitesp}* { BEGIN(PAIRSTART);} |
---|
76 | |
---|
77 | <PAIRSTART,INITIAL,HORSBALISE>{newline}+{whitesp}* { BEGIN(INITIAL); return NEWLINE;} |
---|
78 | |
---|
79 | <DANSBALISE,INITIAL,HORSBALISE>{S} { } |
---|
80 | |
---|
81 | <INITIAL,HORSBALISE>{newline}*"<" { BEGIN(DANSBALISE); return INFCAR;} |
---|
82 | |
---|
83 | |
---|
84 | <DANSBALISE>">" { BEGIN(HORSBALISE);return SUPCAR;} |
---|
85 | |
---|
86 | |
---|
87 | <DANSBALISE>"/" {return SLASH;} |
---|
88 | |
---|
89 | |
---|
90 | <DANSBALISE>{egalevolue} {return Eq;} |
---|
91 | |
---|
92 | |
---|
93 | <DANSBALISE>{Name}{newline}* {memmove(srlval.chaine,yytext,(strlen(yytext)+1)*sizeof(char));return ID;} |
---|
94 | |
---|
95 | |
---|
96 | <DANSBALISE>{attvalue} {return ATTVALUE;} |
---|
97 | |
---|
98 | |
---|
99 | <INITIAL,DANSBALISE,HORSBALISE>.|\n {lmsg=(char*)malloc(1024*sizeof(char));sprintf(lmsg,"error: line %d: character not allowed '%s'",srlineno,yytext);fprintf(stderr,"%s \n",lmsg);srlval.chaine=lmsg;fprintf(stderr,"%s \n",lmsg);return -1;} |
---|
100 | |
---|
101 | %% |
---|
102 | |
---|