1340
|
1 /********************************************************************************************************* |
|
2 * Software License Agreement (BSD License) * |
|
3 * Authors: Thomas Klausner <tk@giga.or.at> based on code by Sebastien Decugis <sdecugis@freediameter.net>* |
|
4 * * |
|
5 * Copyright (c) 2018, Thomas Klausner * |
|
6 * Copyright (c) 2013, WIDE Project and NICT * |
|
7 * All rights reserved. * |
|
8 * * |
|
9 * Written under contract by Effortel Technologies SA, http://effortel.com/ * |
|
10 * * |
|
11 * Redistribution and use of this software in source and binary forms, with or without modification, are * |
|
12 * permitted provided that the following conditions are met: * |
|
13 * * |
|
14 * * Redistributions of source code must retain the above * |
|
15 * copyright notice, this list of conditions and the * |
|
16 * following disclaimer. * |
|
17 * * |
|
18 * * Redistributions in binary form must reproduce the above * |
|
19 * copyright notice, this list of conditions and the * |
|
20 * following disclaimer in the documentation and/or other * |
|
21 * materials provided with the distribution. * |
|
22 * * |
|
23 * * Neither the name of the WIDE Project or NICT nor the * |
|
24 * names of its contributors may be used to endorse or * |
|
25 * promote products derived from this software without * |
|
26 * specific prior written permission of WIDE Project and * |
|
27 * NICT. * |
|
28 * * |
|
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * |
|
30 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * |
|
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * |
|
32 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
|
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * |
|
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * |
|
35 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * |
|
36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
|
37 *********************************************************************************************************/ |
|
38 |
|
39 /* Tokenizer |
|
40 * |
|
41 */ |
|
42 |
|
43 %{ |
|
44 #include "rt_deny_by_size.h" |
|
45 #include "rt_deny_by_size_conf.tab.h" |
|
46 |
|
47 /* Update the column information */ |
|
48 #define YY_USER_ACTION { \ |
|
49 yylloc->first_column = yylloc->last_column + 1; \ |
|
50 yylloc->last_column = yylloc->first_column + yyleng - 1; \ |
|
51 } |
|
52 |
|
53 /* Avoid warning with newer flex */ |
|
54 #define YY_NO_INPUT |
|
55 |
|
56 %} |
|
57 |
|
58 qstring \"[^\"\n]*\" |
|
59 |
|
60 |
|
61 %option bison-bridge bison-locations |
|
62 %option noyywrap |
|
63 %option nounput |
|
64 |
|
65 %% |
|
66 |
|
67 /* Update the line count */ |
|
68 \n { |
|
69 yylloc->first_line++; |
|
70 yylloc->last_line++; |
|
71 yylloc->last_column=0; |
|
72 } |
|
73 |
|
74 /* Eat all spaces but not new lines */ |
|
75 ([[:space:]]{-}[\n])+ ; |
|
76 /* Eat all comments */ |
|
77 #.*$ ; |
|
78 |
|
79 /* Recognize any integer */ |
|
80 [-]?[[:digit:]]+ { |
|
81 /* Convert this to an integer value */ |
|
82 int ret=0; |
|
83 ret = sscanf(yytext, "%i", &yylval->integer); |
|
84 if (ret != 1) { |
|
85 /* No matching: an error occurred */ |
|
86 TRACE_ERROR("Unable to convert the value '%s' to a valid number: %s", yytext, strerror(errno)); |
|
87 return LEX_ERROR; /* trig an error in yacc parser */ |
|
88 /* Maybe we could REJECT instead of failing here? */ |
|
89 } |
|
90 return INTEGER; |
|
91 } |
|
92 |
|
93 |
|
94 |
|
95 /* The key words */ |
|
96 (?i:"MaximumSize") { return MAXIMUMSIZE; } |
|
97 |
|
98 /* Valid single characters for yyparse */ |
|
99 [=;] { return yytext[0]; } |
|
100 |
|
101 /* Unrecognized sequence, if it did not match any previous pattern */ |
|
102 [^[:space:]=;\n]+ { |
|
103 TRACE_ERROR("Unrecognized text on line %d col %d: '%s'.", yylloc->first_line, yylloc->first_column, yytext); |
|
104 return LEX_ERROR; |
|
105 } |
|
106 |
|
107 %% |