Commit | Line | Data |
---|---|---|
970ed795 | 1 | /****************************************************************************** |
d44e3c4f | 2 | * Copyright (c) 2000-2016 Ericsson Telecom AB |
970ed795 EL |
3 | * All rights reserved. This program and the accompanying materials |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
d44e3c4f | 7 | * |
8 | * Contributors: | |
9 | * Baji, Laszlo | |
10 | * Balasko, Jeno | |
11 | * Baranyi, Botond | |
12 | * Beres, Szabolcs | |
13 | * Delic, Adam | |
14 | * Forstner, Matyas | |
15 | * Kovacs, Ferenc | |
16 | * Pandi, Krisztian | |
17 | * Raduly, Csaba | |
18 | * Szabados, Kristof | |
19700695 | 19 | * Szabo, Bence Janos |
d44e3c4f | 20 | * Szabo, Janos Zoltan – initial implementation |
21 | * Szalai, Gabor | |
22 | * Zalanyi, Balazs Andor | |
23 | * | |
970ed795 EL |
24 | ******************************************************************************/ |
25 | %option noyywrap | |
26 | %option never-interactive | |
27 | %option nounput | |
28 | ||
29 | %{ | |
30 | ||
31 | #include <string.h> | |
32 | #include <stdlib.h> | |
33 | #include <assert.h> | |
34 | ||
35 | #include <deque> | |
36 | #include <string> | |
37 | ||
38 | #include "../common/cfg_process_utils.hh" | |
39 | #include "../common/Path2.hh" | |
40 | ||
41 | #include "../common/memory.h" | |
42 | #include "Types.h" | |
43 | #include "Parameters.h" | |
44 | #include "Param_Types.hh" | |
45 | #include "Port.hh" | |
46 | #include "LoggingBits.hh" | |
47 | #include "LoggingParam.hh" | |
48 | #include "Error.hh" | |
49 | #include "config_process.tab.hh" | |
50 | #include "../common/config_preproc.h" | |
51 | #include "../common/path.h" | |
52 | ||
53 | #include "../common/dbgnew.hh" | |
54 | ||
a38c6d4c | 55 | #include "Profiler.hh" |
56 | ||
970ed795 EL |
57 | extern string_map_t *config_defines; |
58 | ||
59 | #define yylval config_process_lval | |
60 | ||
61 | static int current_line; | |
62 | ||
63 | static YY_BUFFER_STATE main_buffer = NULL; | |
64 | /* This buffer is used for macro expansion */ | |
65 | static YY_BUFFER_STATE expansion_buffer = NULL; | |
66 | ||
67 | static std::deque<IncludeElem<YY_BUFFER_STATE> >* include_chain = NULL; | |
68 | ||
69 | static void set_ret_val_cstr(const std::string& cstring) { | |
70 | param_charstring_t& ch_val = yylval.charstring_val; | |
71 | ch_val.n_chars = cstring.size(); | |
72 | ch_val.chars_ptr = (char*) Malloc(ch_val.n_chars + 1); | |
73 | memcpy(ch_val.chars_ptr, cstring.c_str(), cstring.size() + 1); | |
74 | } | |
75 | ||
76 | std::string get_cfg_process_current_file() { | |
77 | if (include_chain && !include_chain->empty()) { | |
78 | return include_chain->back().get_full_path(); | |
79 | } | |
80 | ||
81 | return std::string(); | |
82 | } | |
83 | ||
84 | %} | |
85 | ||
86 | WHITESPACE [ \t] | |
87 | WS {WHITESPACE}* | |
88 | NEWLINE \r|\n|\r\n | |
89 | LINECOMMENT ("//"|"#")[^\r\n]*{NEWLINE} | |
90 | ||
91 | NUMBER 0|([1-9][0-9]*) | |
92 | ||
93 | FLOAT [+-]?({NUMBER}\.[0-9]+)|((({NUMBER}(\.[0-9]+)?)|(\.[0-9]+))[Ee][+-]?{NUMBER}) | |
94 | ||
95 | BIN 0|1 | |
96 | BITSTRING '{BIN}*'B | |
97 | BINMATCH 0|1|\?|\* | |
98 | BITSTRINGMATCH '{BINMATCH}*'B | |
99 | BITSTRING_BAD '[^']*'B | |
100 | ||
101 | HEX [0-9A-Fa-f] | |
102 | HEXSTRING '{HEX}*'H | |
103 | HEXMATCH [0-9A-Fa-f\?\*] | |
104 | HEXSTRINGMATCH '{HEXMATCH}*'H | |
105 | HEXSTRING_BAD '[^']*'H | |
106 | ||
107 | OCT {HEX}{HEX} | |
108 | OCTETSTRING '{OCT}*'O | |
109 | OCTMATCH {HEX}{HEX}|\?|\* | |
110 | OCTETSTRINGMATCH '{OCTMATCH}*'O | |
111 | OCTETSTRING_BAD '[^']*'O | |
112 | ||
113 | BINSTRING_BAD '[^']*' | |
114 | ||
115 | TTCN3IDENTIFIER [A-Za-z][A-Za-z0-9_]* | |
116 | ASN1LOWERIDENTIFIER [a-z](-?[A-Za-z0-9]+)* | |
117 | ||
118 | COMPONENT .*\({NUMBER}\) | |
119 | ||
120 | MACRO_CSTR \${TTCN3IDENTIFIER}|\$"{"{WS}{TTCN3IDENTIFIER}{WS}(","{WS}charstring{WS})?"}" | |
121 | MACRO_BOOL \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}boolean{WS}"}" | |
122 | MACRO_FLOAT \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}float{WS}"}" | |
123 | MACRO_ID \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}identifier{WS}"}" | |
124 | MACRO_INT \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}integer{WS}"}" | |
125 | MACRO_BSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}bitstring{WS}"}" | |
126 | MACRO_HSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}hexstring{WS}"}" | |
127 | MACRO_OSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}octetstring{WS}"}" | |
128 | MACRO_BINARY \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}binaryoctet{WS}"}" | |
129 | MACRO_HOSTNAME \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}hostname{WS}"}" | |
130 | ||
131 | HOSTNAME [A-Za-z0-9]([A-Za-z0-9_\-]*[A-Za-z0-9])? | |
132 | DNSNAME {HOSTNAME}(\.{HOSTNAME})*\.? | |
133 | ||
134 | /* Example: fe80::c002:37ff:fe6c:0%fastethernet0/0 */ | |
135 | IPV6 [0-9A-Fa-f:.]+(%[0-9A-Za-z]+)? | |
136 | ||
19700695 | 137 | UID [uU][+]?[0-9A-Fa-f]{1,8} |
138 | ||
970ed795 EL |
139 | TTCNSTRINGPARSING "$#&&&(#TTCNSTRINGPARSING$#&&^#% " |
140 | TTCNSTRINGPARSING_COMPONENT "$#&&&(#TTCNSTRINGPARSING_COMPONENT$#&&^#% " | |
141 | ||
142 | %x SC_commentblock SC_cstring SC_DEFINE | |
143 | %s SC_MODULE_PARAMETERS SC_LOGGING SC_TESTPORT_PARAMETERS SC_EXECUTE SC_GROUPS | |
144 | %s SC_COMPONENTS SC_EXTERNAL_COMMANDS SC_MAIN_CONTROLLER SC_INCLUDE SC_ORDERED_INCLUDE | |
19700695 | 145 | %s SC_STRING2TTCN_COMPONENT SC_PROFILER SC_CHAR_KEYWORD |
970ed795 EL |
146 | |
147 | %% | |
148 | ||
149 | int caller_state = INITIAL; | |
150 | std::string cstring; | |
151 | int cstring_start = -1; | |
152 | ||
153 | /* Eat up comments and whitespaces */ | |
154 | ||
155 | "/*" { | |
156 | caller_state = YY_START; | |
157 | BEGIN(SC_commentblock); | |
158 | } | |
159 | <SC_commentblock> | |
160 | { | |
161 | "*/" BEGIN(caller_state); | |
162 | {NEWLINE} current_line++; | |
163 | . /* do nothing */ | |
164 | <<EOF>> { | |
165 | config_process_error("Unterminated block comment (missing */ at the " | |
166 | "end of file)."); | |
167 | BEGIN(caller_state); | |
168 | } | |
169 | } | |
170 | ||
171 | {WHITESPACE} | |
172 | {NEWLINE} | | |
173 | {LINECOMMENT} current_line++; | |
174 | ||
175 | {TTCNSTRINGPARSING} { | |
176 | if (Ttcn_String_Parsing::happening()) { | |
177 | BEGIN(SC_MODULE_PARAMETERS); | |
178 | return TtcnStringParsingKeyword; | |
179 | } else { | |
180 | config_process_error("Invalid character sequence encountered."); | |
181 | } | |
182 | } | |
183 | ||
184 | {TTCNSTRINGPARSING_COMPONENT} { | |
185 | if (Ttcn_String_Parsing::happening()) { | |
186 | BEGIN(SC_STRING2TTCN_COMPONENT); | |
187 | return TtcnStringParsingKeyword; | |
188 | } else { | |
189 | config_process_error("Invalid character sequence encountered."); | |
190 | } | |
191 | } | |
192 | ||
193 | /* Section delimiters */ | |
194 | ||
195 | <*>"["{WS}MODULE_PARAMETERS{WS}"]" { | |
196 | if (YY_START!=SC_commentblock && YY_START!=SC_cstring) { | |
197 | BEGIN(SC_MODULE_PARAMETERS); | |
198 | return ModuleParametersKeyword; | |
199 | } | |
200 | } | |
201 | ||
202 | <*>"["{WS}LOGGING{WS}"]" { | |
203 | if (YY_START!=SC_commentblock && YY_START!=SC_cstring) { | |
204 | BEGIN(SC_LOGGING); | |
205 | return LoggingKeyword; | |
206 | } | |
207 | } | |
208 | ||
af710487 | 209 | <*>"["{WS}PROFILER{WS}"]" { |
210 | if (YY_START!=SC_commentblock && YY_START!=SC_cstring) { | |
211 | BEGIN(SC_PROFILER); | |
212 | return ProfilerKeyword; | |
213 | } | |
214 | } | |
215 | ||
970ed795 EL |
216 | <*>"["{WS}TESTPORT_PARAMETERS{WS}"]" { |
217 | if (YY_START!=SC_commentblock && YY_START!=SC_cstring) { | |
218 | BEGIN(SC_TESTPORT_PARAMETERS); | |
219 | return TestportParametersKeyword; | |
220 | } | |
221 | } | |
222 | ||
223 | <*>"["{WS}EXECUTE{WS}"]" { | |
224 | if (YY_START!=SC_commentblock && YY_START!=SC_cstring) { | |
225 | BEGIN(SC_EXECUTE); | |
226 | return ExecuteKeyword; | |
227 | } | |
228 | } | |
229 | ||
230 | <*>"["{WS}EXTERNAL_COMMANDS{WS}"]" { | |
231 | if (YY_START!=SC_commentblock && YY_START!=SC_cstring) { | |
232 | BEGIN(SC_EXTERNAL_COMMANDS); | |
233 | return ExternalCommandsKeyword; | |
234 | } | |
235 | } | |
236 | ||
237 | <*>"["{WS}GROUPS{WS}"]" { | |
238 | if (YY_START!=SC_commentblock && YY_START!=SC_cstring) { | |
239 | BEGIN(SC_GROUPS); | |
240 | return GroupsKeyword; | |
241 | } | |
242 | } | |
243 | ||
244 | <*>"["{WS}COMPONENTS{WS}"]" { | |
245 | if (YY_START!=SC_commentblock && YY_START!=SC_cstring) { | |
246 | BEGIN(SC_COMPONENTS); | |
247 | return ComponentsKeyword; | |
248 | } | |
249 | } | |
250 | ||
251 | <*>"["{WS}MAIN_CONTROLLER{WS}"]" { | |
252 | if (YY_START!=SC_commentblock && YY_START!=SC_cstring) { | |
253 | BEGIN(SC_MAIN_CONTROLLER); | |
254 | return MainControllerKeyword; | |
255 | } | |
256 | } | |
257 | ||
258 | <*>"["{WS}INCLUDE{WS}"]" { | |
259 | if (YY_START!=SC_commentblock && YY_START!=SC_cstring) { | |
260 | BEGIN(SC_INCLUDE); | |
261 | return IncludeKeyword; | |
262 | } | |
263 | } | |
264 | ||
265 | <*>"["{WS}ORDERED_INCLUDE{WS}"]" { | |
266 | if (YY_START!=SC_commentblock && YY_START!=SC_cstring) { | |
267 | BEGIN(SC_ORDERED_INCLUDE); | |
268 | } | |
269 | } | |
270 | ||
271 | <*>"["{WS}DEFINE{WS}"]" { | |
272 | if (YY_START!=SC_commentblock && YY_START!=SC_cstring) { | |
273 | BEGIN(SC_DEFINE); | |
274 | return DefineKeyword; | |
275 | } | |
276 | } | |
277 | ||
278 | /* Rules for SC_DEFINE must precede everything else */ | |
279 | ||
280 | <SC_DEFINE>{ | |
281 | ||
282 | "/*" { | |
283 | caller_state = SC_DEFINE; | |
284 | BEGIN(SC_commentblock); | |
285 | } | |
286 | ||
287 | \" { | |
288 | caller_state = SC_DEFINE; | |
289 | BEGIN(SC_cstring); | |
290 | cstring.clear(); | |
291 | cstring_start = current_line; | |
292 | } | |
293 | ||
294 | {LINECOMMENT}|{NEWLINE} current_line++; | |
295 | ||
296 | \\\" | |
297 | ||
298 | . /* eat unnecessary chars */ | |
299 | ||
a38c6d4c | 300 | } |
301 | ||
302 | <SC_PROFILER>{HEX}+ { | |
303 | /* numeric statistics filter (check this before checking for NUMBERs) */ | |
304 | yylval.uint_val = 0; | |
305 | while(0 != *yytext) { | |
306 | yylval.uint_val *= 16; | |
307 | if ('0' <= *yytext && '9' >= *yytext) { | |
308 | yylval.uint_val += *yytext - '0'; | |
309 | } | |
310 | else if ('a' <= *yytext && 'f' >= *yytext) { | |
311 | yylval.uint_val += *yytext - 'a' + 10; | |
312 | } | |
313 | else { | |
314 | yylval.uint_val += *yytext - 'A' + 10; | |
315 | } | |
316 | ++yytext; | |
317 | } | |
318 | return ProfilerStatsFlag; | |
970ed795 EL |
319 | } |
320 | ||
321 | /* Values */ | |
322 | ||
323 | {NUMBER} { | |
324 | yylval.int_val = new int_val_t(yytext); | |
19700695 | 325 | if (YY_START == SC_MODULE_PARAMETERS || YY_START == SC_CHAR_KEYWORD) { |
3abe9331 | 326 | // return a different token for module parameters so it doesn't conflict with references |
327 | return MPNumber; | |
328 | } | |
970ed795 EL |
329 | return Number; |
330 | } | |
331 | ||
332 | {FLOAT} { | |
333 | yylval.float_val = atof(yytext); | |
19700695 | 334 | if (YY_START == SC_MODULE_PARAMETERS || YY_START == SC_CHAR_KEYWORD) { |
3abe9331 | 335 | // return a different token for module parameters so it doesn't conflict with references |
336 | return MPFloat; | |
337 | } | |
970ed795 EL |
338 | return Float; |
339 | } | |
340 | ||
341 | {BITSTRING} { | |
342 | yylval.bitstring_val.n_bits = yyleng - 3; | |
343 | int n_bytes = (yylval.bitstring_val.n_bits + 7) / 8; | |
344 | yylval.bitstring_val.bits_ptr = (unsigned char *)Malloc(n_bytes); | |
345 | memset(yylval.bitstring_val.bits_ptr, 0, n_bytes); | |
346 | for (int i = 0; i < yylval.bitstring_val.n_bits; i++) | |
347 | if (yytext[i+1] == '1') | |
348 | yylval.bitstring_val.bits_ptr[i/8] |= 1 << (i % 8); | |
349 | return Bstring; | |
350 | } | |
351 | ||
352 | {BITSTRINGMATCH} { | |
353 | yylval.str_val = mcopystrn(yytext+1, yyleng-3); | |
354 | return BstringMatch; | |
355 | } | |
356 | ||
357 | {BITSTRING_BAD} { | |
358 | config_process_error("Invalid bitstring value."); | |
359 | yylval.bitstring_val.n_bits = 0; | |
360 | yylval.bitstring_val.bits_ptr = NULL; | |
361 | return Bstring; | |
362 | } | |
363 | ||
364 | {HEXSTRING} { | |
365 | yylval.hexstring_val.n_nibbles = yyleng - 3; | |
366 | int n_bytes = (yylval.hexstring_val.n_nibbles + 1) / 2; | |
367 | yylval.hexstring_val.nibbles_ptr = (unsigned char *)Malloc(n_bytes); | |
368 | memset(yylval.hexstring_val.nibbles_ptr, 0, n_bytes); | |
369 | for (int i = 0; i < yylval.hexstring_val.n_nibbles; i++) { | |
370 | unsigned int hex_digit; | |
371 | sscanf(yytext+i+1, "%1x", &hex_digit); | |
372 | if(i % 2) yylval.hexstring_val.nibbles_ptr[i/2] |= | |
373 | (hex_digit << 4); | |
374 | else yylval.hexstring_val.nibbles_ptr[i/2] |= hex_digit; | |
375 | } | |
376 | return Hstring; | |
377 | } | |
378 | ||
379 | {HEXSTRINGMATCH} { | |
380 | yylval.str_val = mcopystrn(yytext+1, yyleng-3); | |
381 | return HstringMatch; | |
382 | } | |
383 | ||
384 | {HEXSTRING_BAD} { | |
385 | config_process_error("Invalid hexstring value."); | |
386 | yylval.hexstring_val.n_nibbles = 0; | |
387 | yylval.hexstring_val.nibbles_ptr = NULL; | |
388 | return Hstring; | |
389 | } | |
390 | ||
391 | {OCTETSTRING} { | |
392 | yylval.octetstring_val.n_octets = (yyleng - 3) / 2; | |
393 | yylval.octetstring_val.octets_ptr = (unsigned char *) | |
394 | Malloc(yylval.octetstring_val.n_octets); | |
395 | ||
396 | for (int i = 0; i < yylval.octetstring_val.n_octets; i++) { | |
397 | unsigned int this_octet; | |
398 | sscanf(yytext+2*i+1, "%2x", &this_octet); | |
399 | yylval.octetstring_val.octets_ptr[i] = this_octet; | |
400 | } | |
401 | return Ostring; | |
402 | } | |
403 | ||
404 | {OCTETSTRINGMATCH} { | |
405 | yylval.str_val = mcopystrn(yytext+1, yyleng-3); | |
406 | return OstringMatch; | |
407 | } | |
408 | ||
409 | {OCTETSTRING_BAD} { | |
410 | config_process_error("Invalid octetstring value."); | |
411 | yylval.octetstring_val.n_octets = 0; | |
412 | yylval.octetstring_val.octets_ptr = NULL; | |
413 | return Ostring; | |
414 | } | |
415 | ||
416 | {BINSTRING_BAD} config_process_error("Invalid string value."); | |
417 | ||
418 | ' config_process_error("Unmatched ' character."); | |
419 | ||
420 | \" { | |
421 | caller_state = YY_START; | |
422 | BEGIN(SC_cstring); | |
423 | cstring.clear(); | |
424 | cstring_start = current_line; | |
425 | } | |
426 | ||
427 | <SC_cstring> | |
428 | { | |
429 | \"\" cstring += '"'; | |
430 | \" { | |
431 | /* end of the string */ | |
432 | BEGIN(caller_state); | |
433 | switch (caller_state) { | |
434 | case SC_DEFINE: | |
435 | cstring.clear(); | |
436 | break; | |
437 | case SC_ORDERED_INCLUDE: | |
438 | { | |
439 | std::string error_msg = switch_lexer(include_chain, cstring, | |
440 | YY_CURRENT_BUFFER, yy_create_buffer, yy_switch_to_buffer, | |
441 | current_line, YY_BUF_SIZE); | |
442 | if (error_msg.empty()) { | |
443 | BEGIN(INITIAL); | |
444 | } else { | |
445 | config_process_error(error_msg.c_str()); | |
446 | } | |
447 | } | |
448 | break; | |
449 | default: | |
450 | set_ret_val_cstr(cstring); | |
19700695 | 451 | if (caller_state == SC_MODULE_PARAMETERS || caller_state == SC_CHAR_KEYWORD) { |
3abe9331 | 452 | // return a different token for module parameters so it doesn't conflict with references |
453 | return MPCstring; | |
454 | } | |
970ed795 EL |
455 | return Cstring; |
456 | } | |
457 | ||
458 | cstring.clear(); | |
459 | cstring_start = -1; | |
460 | } | |
461 | \\[\\'"?] cstring += yytext[1]; /* backslash-quoted \ or " or ' or ? */ | |
462 | \\{NEWLINE} current_line++; | |
463 | \\a cstring += '\a'; | |
464 | \\b cstring += '\b'; | |
465 | \\f cstring += '\f'; | |
466 | \\n cstring += '\n'; | |
467 | \\r cstring += '\r'; | |
468 | \\t cstring += '\t'; | |
469 | \\v cstring += '\v'; | |
470 | \\[0-7]{1,3} { | |
471 | unsigned int c; | |
472 | sscanf(yytext + 1, "%o", &c); | |
473 | if (c > 255) | |
474 | config_process_error("Invalid octal character code in string " | |
475 | "literal."); | |
476 | else if (c == 0 && caller_state != SC_MODULE_PARAMETERS) | |
477 | config_process_error("NUL characters in string literals are " | |
478 | "allowed only in section [MODULE_PARAMETERS]."); | |
479 | else cstring += c; | |
480 | } | |
481 | \\x{HEX}{1,2} { | |
482 | unsigned int c; | |
483 | sscanf(yytext + 2, "%x", &c); | |
484 | if (c == 0 && caller_state != SC_MODULE_PARAMETERS) | |
485 | config_process_error("NUL characters in string literals are " | |
486 | "allowed only in section [MODULE_PARAMETERS]."); | |
487 | else cstring += c; | |
488 | } | |
489 | \\(x[^\\\"]|.) { | |
490 | config_process_error("Invalid escape sequence in string literal."); | |
491 | } | |
492 | {NEWLINE} { | |
493 | cstring.append(yytext, yyleng); | |
494 | current_line++; | |
495 | } | |
496 | . cstring += yytext[0]; | |
497 | <<EOF>> { | |
498 | if (cstring_start >=0) { | |
499 | config_process_error_f("Unterminated string literal starting at line %d " | |
500 | "(missing \" at the end of file).", cstring_start); | |
501 | } else { | |
502 | config_process_error("Unterminated string literal (missing \" at the " | |
503 | "end of file)."); | |
504 | } | |
505 | BEGIN(caller_state); | |
506 | if (caller_state!=SC_DEFINE) { | |
507 | set_ret_val_cstr(cstring); | |
19700695 | 508 | if (caller_state == SC_MODULE_PARAMETERS || caller_state == SC_CHAR_KEYWORD) { |
3abe9331 | 509 | // return a different token for module parameters so it doesn't conflict with references |
510 | return MPCstring; | |
511 | } | |
970ed795 EL |
512 | return Cstring; |
513 | } | |
514 | ||
515 | cstring.clear(); | |
516 | } | |
517 | } | |
518 | ||
19700695 | 519 | <SC_CHAR_KEYWORD> |
520 | { | |
521 | {UID} { | |
522 | yylval.str_val = mcopystrn(yytext, yyleng); | |
523 | return UIDval; | |
524 | } | |
525 | ||
526 | [,] { return *yytext; } | |
527 | ||
528 | [)] { BEGIN(SC_MODULE_PARAMETERS); return *yytext; } | |
529 | } | |
530 | ||
970ed795 EL |
531 | /* Section-wide keywords */ |
532 | ||
533 | <SC_MODULE_PARAMETERS> | |
534 | { | |
535 | NULL return NULLKeyword; | |
536 | null return nullKeyword; | |
19700695 | 537 | char { BEGIN(SC_CHAR_KEYWORD); return CharKeyword; } |
970ed795 EL |
538 | objid return ObjIdKeyword; |
539 | omit return OmitKeyword; | |
540 | none { | |
541 | yylval.verdict_val = NONE; | |
542 | return VerdictValue; | |
543 | } | |
544 | pass { | |
545 | yylval.verdict_val = PASS; | |
546 | return VerdictValue; | |
547 | } | |
548 | inconc { | |
549 | yylval.verdict_val = INCONC; | |
550 | return VerdictValue; | |
551 | } | |
552 | fail { | |
553 | yylval.verdict_val = FAIL; | |
554 | return VerdictValue; | |
555 | } | |
556 | error { | |
557 | yylval.verdict_val = ERROR; | |
558 | return VerdictValue; | |
559 | } | |
560 | complement return ComplementKeyword; | |
561 | "\.\." return DotDot; | |
562 | superset return SupersetKeyword; | |
563 | subset return SubsetKeyword; | |
564 | pattern return PatternKeyword; | |
565 | permutation return PermutationKeyword; | |
566 | length return LengthKeyword; | |
567 | ifpresent return IfpresentKeyword; | |
568 | infinity return InfinityKeyword; | |
569 | } | |
570 | ||
af710487 | 571 | <SC_MODULE_PARAMETERS,SC_LOGGING,SC_PROFILER> |
970ed795 EL |
572 | { |
573 | true { | |
574 | yylval.bool_val = TRUE; | |
575 | return BooleanValue; | |
576 | } | |
577 | false { | |
578 | yylval.bool_val = FALSE; | |
579 | return BooleanValue; | |
580 | } | |
581 | } | |
582 | ||
583 | /* We could add SC_LOGGING to make mtc and system special for the logging section too */ | |
584 | <SC_MODULE_PARAMETERS,SC_STRING2TTCN_COMPONENT,SC_TESTPORT_PARAMETERS,SC_LOGGING> | |
585 | { | |
586 | mtc return MTCKeyword; | |
587 | system return SystemKeyword; | |
588 | } | |
589 | ||
590 | <SC_LOGGING> | |
591 | { | |
592 | [Ff]ile[Nn]ame | | |
593 | [Ll]og[Ff]ile return LogFile; | |
594 | ||
595 | [Ee]mergency[Ll]ogging return EmergencyLogging; | |
596 | ||
597 | [Ee]mergency[Ll]ogging[Bb]ehaviour return EmergencyLoggingBehaviour; | |
598 | ||
599 | [Ee]mergency[Ll]ogging[Mm]ask return EmergencyLoggingMask; | |
600 | ||
d44e3c4f | 601 | [Ee]mergency[Ll]ogging[Ff]or[Ff]ail[Vv]erdict return EmergencyLoggingForFailVerdict; |
602 | ||
970ed795 EL |
603 | [Ff]ile[Mm]ask return FileMask; |
604 | ||
605 | [Cc]onsole[Mm]ask return ConsoleMask; | |
606 | ||
607 | [Tt]ime[Ss]tamp[Ff]ormat return TimestampFormat; | |
608 | [Cc]onsole[Tt]ime[Ss]tamp[Ff]ormat return ConsoleTimestampFormat; | |
609 | ||
610 | [Ll]og[Ss]ource[Ii]nfo | | |
611 | [Ss]ource[Ii]nfo[Ff]ormat return SourceInfoFormat; | |
612 | ||
613 | [Aa]ppend[Ff]ile return AppendFile; | |
614 | ||
615 | [Ll]og[Ee]vent[Tt]ypes return LogEventTypes; | |
616 | ||
617 | [Ll]og[Ee]ntity[Nn]ame return LogEntityName; | |
618 | ||
619 | [Ll]og[Ff]ile[Ss]ize return LogFileSize; | |
620 | ||
621 | [Ll]og[Ff]ile[Nn]umber return LogFileNumber; | |
622 | ||
623 | [Dd]isk[Ff]ull[Aa]ction return DiskFullAction; | |
624 | ||
625 | [Mm]atching[Hh]ints return MatchingHints; | |
626 | ||
627 | [Ll]ogger[Pp]lugins return LoggerPlugins; | |
628 | ||
629 | /* Lexer's handling of logging keywords: | |
630 | * | |
631 | * For sub-categories and categories with only one member, | |
632 | * LoggingBit is returned and the value is the corresponding | |
633 | * TTCN_Logger::Severity. | |
634 | * | |
635 | * For the old categories which now have subcategories, the old keyword | |
636 | * is returned as LoggingBitCollection with the corresponding | |
637 | * _UNQUALIFIED as the semantic value. The parser will construct the | |
638 | * multi-bit value. | |
639 | * | |
640 | * The lexer never returns a token with a Logging_Bits type. | |
641 | */ | |
642 | LOG_NOTHING { | |
643 | yylval.logseverity_val = TTCN_Logger::NOTHING_TO_LOG; | |
644 | return LoggingBit; | |
645 | } | |
646 | ||
647 | ACTION_UNQUALIFIED { | |
648 | yylval.logseverity_val = TTCN_Logger::ACTION_UNQUALIFIED; | |
649 | return LoggingBit; | |
650 | } | |
651 | (TTCN_)?ACTION { | |
652 | yylval.logseverity_val = TTCN_Logger::ACTION_UNQUALIFIED; | |
653 | return LoggingBitCollection; | |
654 | } | |
655 | ||
656 | DEBUG_ENCDEC { | |
657 | yylval.logseverity_val = TTCN_Logger::DEBUG_ENCDEC; | |
658 | return LoggingBit; | |
659 | } | |
660 | DEBUG_TESTPORT { | |
661 | yylval.logseverity_val = TTCN_Logger::DEBUG_TESTPORT; | |
662 | return LoggingBit; | |
663 | } | |
3f84031e | 664 | DEBUG_USER { |
665 | yylval.logseverity_val = TTCN_Logger::DEBUG_USER; | |
666 | return LoggingBit; | |
667 | } | |
668 | DEBUG_FRAMEWORK { | |
669 | yylval.logseverity_val = TTCN_Logger::DEBUG_FRAMEWORK; | |
670 | return LoggingBit; | |
671 | } | |
970ed795 EL |
672 | DEBUG_UNQUALIFIED { |
673 | yylval.logseverity_val = TTCN_Logger::DEBUG_UNQUALIFIED; | |
674 | return LoggingBit; | |
675 | } | |
676 | (TTCN_)?DEBUG { | |
677 | yylval.logseverity_val = TTCN_Logger::DEBUG_UNQUALIFIED; | |
678 | return LoggingBitCollection; | |
679 | } | |
680 | ||
681 | DEFAULTOP_ACTIVATE { | |
682 | yylval.logseverity_val = TTCN_Logger::DEFAULTOP_ACTIVATE; | |
683 | return LoggingBit; | |
684 | } | |
685 | DEFAULTOP_DEACTIVATE { | |
686 | yylval.logseverity_val = TTCN_Logger::DEFAULTOP_DEACTIVATE; | |
687 | return LoggingBit; | |
688 | } | |
689 | DEFAULTOP_EXIT { | |
690 | yylval.logseverity_val = TTCN_Logger::DEFAULTOP_EXIT; | |
691 | return LoggingBit; | |
692 | } | |
693 | DEFAULTOP_UNQUALIFIED { | |
694 | yylval.logseverity_val = TTCN_Logger::DEFAULTOP_UNQUALIFIED; | |
695 | return LoggingBit; | |
696 | } | |
697 | (TTCN_)?DEFAULTOP { | |
698 | yylval.logseverity_val = TTCN_Logger::DEFAULTOP_UNQUALIFIED; | |
699 | return LoggingBitCollection; | |
700 | } | |
701 | ||
702 | ERROR_UNQUALIFIED { | |
703 | yylval.logseverity_val = TTCN_Logger::ERROR_UNQUALIFIED; | |
704 | return LoggingBit; | |
705 | } | |
706 | (TTCN_)?ERROR { | |
707 | yylval.logseverity_val = TTCN_Logger::ERROR_UNQUALIFIED; | |
708 | return LoggingBitCollection; | |
709 | } | |
710 | ||
711 | EXECUTOR_COMPONENT { | |
712 | yylval.logseverity_val = TTCN_Logger::EXECUTOR_COMPONENT; | |
713 | return LoggingBit; | |
714 | } | |
715 | EXECUTOR_CONFIGDATA { | |
716 | yylval.logseverity_val = TTCN_Logger::EXECUTOR_CONFIGDATA; | |
717 | return LoggingBit; | |
718 | } | |
719 | EXECUTOR_EXTCOMMAND { | |
720 | yylval.logseverity_val = TTCN_Logger::EXECUTOR_EXTCOMMAND; | |
721 | return LoggingBit; | |
722 | } | |
723 | EXECUTOR_LOGOPTIONS { | |
724 | yylval.logseverity_val = TTCN_Logger::EXECUTOR_LOGOPTIONS; | |
725 | return LoggingBit; | |
726 | } | |
727 | EXECUTOR_RUNTIME { | |
728 | yylval.logseverity_val = TTCN_Logger::EXECUTOR_RUNTIME; | |
729 | return LoggingBit; | |
730 | } | |
731 | EXECUTOR_UNQUALIFIED { | |
732 | yylval.logseverity_val = TTCN_Logger::EXECUTOR_UNQUALIFIED; | |
733 | return LoggingBit; | |
734 | } | |
735 | (TTCN_)?EXECUTOR { | |
736 | yylval.logseverity_val = TTCN_Logger::EXECUTOR_UNQUALIFIED; | |
737 | return LoggingBitCollection; | |
738 | } | |
739 | ||
740 | FUNCTION_RND { | |
741 | yylval.logseverity_val = TTCN_Logger::FUNCTION_RND; | |
742 | return LoggingBit; | |
743 | } | |
744 | FUNCTION_UNQUALIFIED { | |
745 | yylval.logseverity_val = TTCN_Logger::FUNCTION_UNQUALIFIED; | |
746 | return LoggingBit; | |
747 | } | |
748 | (TTCN_)?FUNCTION { | |
749 | yylval.logseverity_val = TTCN_Logger::FUNCTION_UNQUALIFIED; | |
750 | return LoggingBitCollection; | |
751 | } | |
752 | ||
753 | MATCHING_DONE { | |
754 | yylval.logseverity_val = TTCN_Logger::MATCHING_DONE; | |
755 | return LoggingBit; | |
756 | } | |
757 | MATCHING_MCSUCCESS { | |
758 | yylval.logseverity_val = TTCN_Logger::MATCHING_MCSUCCESS; | |
759 | return LoggingBit; | |
760 | } | |
761 | MATCHING_MCUNSUCC { | |
762 | yylval.logseverity_val = TTCN_Logger::MATCHING_MCUNSUCC; | |
763 | return LoggingBit; | |
764 | } | |
765 | MATCHING_MMSUCCESS { | |
766 | yylval.logseverity_val = TTCN_Logger::MATCHING_MMSUCCESS; | |
767 | return LoggingBit; | |
768 | } | |
769 | MATCHING_MMUNSUCC { | |
770 | yylval.logseverity_val = TTCN_Logger::MATCHING_MMUNSUCC; | |
771 | return LoggingBit; | |
772 | } | |
773 | MATCHING_PCSUCCESS { | |
774 | yylval.logseverity_val = TTCN_Logger::MATCHING_PCSUCCESS; | |
775 | return LoggingBit; | |
776 | } | |
777 | MATCHING_PCUNSUCC { | |
778 | yylval.logseverity_val = TTCN_Logger::MATCHING_PCUNSUCC; | |
779 | return LoggingBit; | |
780 | } | |
781 | MATCHING_PMSUCCESS { | |
782 | yylval.logseverity_val = TTCN_Logger::MATCHING_PMSUCCESS; | |
783 | return LoggingBit; | |
784 | } | |
785 | MATCHING_PMUNSUCC { | |
786 | yylval.logseverity_val = TTCN_Logger::MATCHING_PMUNSUCC; | |
787 | return LoggingBit; | |
788 | } | |
789 | MATCHING_PROBLEM { | |
790 | yylval.logseverity_val = TTCN_Logger::MATCHING_PROBLEM; | |
791 | return LoggingBit; | |
792 | } | |
793 | MATCHING_TIMEOUT { | |
794 | yylval.logseverity_val = TTCN_Logger::MATCHING_TIMEOUT; | |
795 | return LoggingBit; | |
796 | } | |
797 | MATCHING_UNQUALIFIED { | |
798 | yylval.logseverity_val = TTCN_Logger::MATCHING_UNQUALIFIED; | |
799 | return LoggingBit; | |
800 | } | |
801 | (TTCN_)?MATCHING { | |
802 | yylval.logseverity_val = TTCN_Logger::MATCHING_UNQUALIFIED; | |
803 | return LoggingBitCollection; | |
804 | } | |
805 | ||
806 | PARALLEL_PORTCONN { | |
807 | yylval.logseverity_val = TTCN_Logger::PARALLEL_PORTCONN; | |
808 | return LoggingBit; | |
809 | } | |
810 | PARALLEL_PORTMAP { | |
811 | yylval.logseverity_val = TTCN_Logger::PARALLEL_PORTMAP; | |
812 | return LoggingBit; | |
813 | } | |
814 | PARALLEL_PTC { | |
815 | yylval.logseverity_val = TTCN_Logger::PARALLEL_PTC; | |
816 | return LoggingBit; | |
817 | } | |
818 | PARALLEL_UNQUALIFIED { | |
819 | yylval.logseverity_val = TTCN_Logger::PARALLEL_UNQUALIFIED; | |
820 | return LoggingBit; | |
821 | } | |
822 | (TTCN_)?PARALLEL { | |
823 | yylval.logseverity_val = TTCN_Logger::PARALLEL_UNQUALIFIED; | |
824 | return LoggingBitCollection; | |
825 | } | |
826 | ||
827 | PORTEVENT_DUALRECV { | |
828 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_DUALRECV; | |
829 | return LoggingBit; | |
830 | } | |
831 | PORTEVENT_DUALSEND { | |
832 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_DUALSEND; | |
833 | return LoggingBit; | |
834 | } | |
835 | PORTEVENT_MCRECV { | |
836 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_MCRECV; | |
837 | return LoggingBit; | |
838 | } | |
839 | PORTEVENT_MCSEND { | |
840 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_MCSEND; | |
841 | return LoggingBit; | |
842 | } | |
843 | PORTEVENT_MMRECV { | |
844 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_MMRECV; | |
845 | return LoggingBit; | |
846 | } | |
847 | PORTEVENT_MMSEND { | |
848 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_MMSEND; | |
849 | return LoggingBit; | |
850 | } | |
851 | PORTEVENT_MQUEUE { | |
852 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_MQUEUE; | |
853 | return LoggingBit; | |
854 | } | |
855 | PORTEVENT_PCIN { | |
856 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_PCIN; | |
857 | return LoggingBit; | |
858 | } | |
859 | PORTEVENT_PCOUT { | |
860 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_PCOUT; | |
861 | return LoggingBit; | |
862 | } | |
863 | PORTEVENT_PMIN { | |
864 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_PMIN; | |
865 | return LoggingBit; | |
866 | } | |
867 | PORTEVENT_PMOUT { | |
868 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_PMOUT; | |
869 | return LoggingBit; | |
870 | } | |
871 | PORTEVENT_PQUEUE { | |
872 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_PQUEUE; | |
873 | return LoggingBit; | |
874 | } | |
875 | PORTEVENT_STATE { | |
876 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_STATE; | |
877 | return LoggingBit; | |
878 | } | |
879 | PORTEVENT_UNQUALIFIED { | |
880 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_UNQUALIFIED; | |
881 | return LoggingBit; | |
882 | } | |
883 | (TTCN_)?PORTEVENT { | |
884 | yylval.logseverity_val = TTCN_Logger::PORTEVENT_UNQUALIFIED; | |
885 | return LoggingBitCollection; | |
886 | } | |
887 | ||
888 | STATISTICS_UNQUALIFIED { | |
889 | yylval.logseverity_val = TTCN_Logger::STATISTICS_UNQUALIFIED; | |
890 | return LoggingBit; | |
891 | } | |
892 | STATISTICS_VERDICT { | |
893 | yylval.logseverity_val = TTCN_Logger::STATISTICS_VERDICT; | |
894 | return LoggingBit; | |
895 | } | |
896 | (TTCN_)?STATISTICS { | |
897 | yylval.logseverity_val = TTCN_Logger::STATISTICS_UNQUALIFIED; | |
898 | return LoggingBitCollection; | |
899 | } | |
900 | ||
901 | TESTCASE_FINISH { | |
902 | yylval.logseverity_val = TTCN_Logger::TESTCASE_FINISH; | |
903 | return LoggingBit; | |
904 | } | |
905 | TESTCASE_START { | |
906 | yylval.logseverity_val = TTCN_Logger::TESTCASE_START; | |
907 | return LoggingBit; | |
908 | } | |
909 | TESTCASE_UNQUALIFIED { | |
910 | yylval.logseverity_val = TTCN_Logger::TESTCASE_UNQUALIFIED; | |
911 | return LoggingBit; | |
912 | } | |
913 | (TTCN_)?TESTCASE { | |
914 | yylval.logseverity_val = TTCN_Logger::TESTCASE_UNQUALIFIED; | |
915 | return LoggingBitCollection; | |
916 | } | |
917 | ||
918 | TIMEROP_GUARD { | |
919 | yylval.logseverity_val = TTCN_Logger::TIMEROP_GUARD; | |
920 | return LoggingBit; | |
921 | } | |
922 | TIMEROP_READ { | |
923 | yylval.logseverity_val = TTCN_Logger::TIMEROP_READ; | |
924 | return LoggingBit; | |
925 | } | |
926 | TIMEROP_START { | |
927 | yylval.logseverity_val = TTCN_Logger::TIMEROP_START; | |
928 | return LoggingBit; | |
929 | } | |
930 | TIMEROP_STOP { | |
931 | yylval.logseverity_val = TTCN_Logger::TIMEROP_STOP; | |
932 | return LoggingBit; | |
933 | } | |
934 | TIMEROP_TIMEOUT { | |
935 | yylval.logseverity_val = TTCN_Logger::TIMEROP_TIMEOUT; | |
936 | return LoggingBit; | |
937 | } | |
938 | TIMEROP_UNQUALIFIED { | |
939 | yylval.logseverity_val = TTCN_Logger::TIMEROP_UNQUALIFIED; | |
940 | return LoggingBit; | |
941 | } | |
942 | (TTCN_)?TIMEROP { | |
943 | yylval.logseverity_val = TTCN_Logger::TIMEROP_UNQUALIFIED; | |
944 | return LoggingBitCollection; | |
945 | } | |
946 | ||
947 | USER_UNQUALIFIED { | |
948 | yylval.logseverity_val = TTCN_Logger::USER_UNQUALIFIED; | |
949 | return LoggingBit; | |
950 | } | |
951 | (TTCN_)?USER { | |
952 | yylval.logseverity_val = TTCN_Logger::USER_UNQUALIFIED; | |
953 | return LoggingBitCollection; | |
954 | } | |
955 | ||
956 | VERDICTOP_FINAL { | |
957 | yylval.logseverity_val = TTCN_Logger::VERDICTOP_FINAL; | |
958 | return LoggingBit; | |
959 | } | |
960 | VERDICTOP_GETVERDICT { | |
961 | yylval.logseverity_val = TTCN_Logger::VERDICTOP_GETVERDICT; | |
962 | return LoggingBit; | |
963 | } | |
964 | VERDICTOP_SETVERDICT { | |
965 | yylval.logseverity_val = TTCN_Logger::VERDICTOP_SETVERDICT; | |
966 | return LoggingBit; | |
967 | } | |
968 | VERDICTOP_UNQUALIFIED { | |
969 | yylval.logseverity_val = TTCN_Logger::VERDICTOP_UNQUALIFIED; | |
970 | return LoggingBit; | |
971 | } | |
972 | (TTCN_)?VERDICTOP { | |
973 | yylval.logseverity_val = TTCN_Logger::VERDICTOP_UNQUALIFIED; | |
974 | return LoggingBitCollection; | |
975 | } | |
976 | ||
977 | WARNING_UNQUALIFIED { | |
978 | yylval.logseverity_val = TTCN_Logger::WARNING_UNQUALIFIED; | |
979 | return LoggingBit; | |
980 | } | |
981 | (TTCN_)?WARNING { | |
982 | yylval.logseverity_val = TTCN_Logger::WARNING_UNQUALIFIED; | |
983 | return LoggingBitCollection; | |
984 | } | |
985 | ||
986 | LOG_ALL { | |
987 | yylval.logseverity_val = TTCN_Logger::LOG_ALL_IMPORTANT; | |
988 | return LoggingBitCollection; | |
989 | } | |
990 | ||
991 | [Tt][Ii][Mm][Ee] { | |
992 | yylval.timestamp_value = TTCN_Logger::TIMESTAMP_TIME; | |
993 | return TimestampValue; | |
994 | } | |
995 | [Dd][Aa][Tt][Ee][Tt][Ii][Mm][Ee] { | |
996 | yylval.timestamp_value = TTCN_Logger::TIMESTAMP_DATETIME; | |
997 | return TimestampValue; | |
998 | } | |
999 | [Ss][Ee][Cc][Oo][Nn][Dd][Ss] { | |
1000 | yylval.timestamp_value = TTCN_Logger::TIMESTAMP_SECONDS; | |
1001 | return TimestampValue; | |
1002 | } | |
1003 | [Nn][Oo][Nn][Ee] { | |
1004 | yylval.source_info_value = TTCN_Logger::SINFO_NONE; | |
1005 | return SourceInfoValue; | |
1006 | } | |
1007 | [Ss][Ii][Nn][Gg][Ll][Ee] { | |
1008 | yylval.source_info_value = TTCN_Logger::SINFO_SINGLE; | |
1009 | return SourceInfoValue; | |
1010 | } | |
1011 | [Ss][Tt][Aa][Cc][Kk] { | |
1012 | yylval.source_info_value = TTCN_Logger::SINFO_STACK; | |
1013 | return SourceInfoValue; | |
1014 | } | |
1015 | [Yy][Ee][Ss] { | |
1016 | yylval.bool_val = TRUE; | |
1017 | return YesNo; | |
1018 | } | |
1019 | [Nn][Oo] { | |
1020 | yylval.bool_val = FALSE; | |
1021 | return YesNo; | |
1022 | } | |
1023 | [Bb]uffer[Aa]ll { | |
1024 | yylval.emergency_logging_behaviour_value = TTCN_Logger::BUFFER_ALL; | |
1025 | return EmergencyLoggingBehaviourValue; | |
1026 | } | |
1027 | [Bb]uffer[Mm]asked { | |
1028 | yylval.emergency_logging_behaviour_value = TTCN_Logger::BUFFER_MASKED; | |
1029 | return EmergencyLoggingBehaviourValue; | |
1030 | } | |
1031 | ||
1032 | [Cc]ompact return Compact; | |
1033 | [Dd]etailed return Detailed; | |
1034 | [Ss]ub[Cc]ategories return SubCategories; | |
1035 | ||
1036 | [Ee]rror return Error; | |
1037 | ||
1038 | [Ss]top return Stop; | |
1039 | ||
1040 | [Rr]etry return Retry; | |
1041 | ||
1042 | [Dd]elete return Delete; | |
1043 | } | |
1044 | ||
af710487 | 1045 | <SC_PROFILER> |
1046 | { | |
a38c6d4c | 1047 | [Dd]isable[Pp]rofiler return DisableProfilerKeyword; |
1048 | [Dd]isable[Cc]overage return DisableCoverageKeyword; | |
1049 | [Dd]ata[Bb]ase[Ff]ile return DatabaseFileKeyword; | |
1050 | [Aa]ggregate[Dd]ata return AggregateDataKeyword; | |
1051 | [Ss]tatistics[Ff]ile return StatisticsFileKeyword; | |
1052 | [Dd]isable[Ss]tatistics return DisableStatisticsKeyword; | |
1053 | [Ss]tatistics[Ff]ilter return StatisticsFilterKeyword; | |
1054 | [Ss]tart[Aa]utomatically return StartAutomaticallyKeyword; | |
1055 | [Nn]et[Ll]ine[Tt]imes return NetLineTimesKeyword; | |
1056 | [Nn]et[Ff]unction[Tt]imes return NetFunctionTimesKeyword; | |
1057 | ||
1058 | /* statistics filters */ | |
1059 | [Nn]umber[Oo]f[Ll]ines { | |
3abe9331 | 1060 | yylval.uint_val = Profiler_Tools::STATS_NUMBER_OF_LINES; |
a38c6d4c | 1061 | return ProfilerStatsFlag; |
1062 | } | |
1063 | [Ll]ine[Dd]ata[Rr]aw { | |
3abe9331 | 1064 | yylval.uint_val = Profiler_Tools::STATS_LINE_DATA_RAW; |
a38c6d4c | 1065 | return ProfilerStatsFlag; |
1066 | } | |
1067 | [Ff]unc[Dd]ata[Rr]aw { | |
3abe9331 | 1068 | yylval.uint_val = Profiler_Tools::STATS_FUNC_DATA_RAW; |
a38c6d4c | 1069 | return ProfilerStatsFlag; |
1070 | } | |
1071 | [Ll]ine[Aa]vg[Rr]aw { | |
3abe9331 | 1072 | yylval.uint_val = Profiler_Tools::STATS_LINE_AVG_RAW; |
a38c6d4c | 1073 | return ProfilerStatsFlag; |
1074 | } | |
1075 | [Ff]unc[Aa]vg[Rr]aw { | |
3abe9331 | 1076 | yylval.uint_val = Profiler_Tools::STATS_FUNC_AVG_RAW; |
a38c6d4c | 1077 | return ProfilerStatsFlag; |
1078 | } | |
1079 | [Ll]ine[Tt]imes[Ss]orted[Bb]y[Mm]od { | |
3abe9331 | 1080 | yylval.uint_val = Profiler_Tools::STATS_LINE_TIMES_SORTED_BY_MOD; |
a38c6d4c | 1081 | return ProfilerStatsFlag; |
1082 | } | |
1083 | [Ff]unc[Tt]imes[Ss]orted[Bb]y[Mm]od { | |
3abe9331 | 1084 | yylval.uint_val = Profiler_Tools::STATS_FUNC_TIMES_SORTED_BY_MOD; |
a38c6d4c | 1085 | return ProfilerStatsFlag; |
1086 | } | |
1087 | [Ll]ine[Tt]imes[Ss]orted[Tt]otal { | |
3abe9331 | 1088 | yylval.uint_val = Profiler_Tools::STATS_LINE_TIMES_SORTED_TOTAL; |
a38c6d4c | 1089 | return ProfilerStatsFlag; |
1090 | } | |
1091 | [Ff]unc[Tt]imes[Ss]orted[Tt]otal { | |
3abe9331 | 1092 | yylval.uint_val = Profiler_Tools::STATS_FUNC_TIMES_SORTED_TOTAL; |
a38c6d4c | 1093 | return ProfilerStatsFlag; |
1094 | } | |
1095 | [Ll]ine[Cc]ount[Ss]orted[Bb]y[Mm]od { | |
3abe9331 | 1096 | yylval.uint_val = Profiler_Tools::STATS_LINE_COUNT_SORTED_BY_MOD; |
a38c6d4c | 1097 | return ProfilerStatsFlag; |
1098 | } | |
1099 | [Ff]unc[Cc]ount[Ss]orted[Bb]y[Mm]od { | |
3abe9331 | 1100 | yylval.uint_val = Profiler_Tools::STATS_FUNC_COUNT_SORTED_BY_MOD; |
a38c6d4c | 1101 | return ProfilerStatsFlag; |
1102 | } | |
1103 | [Ll]ine[Cc]ount[Ss]orted[Tt]otal { | |
3abe9331 | 1104 | yylval.uint_val = Profiler_Tools::STATS_LINE_COUNT_SORTED_TOTAL; |
a38c6d4c | 1105 | return ProfilerStatsFlag; |
1106 | } | |
1107 | [Ff]unc[Cc]ount[Ss]orted[Tt]otal { | |
3abe9331 | 1108 | yylval.uint_val = Profiler_Tools::STATS_FUNC_COUNT_SORTED_TOTAL; |
a38c6d4c | 1109 | return ProfilerStatsFlag; |
1110 | } | |
1111 | [Ll]ine[Aa]vg[Ss]orted[Bb]y[Mm]od { | |
3abe9331 | 1112 | yylval.uint_val = Profiler_Tools::STATS_LINE_AVG_SORTED_BY_MOD; |
a38c6d4c | 1113 | return ProfilerStatsFlag; |
1114 | } | |
1115 | [Ff]unc[Aa]vg[Ss]orted[Bb]y[Mm]od { | |
3abe9331 | 1116 | yylval.uint_val = Profiler_Tools::STATS_FUNC_AVG_SORTED_BY_MOD; |
a38c6d4c | 1117 | return ProfilerStatsFlag; |
1118 | } | |
1119 | [Ll]ine[Aa]vg[Ss]orted[Tt]otal { | |
3abe9331 | 1120 | yylval.uint_val = Profiler_Tools::STATS_LINE_AVG_SORTED_TOTAL; |
a38c6d4c | 1121 | return ProfilerStatsFlag; |
1122 | } | |
1123 | [Ff]unc[Aa]vg[Ss]orted[Tt]otal { | |
3abe9331 | 1124 | yylval.uint_val = Profiler_Tools::STATS_FUNC_AVG_SORTED_TOTAL; |
a38c6d4c | 1125 | return ProfilerStatsFlag; |
1126 | } | |
1127 | [Tt]op10[Ll]ine[Tt]imes { | |
3abe9331 | 1128 | yylval.uint_val = Profiler_Tools::STATS_TOP10_LINE_TIMES; |
a38c6d4c | 1129 | return ProfilerStatsFlag; |
1130 | } | |
1131 | [Tt]op10[Ff]unc[Tt]imes { | |
3abe9331 | 1132 | yylval.uint_val = Profiler_Tools::STATS_TOP10_FUNC_TIMES; |
a38c6d4c | 1133 | return ProfilerStatsFlag; |
1134 | } | |
1135 | [Tt]op10[Ll]ine[Cc]ount { | |
3abe9331 | 1136 | yylval.uint_val = Profiler_Tools::STATS_TOP10_LINE_COUNT; |
a38c6d4c | 1137 | return ProfilerStatsFlag; |
1138 | } | |
1139 | [Tt]op10[Ff]unc[Cc]ount { | |
3abe9331 | 1140 | yylval.uint_val = Profiler_Tools::STATS_TOP10_FUNC_COUNT; |
a38c6d4c | 1141 | return ProfilerStatsFlag; |
1142 | } | |
1143 | [Tt]op10[Ll]ine[Aa]vg { | |
3abe9331 | 1144 | yylval.uint_val = Profiler_Tools::STATS_TOP10_LINE_AVG; |
a38c6d4c | 1145 | return ProfilerStatsFlag; |
1146 | } | |
1147 | [Tt]op10[Ff]unc[Aa]vg { | |
3abe9331 | 1148 | yylval.uint_val = Profiler_Tools::STATS_TOP10_FUNC_AVG; |
a38c6d4c | 1149 | return ProfilerStatsFlag; |
1150 | } | |
1151 | [Uu]nused[Ll]ines { | |
3abe9331 | 1152 | yylval.uint_val = Profiler_Tools::STATS_UNUSED_LINES; |
a38c6d4c | 1153 | return ProfilerStatsFlag; |
1154 | } | |
1155 | [Uu]nused[Ff]unc { | |
3abe9331 | 1156 | yylval.uint_val = Profiler_Tools::STATS_UNUSED_FUNC; |
a38c6d4c | 1157 | return ProfilerStatsFlag; |
1158 | } | |
1159 | [Aa]ll[Rr]aw[Dd]ata { | |
3abe9331 | 1160 | yylval.uint_val = Profiler_Tools::STATS_ALL_RAW_DATA; |
a38c6d4c | 1161 | return ProfilerStatsFlag; |
1162 | } | |
1163 | [Ll]ine[Dd]ata[Ss]orted[Bb]y[Mm]od { | |
3abe9331 | 1164 | yylval.uint_val = Profiler_Tools::STATS_LINE_DATA_SORTED_BY_MOD; |
a38c6d4c | 1165 | return ProfilerStatsFlag; |
1166 | } | |
1167 | [Ff]unc[Dd]ata[Ss]orted[Bb]y[Mm]od { | |
3abe9331 | 1168 | yylval.uint_val = Profiler_Tools::STATS_FUNC_DATA_SORTED_BY_MOD; |
a38c6d4c | 1169 | return ProfilerStatsFlag; |
1170 | } | |
1171 | [Ll]ine[Dd]ata[Ss]orted[Tt]otal { | |
3abe9331 | 1172 | yylval.uint_val = Profiler_Tools::STATS_LINE_DATA_SORTED_TOTAL; |
a38c6d4c | 1173 | return ProfilerStatsFlag; |
1174 | } | |
1175 | [Ff]unc[Dd]ata[Ss]orted[Tt]otal { | |
3abe9331 | 1176 | yylval.uint_val = Profiler_Tools::STATS_FUNC_DATA_SORTED_TOTAL; |
a38c6d4c | 1177 | return ProfilerStatsFlag; |
1178 | } | |
1179 | [Ll]ine[Dd]ata[Ss]orted { | |
3abe9331 | 1180 | yylval.uint_val = Profiler_Tools::STATS_LINE_DATA_SORTED; |
a38c6d4c | 1181 | return ProfilerStatsFlag; |
1182 | } | |
1183 | [Ff]unc[Dd]ata[Ss]orted { | |
3abe9331 | 1184 | yylval.uint_val = Profiler_Tools::STATS_FUNC_DATA_SORTED; |
a38c6d4c | 1185 | return ProfilerStatsFlag; |
1186 | } | |
1187 | [Aa]ll[Dd]ata[Ss]orted { | |
3abe9331 | 1188 | yylval.uint_val = Profiler_Tools::STATS_ALL_DATA_SORTED; |
a38c6d4c | 1189 | return ProfilerStatsFlag; |
1190 | } | |
1191 | [Tt]op10[Ll]ine[Dd]ata { | |
3abe9331 | 1192 | yylval.uint_val = Profiler_Tools::STATS_TOP10_LINE_DATA; |
a38c6d4c | 1193 | return ProfilerStatsFlag; |
1194 | } | |
1195 | [Tt]op10[Ff]unc[Dd]ata { | |
3abe9331 | 1196 | yylval.uint_val = Profiler_Tools::STATS_TOP10_FUNC_DATA; |
a38c6d4c | 1197 | return ProfilerStatsFlag; |
1198 | } | |
1199 | [Tt]op10[Aa]ll[Dd]ata { | |
3abe9331 | 1200 | yylval.uint_val = Profiler_Tools::STATS_TOP10_ALL_DATA; |
a38c6d4c | 1201 | return ProfilerStatsFlag; |
1202 | } | |
1203 | [Uu]nused[Dd]ata { | |
3abe9331 | 1204 | yylval.uint_val = Profiler_Tools::STATS_UNUSED_DATA; |
a38c6d4c | 1205 | return ProfilerStatsFlag; |
1206 | } | |
1207 | [Aa]ll { | |
3abe9331 | 1208 | yylval.uint_val = Profiler_Tools::STATS_ALL; |
a38c6d4c | 1209 | return ProfilerStatsFlag; |
1210 | } | |
af710487 | 1211 | } |
1212 | ||
970ed795 EL |
1213 | <SC_EXECUTE>control return ControlKeyword; |
1214 | ||
1215 | <SC_EXTERNAL_COMMANDS> | |
1216 | { | |
1217 | [Bb]egin[Cc]ontrol[Pp]art return BeginControlPart; | |
1218 | [Ee]nd[Cc]ontrol[Pp]art return EndControlPart; | |
1219 | [Bb]egin[Tt]est[Cc]ase return BeginTestCase; | |
1220 | [Ee]nd[Tt]est[Cc]ase return EndTestCase; | |
1221 | } | |
1222 | ||
1223 | <SC_MAIN_CONTROLLER> | |
1224 | { | |
1225 | [Ll]ocal[Aa]ddress return LocalAddress; | |
1226 | [Tt][Cc][Pp][Pp]ort return TCPPort; | |
1227 | [Kk]ill[Tt]imer return KillTimer; | |
1228 | [Nn]um[Hh][Cc]s return NumHCs; | |
1229 | [Uu]nix[Ss]ockets[Ee]nabled return UnixSocketEnabled; | |
1230 | [Yy][Ee][Ss] return YesToken; | |
1231 | [Nn][Oo] return NoToken; | |
1232 | } | |
1233 | ||
1234 | {TTCN3IDENTIFIER} { | |
1235 | yylval.str_val = mcopystr(yytext); | |
1236 | return Identifier; | |
1237 | } | |
1238 | ||
1239 | <SC_MODULE_PARAMETERS>{ASN1LOWERIDENTIFIER} { | |
1240 | yylval.str_val = mcopystr(yytext); | |
3abe9331 | 1241 | for (size_t i = 0; i < yyleng; i++) { |
970ed795 EL |
1242 | if (yylval.str_val[i] == '-') yylval.str_val[i] = '_'; |
1243 | } | |
1244 | TTCN_warning("In line %d of configuration file: `%s' is not a valid TTCN-3 " | |
1245 | "identifier. Did you mean `%s'?", current_line, yytext, yylval.str_val); | |
1246 | return ASN1LowerIdentifier; | |
1247 | } | |
1248 | ||
1249 | <SC_GROUPS,SC_COMPONENTS,SC_MAIN_CONTROLLER>{DNSNAME}|{IPV6} return DNSName; | |
1250 | /* Information is discarded ! */ | |
1251 | ||
1252 | <SC_STRING2TTCN_COMPONENT>{COMPONENT} { | |
1253 | /* Ignore the component name, just return its number */ | |
1254 | size_t len = strlen(yytext); | |
1255 | size_t pos = len - 1; | |
1256 | while(yytext[pos] != '(' && pos != 0) { | |
1257 | --pos; | |
1258 | } | |
1259 | char* comp_num_str = mcopystrn(yytext + pos + 1, len - pos - 1); | |
1260 | yylval.int_val = new int_val_t(comp_num_str); | |
1261 | Free(comp_num_str); | |
3abe9331 | 1262 | return MPNumber; |
970ed795 EL |
1263 | } |
1264 | ||
1265 | {MACRO_BOOL} { | |
1266 | if (config_defines != NULL) { | |
1267 | char *macroname = get_macro_id_from_ref(yytext); | |
1268 | size_t macrolen; | |
1269 | const char *macrovalue = | |
1270 | string_map_get_bykey(config_defines, macroname, ¯olen); | |
1271 | if (macrovalue != NULL) { | |
1272 | if (!strcmp(macrovalue, "true")) yylval.bool_val = TRUE; | |
1273 | else if (!strcmp(macrovalue, "false")) yylval.bool_val = FALSE; | |
1274 | else { | |
1275 | config_process_error_f("Macro `%s' cannot be interpreted as boolean " | |
1276 | "value: `%s'", macroname, macrovalue); | |
1277 | yylval.bool_val = FALSE; | |
1278 | } | |
1279 | } else { | |
1280 | config_process_error_f("No macro or environmental variable defined" | |
1281 | " with name `%s'", macroname); | |
1282 | yylval.bool_val = FALSE; | |
1283 | } | |
1284 | Free(macroname); | |
1285 | } else { | |
1286 | config_process_error("Internal error: Macro reference cannot be used in " | |
1287 | "this context."); | |
1288 | yylval.bool_val = FALSE; | |
1289 | } | |
1290 | return BooleanValue; | |
1291 | } | |
1292 | ||
1293 | {MACRO_INT} { | |
1294 | if (config_defines != NULL) { | |
1295 | char *macroname = get_macro_id_from_ref(yytext); | |
1296 | size_t macrolen; | |
1297 | const char *macrovalue = | |
1298 | string_map_get_bykey(config_defines, macroname, ¯olen); | |
1299 | if (macrovalue != NULL) { | |
1300 | if (string_is_int(macrovalue, macrolen)) | |
1301 | yylval.int_val = new int_val_t(macrovalue); | |
1302 | else { | |
1303 | config_process_error_f("Macro `%s' cannot be interpreted as integer " | |
1304 | "value: `%s'", macroname, macrovalue); | |
1305 | yylval.int_val = new int_val_t((RInt)0); | |
1306 | } | |
1307 | } else { | |
1308 | config_process_error_f("No macro or environmental variable defined" | |
1309 | " with name `%s'", macroname); | |
1310 | yylval.int_val = new int_val_t((RInt)0); | |
1311 | } | |
1312 | Free(macroname); | |
1313 | } else { | |
1314 | config_process_error("Internal error: Macro reference cannot be used in " | |
1315 | "this context."); | |
1316 | yylval.int_val = new int_val_t((RInt)0); | |
1317 | } | |
19700695 | 1318 | if (YY_START == SC_MODULE_PARAMETERS || YY_START == SC_CHAR_KEYWORD) { |
3abe9331 | 1319 | // return a different token for module parameters so it doesn't conflict with references |
1320 | return MPNumber; | |
1321 | } | |
970ed795 EL |
1322 | return Number; |
1323 | } | |
1324 | ||
1325 | {MACRO_FLOAT} { | |
1326 | if (config_defines != NULL) { | |
1327 | char *macroname = get_macro_id_from_ref(yytext); | |
1328 | size_t macrolen; | |
1329 | const char *macrovalue = | |
1330 | string_map_get_bykey(config_defines, macroname, ¯olen); | |
1331 | if (macrovalue != NULL) { | |
1332 | if (string_is_float(macrovalue, macrolen)) | |
1333 | yylval.float_val = atof(macrovalue); | |
1334 | else { | |
1335 | config_process_error_f("Macro `%s' cannot be interpreted as float value: " | |
1336 | "`%s'", macroname, macrovalue); | |
1337 | yylval.float_val = 0.0; | |
1338 | } | |
1339 | } else { | |
1340 | config_process_error_f("No macro or environmental variable defined" | |
1341 | " with name `%s'", macroname); | |
1342 | yylval.float_val = 0.0; | |
1343 | } | |
1344 | Free(macroname); | |
1345 | } else { | |
1346 | config_process_error("Internal error: Macro reference cannot be used in " | |
1347 | "this context."); | |
1348 | yylval.float_val = 0.0; | |
1349 | } | |
19700695 | 1350 | if (YY_START == SC_MODULE_PARAMETERS || YY_START == SC_CHAR_KEYWORD) { |
3abe9331 | 1351 | // return a different token for module parameters so it doesn't conflict with references |
1352 | return MPFloat; | |
1353 | } | |
970ed795 EL |
1354 | return Float; |
1355 | } | |
1356 | ||
1357 | {MACRO_ID} { | |
1358 | if (config_defines != NULL) { | |
1359 | char *macroname = get_macro_id_from_ref(yytext); | |
1360 | size_t macrolen; | |
1361 | const char *macrovalue = | |
1362 | string_map_get_bykey(config_defines, macroname, ¯olen); | |
1363 | boolean is_asn = FALSE; | |
1364 | if (macrovalue != NULL) { | |
1365 | if (string_is_id(macrovalue, macrolen)) { | |
1366 | yylval.str_val = mcopystr(macrovalue); | |
1367 | for (size_t i = 0; i < macrolen; i++) { | |
1368 | if (yylval.str_val[i]=='-') { | |
1369 | yylval.str_val[i] = '_'; | |
1370 | is_asn = TRUE; | |
1371 | } | |
1372 | } | |
1373 | if (is_asn) | |
1374 | TTCN_warning("In line %d of configuration file: `%s' is not a valid" | |
1375 | " TTCN-3 identifier. Did you mean `%s'?", | |
1376 | current_line, macrovalue, yylval.str_val); | |
1377 | } else { | |
1378 | config_process_error_f("Macro `%s' cannot be interpreted as identifier: " | |
1379 | "`%s'", macroname, macrovalue); | |
1380 | yylval.str_val = memptystr(); | |
1381 | } | |
1382 | } else { | |
1383 | config_process_error_f("No macro or environmental variable defined with " | |
1384 | "name `%s'", macroname); | |
1385 | yylval.str_val = memptystr(); | |
1386 | } | |
1387 | Free(macroname); | |
1388 | return is_asn ? ASN1LowerIdentifier : Identifier; | |
1389 | } else { | |
1390 | config_process_error("Internal error: Macro reference cannot be used in " | |
1391 | "this context."); | |
1392 | yylval.str_val = memptystr(); | |
1393 | return Identifier; | |
1394 | } | |
1395 | } | |
1396 | ||
1397 | {MACRO_CSTR} { | |
1398 | if (config_defines == NULL) { | |
1399 | config_process_error("Internal error: Macro reference cannot be used in " | |
1400 | "this context."); | |
1401 | yylval.charstring_val.n_chars = 0; | |
1402 | yylval.charstring_val.chars_ptr = memptystr(); | |
19700695 | 1403 | if (YY_START == SC_MODULE_PARAMETERS || YY_START == SC_CHAR_KEYWORD) { |
3abe9331 | 1404 | // return a different token for module parameters so it doesn't conflict with references |
1405 | return MPCstring; | |
1406 | } | |
970ed795 EL |
1407 | return Cstring; |
1408 | } | |
1409 | ||
1410 | char *macroname; | |
1411 | if (yytext[1] == '{') macroname = get_macro_id_from_ref(yytext); | |
1412 | else macroname = mcopystr(yytext + 1); | |
1413 | size_t macrolen; | |
1414 | const char *macrovalue = string_map_get_bykey | |
1415 | (config_defines, macroname, ¯olen); | |
1416 | ||
1417 | if (macrovalue == NULL) { | |
1418 | config_process_error_f("No macro or environmental variable defined with name " | |
1419 | "`%s'", macroname); | |
1420 | yylval.charstring_val.n_chars=0; | |
1421 | yylval.charstring_val.chars_ptr=memptystr(); | |
1422 | Free(macroname); | |
19700695 | 1423 | if (YY_START == SC_MODULE_PARAMETERS || YY_START == SC_CHAR_KEYWORD) { |
3abe9331 | 1424 | // return a different token for module parameters so it doesn't conflict with references |
1425 | return MPCstring; | |
1426 | } | |
970ed795 EL |
1427 | return Cstring; |
1428 | } | |
1429 | ||
1430 | if (macrolen > 0 && macrovalue[0] == '{') { // structured | |
1431 | main_buffer = YY_CURRENT_BUFFER; | |
1432 | expansion_buffer = yy_scan_string(macrovalue); | |
1433 | yy_switch_to_buffer(expansion_buffer); | |
1434 | Free(macroname); | |
1435 | } else { | |
1436 | yylval.charstring_val.n_chars=macrolen; | |
1437 | yylval.charstring_val.chars_ptr=(char*)Malloc(macrolen+1); | |
1438 | memcpy(yylval.charstring_val.chars_ptr, macrovalue, macrolen+1); | |
1439 | Free(macroname); | |
19700695 | 1440 | if (YY_START == SC_MODULE_PARAMETERS || YY_START == SC_CHAR_KEYWORD) { |
3abe9331 | 1441 | // return a different token for module parameters so it doesn't conflict with references |
1442 | return MPCstring; | |
1443 | } | |
970ed795 EL |
1444 | return Cstring; |
1445 | } | |
1446 | } | |
1447 | ||
1448 | {MACRO_BSTR} { | |
1449 | if (config_defines != NULL) { | |
1450 | char *macroname = get_macro_id_from_ref(yytext); | |
1451 | size_t macrolen; | |
1452 | const char *macrovalue = | |
1453 | string_map_get_bykey(config_defines, macroname, ¯olen); | |
1454 | if (macrovalue != NULL) { | |
1455 | if (string_is_bstr(macrovalue, macrolen)) { | |
1456 | yylval.bitstring_val.n_bits = macrolen; | |
1457 | int n_bytes = (yylval.bitstring_val.n_bits + 7) / 8; | |
1458 | yylval.bitstring_val.bits_ptr = (unsigned char *)Malloc(n_bytes); | |
1459 | memset(yylval.bitstring_val.bits_ptr, 0, n_bytes); | |
1460 | for (int i = 0; i < yylval.bitstring_val.n_bits; i++) | |
1461 | if (macrovalue[i] == '1') | |
1462 | yylval.bitstring_val.bits_ptr[i/8] |= 1 << (i % 8); | |
1463 | } else { | |
1464 | config_process_error_f("Macro `%s' cannot be interpreted as bitstring " | |
1465 | "value: `%s'", macroname, macrovalue); | |
1466 | yylval.bitstring_val.n_bits = 0; | |
1467 | yylval.bitstring_val.bits_ptr = NULL; | |
1468 | } | |
1469 | } else { | |
1470 | config_process_error_f("No macro or environmental variable defined with " | |
1471 | "name `%s'", macroname); | |
1472 | yylval.bitstring_val.n_bits = 0; | |
1473 | yylval.bitstring_val.bits_ptr = NULL; | |
1474 | } | |
1475 | Free(macroname); | |
1476 | } else { | |
1477 | config_process_error_f("Internal error: Macro reference cannot be used in " | |
1478 | "this context."); | |
1479 | yylval.bitstring_val.n_bits = 0; | |
1480 | yylval.bitstring_val.bits_ptr = NULL; | |
1481 | } | |
1482 | return Bstring; | |
1483 | } | |
1484 | ||
1485 | {MACRO_HSTR} { | |
1486 | if (config_defines != NULL) { | |
1487 | char *macroname = get_macro_id_from_ref(yytext); | |
1488 | size_t macrolen; | |
1489 | const char *macrovalue = | |
1490 | string_map_get_bykey(config_defines, macroname, ¯olen); | |
1491 | if (macrovalue != NULL) { | |
1492 | if(string_is_hstr(macrovalue, macrolen)) { | |
1493 | yylval.hexstring_val.n_nibbles = macrolen; | |
1494 | int n_bytes = (yylval.hexstring_val.n_nibbles + 1) / 2; | |
1495 | yylval.hexstring_val.nibbles_ptr = (unsigned char *)Malloc(n_bytes); | |
1496 | memset(yylval.hexstring_val.nibbles_ptr, 0, n_bytes); | |
1497 | for (int i = 0; i < yylval.hexstring_val.n_nibbles; i++) { | |
1498 | unsigned int hex_digit; | |
1499 | sscanf(macrovalue+i, "%1x", &hex_digit); | |
1500 | if(i % 2) yylval.hexstring_val.nibbles_ptr[i/2] |= | |
1501 | (hex_digit << 4); | |
1502 | else yylval.hexstring_val.nibbles_ptr[i/2] |= hex_digit; | |
1503 | } | |
1504 | } else { | |
1505 | config_process_error_f("Macro `%s' cannot be interpreted as hexstring " | |
1506 | "value: `%s'", macroname, macrovalue); | |
1507 | yylval.hexstring_val.n_nibbles = 0; | |
1508 | yylval.hexstring_val.nibbles_ptr = NULL; | |
1509 | } | |
1510 | } else { | |
1511 | config_process_error_f("No macro or environmental variable defined with " | |
1512 | "name `%s'", macroname); | |
1513 | yylval.hexstring_val.n_nibbles = 0; | |
1514 | yylval.hexstring_val.nibbles_ptr = NULL; | |
1515 | } | |
1516 | Free(macroname); | |
1517 | } else { | |
1518 | config_process_error("Internal error: Macro reference cannot be used in " | |
1519 | "this context."); | |
1520 | yylval.hexstring_val.n_nibbles = 0; | |
1521 | yylval.hexstring_val.nibbles_ptr = NULL; | |
1522 | } | |
1523 | return Hstring; | |
1524 | } | |
1525 | ||
1526 | {MACRO_OSTR} { | |
1527 | if (config_defines != NULL) { | |
1528 | char *macroname = get_macro_id_from_ref(yytext); | |
1529 | size_t macrolen; | |
1530 | const char *macrovalue = | |
1531 | string_map_get_bykey(config_defines, macroname, ¯olen); | |
1532 | if (macrovalue != NULL) { | |
1533 | if (string_is_ostr(macrovalue, macrolen)) { | |
1534 | yylval.octetstring_val.n_octets = macrolen / 2; | |
1535 | yylval.octetstring_val.octets_ptr = (unsigned char *) | |
1536 | Malloc(yylval.octetstring_val.n_octets); | |
1537 | for (int i = 0; i < yylval.octetstring_val.n_octets; i++) { | |
1538 | unsigned int this_octet; | |
1539 | sscanf(macrovalue+2*i, "%2x", &this_octet); | |
1540 | yylval.octetstring_val.octets_ptr[i] = this_octet; | |
1541 | } | |
1542 | } else { | |
1543 | config_process_error_f("Macro `%s' cannot be interpreted as octetstring " | |
1544 | "value: `%s'", macroname, macrovalue); | |
1545 | yylval.octetstring_val.n_octets = 0; | |
1546 | yylval.octetstring_val.octets_ptr = NULL; | |
1547 | } | |
1548 | } else { | |
1549 | config_process_error_f("No macro or environmental variable defined with " | |
1550 | "name `%s'", macroname); | |
1551 | yylval.octetstring_val.n_octets = 0; | |
1552 | yylval.octetstring_val.octets_ptr = NULL; | |
1553 | } | |
1554 | Free(macroname); | |
1555 | } else { | |
1556 | config_process_error_f("Internal error: Macro reference cannot be used in " | |
1557 | "this context."); | |
1558 | yylval.octetstring_val.n_octets = 0; | |
1559 | yylval.octetstring_val.octets_ptr = NULL; | |
1560 | } | |
1561 | return Ostring; | |
1562 | } | |
1563 | ||
1564 | {MACRO_BINARY} { | |
1565 | if (config_defines != NULL) { | |
1566 | char *macroname = get_macro_id_from_ref(yytext); | |
1567 | size_t macrolen; | |
1568 | const char *macrovalue = | |
1569 | string_map_get_bykey(config_defines, macroname, ¯olen); | |
1570 | if (macrovalue != NULL) { | |
1571 | yylval.octetstring_val.n_octets=macrolen; | |
1572 | yylval.octetstring_val.octets_ptr = (unsigned char*)Malloc(macrolen); | |
1573 | memcpy(yylval.octetstring_val.octets_ptr, macrovalue, macrolen); | |
1574 | } | |
1575 | else { | |
1576 | config_process_error_f("No macro or environmental variable defined with " | |
1577 | "name `%s'", macroname); | |
1578 | yylval.octetstring_val.n_octets = 0; | |
1579 | yylval.octetstring_val.octets_ptr = NULL; | |
1580 | } | |
1581 | Free(macroname); | |
1582 | } else { | |
1583 | config_process_error("Internal error: Macro reference cannot be used in " | |
1584 | "this context."); | |
1585 | yylval.octetstring_val.n_octets = 0; | |
1586 | yylval.octetstring_val.octets_ptr = NULL; | |
1587 | } | |
1588 | return Ostring; | |
1589 | } | |
1590 | ||
1591 | {MACRO_HOSTNAME} { | |
1592 | if (config_defines != NULL) { | |
1593 | char *macroname = get_macro_id_from_ref(yytext); | |
1594 | size_t macrolen; | |
1595 | const char *macrovalue = | |
1596 | string_map_get_bykey(config_defines, macroname, ¯olen); | |
1597 | if (macrovalue != NULL) { | |
1598 | if (!string_is_hostname(macrovalue, macrolen)) { | |
1599 | config_process_error_f("Macro `%s' cannot be interpreted as host name: " | |
1600 | "`%s'", macroname, macrovalue); | |
1601 | } | |
1602 | } else { | |
1603 | config_process_error_f("No macro or environmental variable defined with " | |
1604 | "name `%s'", macroname); | |
1605 | } | |
1606 | Free(macroname); | |
1607 | } else { | |
1608 | config_process_error("Internal error: Macro reference cannot be used in " | |
1609 | "this context."); | |
1610 | } | |
1611 | return DNSName; | |
1612 | } | |
1613 | ||
1614 | ":="|"=" return AssignmentChar; | |
1615 | "&=" return ConcatChar; | |
1616 | ||
1617 | <<EOF>> { | |
1618 | if (expansion_buffer) { | |
1619 | yy_switch_to_buffer(main_buffer); | |
1620 | yy_delete_buffer(expansion_buffer); | |
1621 | expansion_buffer = NULL; | |
1622 | } else { | |
1623 | if (include_chain->size() > 1) { | |
1624 | yy_delete_buffer(YY_CURRENT_BUFFER); | |
1625 | fclose(include_chain->back().fp); | |
1626 | include_chain->pop_back(); | |
1627 | yy_switch_to_buffer(include_chain->back().buffer_state); | |
1628 | current_line = include_chain->back().line_number; | |
1629 | BEGIN(SC_ORDERED_INCLUDE); | |
1630 | } else { | |
1631 | yyterminate(); | |
1632 | return EOF; | |
1633 | } | |
1634 | } | |
1635 | } | |
1636 | ||
1637 | ||
1638 | ||
19700695 | 1639 | . return yytext[0]; |
970ed795 EL |
1640 | |
1641 | ||
1642 | %% | |
1643 | ||
1644 | void reset_config_process_lex(const char* fname) | |
1645 | { | |
1646 | if (!include_chain) { | |
1647 | include_chain = new std::deque<IncludeElem<YY_BUFFER_STATE> >(); | |
1648 | } | |
1649 | BEGIN(INITIAL); | |
1650 | current_line = 1; | |
1651 | if (fname) { | |
1652 | include_chain->push_back(IncludeElem<YY_BUFFER_STATE>(std::string(fname), config_process_in)); | |
1653 | } | |
1654 | } | |
1655 | ||
1656 | void config_process_close() { | |
1657 | delete include_chain; | |
1658 | include_chain = NULL; | |
1659 | } | |
1660 | ||
1661 | int config_process_get_current_line() | |
1662 | { | |
1663 | return current_line; | |
1664 | } | |
1665 | ||
1666 |