f9a02b0faf68e6646200de190c72f26341ebb423
[deliverable/titan.core.git] / mctr2 / cli / config_read.l
1 /******************************************************************************
2 * Copyright (c) 2000-2015 Ericsson Telecom AB
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
7 ******************************************************************************/
8 %option yylineno
9 %option noyywrap
10 %option never-interactive
11 %option nounput
12
13 %{
14
15 #include <string.h>
16 #include <ctype.h>
17 #include <stdlib.h>
18
19 #include <deque>
20 #include <string>
21
22 #include <openssl/crypto.h>
23 #include <openssl/bn.h>
24
25 #include "../../common/cfg_process_utils.hh"
26 #include "../../common/Path2.hh"
27 #include "../../common/config_preproc.h"
28
29 #include "../../common/memory.h"
30 #include "../mctr/config_data.h"
31 #include "../../core/Types.h"
32 #include "config_read.tab.hh"
33
34 //#include "../../common/dbgnew.hh"
35
36 extern string_map_t *config_defines;
37
38 #define yylval config_read_lval
39
40 /* This buffer stores the state of the main buffer
41 while the macro expansion is happening. */
42 static YY_BUFFER_STATE main_buffer = NULL;
43 /* This buffer is active while the expansion of
44 a reference to a structured macro definition is happening.
45 Otherwise its value is NULL. */
46 static YY_BUFFER_STATE expansion_buffer = NULL;
47
48 static void update_buffer();
49 static boolean whether_update_buffer();
50
51 #define RETURN(x) do {update_buffer(); return (x);} while(0)
52
53 void config_read_warning(const char *warning_str, ...);
54 extern void config_read_error(const char *error_str, ...);
55 extern config_data *cfg;
56
57 static std::deque<IncludeElem<YY_BUFFER_STATE> >* include_chain = NULL;
58
59 std::string get_cfg_read_current_file() {
60 if (include_chain && !include_chain->empty()) {
61 return include_chain->back().get_full_path();
62 }
63 return std::string();
64 }
65
66 %}
67
68 WHITESPACE [ \t]
69 WS {WHITESPACE}*
70 NEWLINE \r|\n|\r\n
71 LINECOMMENT ("//"|"#")[^\r\n]*{NEWLINE}
72
73 NUMBER 0|([1-9][0-9]*)
74
75 FLOAT [+-]?({NUMBER}\.[0-9]+)|((({NUMBER}(\.[0-9]+)?)|(\.[0-9]+))[Ee][+-]?{NUMBER})
76
77 BIN 0|1
78 BITSTRING '{BIN}*'B
79 BINMATCH 0|1|\?|\*
80 BITSTRINGMATCH '{BINMATCH}*'B
81 BITSTRING_BAD '[^']*'B
82
83 HEX [0-9A-Fa-f]
84 HEXSTRING '{HEX}*'H
85 HEXMATCH [0-9A-Fa-f\?\*]
86 HEXSTRINGMATCH '{HEXMATCH}*'H
87 HEXSTRING_BAD '[^']*'H
88
89 OCT {HEX}{HEX}
90 OCTETSTRING '{OCT}*'O
91 OCTMATCH {HEX}{HEX}|\?|\*
92 OCTETSTRINGMATCH '{OCTMATCH}*'O
93 OCTETSTRING_BAD '[^']*'O
94
95 BINSTRING_BAD '[^']*'
96
97 TTCN3IDENTIFIER [A-Za-z][A-Za-z0-9_]*
98 ASN1LOWERIDENTIFIER [a-z](-?[A-Za-z0-9]+)*
99
100 MACRORVALUE ([0-9A-Za-z._-]+)|{IPV6}
101 MACRO_CSTR \${TTCN3IDENTIFIER}|\$"{"{WS}{TTCN3IDENTIFIER}{WS}(","{WS}charstring{WS})?"}"
102 MACRO_BOOL \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}boolean{WS}"}"
103 MACRO_FLOAT \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}float{WS}"}"
104 MACRO_ID \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}identifier{WS}"}"
105 MACRO_INT \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}integer{WS}"}"
106 MACRO_BSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}bitstring{WS}"}"
107 MACRO_HSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}hexstring{WS}"}"
108 MACRO_OSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}octetstring{WS}"}"
109 MACRO_BINARY \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}binaryoctet{WS}"}"
110 MACRO_HOSTNAME \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}hostname{WS}"}"
111
112 CHAR [^\\\"]|\\([\\\'\"\?abfnrtv]|{NEWLINE}|[0-7]{1,3}|x{HEX}{1,2})|\"\"
113 CHARSTRING \"{CHAR}*\"
114
115 HOSTNAME [A-Za-z0-9]([A-Za-z0-9_\-]*[A-Za-z0-9])?
116 DNSNAME {HOSTNAME}(\.{HOSTNAME})*\.?
117
118 /* Example: fe80::c002:37ff:fe6c:0%fastethernet0/0 */
119 IPV6 [0-9A-Fa-f:.]+(%[0-9A-Za-z]+)?
120
121
122 %x SC_blockcomment SC_DEFINE SC_CSTRING SC_ORDERED_INCLUDE
123 %s SC_MODULE_PARAMETERS SC_LOGGING SC_TESTPORT_PARAMETERS SC_EXECUTE SC_GROUPS
124 %s SC_COMPONENTS SC_EXTERNAL_COMMANDS SC_MAIN_CONTROLLER SC_INCLUDE SC_PROFILER
125
126 %%
127 int comment_caller = INITIAL;
128
129 std::string cstring;
130
131 /* Eat up comments and whitespaces */
132
133 "/*" {
134 comment_caller = YY_START;
135 BEGIN(SC_blockcomment);
136 }
137 <SC_blockcomment>
138 {
139 "*/" BEGIN(comment_caller);
140 .|\n
141 }
142
143 {LINECOMMENT}|{WHITESPACE}|{NEWLINE}
144
145 /* Section delimiters */
146
147 <*>"["{WS}MODULE_PARAMETERS{WS}"]" {
148 if (YY_START!=SC_blockcomment) {
149 BEGIN(SC_MODULE_PARAMETERS);
150 RETURN(ModuleParametersKeyword);
151 }
152 }
153
154 <*>"["{WS}LOGGING{WS}"]" {
155 if (YY_START!=SC_blockcomment) {
156 BEGIN(SC_LOGGING);
157 RETURN(LoggingKeyword);
158 }
159 }
160
161 <*>"["{WS}PROFILER{WS}"]" {
162 if (YY_START!=SC_blockcomment) {
163 BEGIN(SC_PROFILER);
164 RETURN(ProfilerKeyword);
165 }
166 }
167
168 <*>"["{WS}TESTPORT_PARAMETERS{WS}"]" {
169 if (YY_START!=SC_blockcomment) {
170 BEGIN(SC_TESTPORT_PARAMETERS);
171 RETURN(TestportParametersKeyword);
172 }
173 }
174
175 <*>"["{WS}EXECUTE{WS}"]" {
176 if (YY_START!=SC_blockcomment) {
177 BEGIN(SC_EXECUTE);
178 RETURN(ExecuteKeyword);
179 }
180 }
181
182 <*>"["{WS}EXTERNAL_COMMANDS{WS}"]" {
183 if (YY_START!=SC_blockcomment) {
184 BEGIN(SC_EXTERNAL_COMMANDS);
185 RETURN(ExternalCommandsKeyword);
186 }
187 }
188
189 <*>"["{WS}GROUPS{WS}"]" {
190 if (YY_START!=SC_blockcomment) {
191 BEGIN(SC_GROUPS);
192 RETURN(GroupsKeyword);
193 }
194 }
195
196 <*>"["{WS}COMPONENTS{WS}"]" {
197 if (YY_START!=SC_blockcomment) {
198 BEGIN(SC_COMPONENTS);
199 RETURN(ComponentsKeyword);
200 }
201 }
202
203 <*>"["{WS}MAIN_CONTROLLER{WS}"]" {
204 if (YY_START!=SC_blockcomment) {
205 BEGIN(SC_MAIN_CONTROLLER);
206 RETURN(MainControllerKeyword);
207 }
208 }
209
210 <*>"["{WS}INCLUDE{WS}"]" {
211 if (YY_START!=SC_blockcomment) {
212 BEGIN(SC_INCLUDE);
213 RETURN(IncludeKeyword);
214 }
215 }
216
217 <*>"["{WS}ORDERED_INCLUDE{WS}"]" {
218 if (YY_START!=SC_blockcomment) {
219 BEGIN(SC_ORDERED_INCLUDE);
220 }
221 }
222
223
224 <*>"["{WS}DEFINE{WS}"]" {
225 if (YY_START!=SC_blockcomment) {
226 BEGIN(SC_DEFINE);
227 RETURN(DefineKeyword);
228 }
229 }
230
231 /* Rules for SC_DEFINE must precede everything else */
232
233 <SC_DEFINE>{
234
235 "/*" {
236 comment_caller = SC_DEFINE;
237 BEGIN(SC_blockcomment);
238 }
239
240 {CHARSTRING} /* eats string */
241
242 {LINECOMMENT}
243
244 {NEWLINE} /* this is not in . */
245
246 \\\"
247
248 . /* eats unnecessary things */
249
250 }
251
252 <SC_ORDERED_INCLUDE>{
253
254 "/*" {
255 comment_caller = YY_START;
256 BEGIN(SC_blockcomment);
257 }
258
259 \" { BEGIN(SC_CSTRING); }
260
261 {LINECOMMENT}
262
263 {NEWLINE} /* this is not in . */
264
265 \\\"
266
267 . /* eat unnecessary chars */
268
269 }
270
271
272 <SC_CSTRING>{
273
274 \"\" cstring += '"';
275
276 \" {
277 std::string error_msg = switch_lexer(include_chain, cstring,
278 YY_CURRENT_BUFFER, yy_create_buffer, yy_switch_to_buffer, yylineno,
279 YY_BUF_SIZE);
280 if (error_msg.empty()) {
281 BEGIN(INITIAL);
282 } else {
283 config_read_error(error_msg.c_str());
284 }
285
286 cstring.clear();
287 } /* end of string */
288
289 \\[\\'"?] cstring += yytext[1]; /* backslash-quoted \ or " or ' or ? */
290 \\{NEWLINE} yylineno++;
291 \\a cstring += '\a';
292 \\b cstring += '\b';
293 \\f cstring += '\f';
294 \\n cstring += '\n';
295 \\r cstring += '\r';
296 \\t cstring += '\t';
297 \\v cstring += '\v';
298
299 \\[0-7]{1,3} {
300 unsigned int c;
301 sscanf(yytext + 1, "%o", &c);
302 if (c <= 255) cstring += c;
303 else config_read_error("Invalid octal character code in string literal");
304 }
305
306 \\x{HEX}{1,2} {
307 unsigned int c;
308 sscanf(yytext + 2, "%x", &c);
309 cstring += c;
310 }
311
312 \\(x[^\\\"]|.) config_read_error("Invalid excape sequence in string literal.");
313
314 {NEWLINE} {
315 cstring.append(yytext, yyleng);
316 yylineno++;
317 }
318
319 . {
320 cstring += yytext[0];
321 }
322 }
323 /* SC_cstring */
324
325
326 <SC_PROFILER>{HEX}+ {
327 /* numeric statistics filter (check this before checking NUMBERs) */
328 RETURN(ProfilerStatsFlag);
329 }
330
331
332 /* Values */
333
334 {NUMBER} {
335 yylval.int_val = NULL;
336 BN_dec2bn(&yylval.int_val, *yytext == '+' ? yytext + 1 : yytext);
337 if (YY_START == SC_MODULE_PARAMETERS) {
338 RETURN(MPNumber);
339 }
340 RETURN(Number);
341 }
342
343 {FLOAT} {
344 yylval.float_val = atof(yytext);
345 if (YY_START == SC_MODULE_PARAMETERS) {
346 RETURN(MPFloat);
347 }
348 RETURN(Float);
349 }
350
351 {BITSTRING} RETURN(Bstring);
352
353 {BITSTRINGMATCH} RETURN(BstringMatch);
354
355 {BITSTRING_BAD} {
356 config_read_error("Invalid bitstring value.");
357 RETURN(Bstring);
358 }
359
360 {HEXSTRING} RETURN(Hstring);
361
362 {HEXSTRINGMATCH} RETURN(HstringMatch);
363
364 {HEXSTRING_BAD} {
365 config_read_error("Invalid hexstring value.");
366 RETURN(Hstring);
367 }
368
369 {OCTETSTRING} RETURN(Ostring);
370
371 {OCTETSTRINGMATCH} RETURN(OstringMatch);
372
373 {OCTETSTRING_BAD} {
374 config_read_error("Invalid octetstring value.");
375 RETURN(Ostring);
376 }
377
378 {BINSTRING_BAD} config_read_error("Invalid string value.");
379
380 ' config_read_error("Unmatched ' character.");
381
382 {CHARSTRING} {
383 yylval.str_val = mcopystrn(yytext, yyleng);
384 if (YY_START == SC_MODULE_PARAMETERS) {
385 RETURN(MPCstring);
386 }
387 RETURN(Cstring);
388 }
389
390 /* Section-wide keywords */
391
392 <SC_MODULE_PARAMETERS>
393 {
394 NULL RETURN(NULLKeyword);
395 null RETURN(nullKeyword);
396 char RETURN(CharKeyword);
397 objid RETURN(ObjIdKeyword);
398 omit RETURN(OmitKeyword);
399 none |
400 pass |
401 inconc |
402 fail |
403 error RETURN(VerdictValue);
404 complement RETURN(ComplementKeyword);
405 "\.\." RETURN(DotDot);
406 superset RETURN(SupersetKeyword);
407 subset RETURN(SubsetKeyword);
408 pattern RETURN(PatternKeyword);
409 permutation RETURN(PermutationKeyword);
410 length RETURN(LengthKeyword);
411 ifpresent RETURN(IfpresentKeyword);
412 infinity RETURN(InfinityKeyword);
413 }
414
415 <SC_MODULE_PARAMETERS,SC_LOGGING,SC_PROFILER>
416 {
417 true |
418 false RETURN(BooleanValue);
419 }
420
421 <SC_MODULE_PARAMETERS,SC_LOGGING,SC_TESTPORT_PARAMETERS>
422 {
423 mtc RETURN(MTCKeyword);
424 system RETURN(SystemKeyword);
425 }
426
427 <SC_LOGGING>
428 {
429 [Ff]ile[Nn]ame |
430 [Ll]og[Ff]ile RETURN(LogFile);
431
432 [Ee]mergency[Ll]ogging RETURN(EmergencyLogging);
433
434 [Ee]mergency[Ll]ogging[Bb]ehaviour RETURN(EmergencyLoggingBehaviour);
435
436 [Bb]uffer[Aa]ll |
437 [Bb]uffer[Ma]asked RETURN(EmergencyLoggingBehaviourValue);
438
439 [Ee]mergency[Ll]ogging[Mm]ask RETURN(EmergencyLoggingMask);
440
441
442 [Ff]ile[Mm]ask RETURN(FileMask);
443
444 [Cc]onsole[Mm]ask RETURN(ConsoleMask);
445
446 [Tt]ime[Ss]tamp[Ff]ormat RETURN(TimestampFormat);
447 [Cc]onsole[Tt]ime[Ss]tamp[Ff]ormat RETURN(ConsoleTimestampFormat);
448
449 [Ll]og[Ss]ource[Ii]nfo |
450 [Ss]ource[Ii]nfo[Ff]ormat RETURN(SourceInfoFormat);
451
452 [Aa]ppend[Ff]ile RETURN(AppendFile);
453
454 [Ll]og[Ee]vent[Tt]ypes RETURN(LogEventTypes);
455
456 [Ll]og[Ee]ntity[Nn]ame RETURN(LogEntityName);
457
458 [Ll]og[Ff]ile[Ss]ize RETURN(LogFileSize);
459
460 [Ll]og[Ff]ile[Nn]umber RETURN(LogFileNumber);
461
462 [Dd]isk[Ff]ull[Aa]ction RETURN(DiskFullAction);
463
464 [Mm]atching[Hh]ints RETURN(MatchingHints);
465
466 [Ll]ogger[Pp]lugins RETURN(LoggerPlugins);
467
468 LOG_NOTHING RETURN(LoggingBit);
469
470 (TTCN_)?ACTION |
471 (TTCN_)?DEBUG |
472 (TTCN_)?DEFAULTOP |
473 (TTCN_)?ERROR |
474 (TTCN_)?EXECUTOR |
475 (TTCN_)?FUNCTION |
476 (TTCN_)?MATCHING |
477 (TTCN_)?PARALLEL |
478 (TTCN_)?PORTEVENT |
479 (TTCN_)?STATISTICS |
480 (TTCN_)?TESTCASE |
481 (TTCN_)?TIMEROP |
482 (TTCN_)?USER |
483 (TTCN_)?VERDICTOP |
484 (TTCN_)?WARNING |
485 LOG_ALL RETURN(LoggingBitCollection);
486
487 ACTION_UNQUALIFIED |
488 DEBUG_ENCDEC |
489 DEBUG_TESTPORT |
490 DEBUG_UNQUALIFIED |
491 DEFAULTOP_ACTIVATE |
492 DEFAULTOP_DEACTIVATE |
493 DEFAULTOP_EXIT |
494 DEFAULTOP_UNQUALIFIED |
495 ERROR_UNQUALIFIED |
496 EXECUTOR_COMPONENT |
497 EXECUTOR_CONFIGDATA |
498 EXECUTOR_EXTCOMMAND |
499 EXECUTOR_LOGOPTIONS |
500 EXECUTOR_RUNTIME |
501 EXECUTOR_UNQUALIFIED |
502 FUNCTION_RND |
503 FUNCTION_UNQUALIFIED |
504 MATCHING_DONE |
505 MATCHING_MCSUCCESS |
506 MATCHING_MCUNSUCC |
507 MATCHING_MMSUCCESS |
508 MATCHING_MMUNSUCC |
509 MATCHING_PCSUCCESS |
510 MATCHING_PCUNSUCC |
511 MATCHING_PMSUCCESS |
512 MATCHING_PMUNSUCC |
513 MATCHING_PROBLEM |
514 MATCHING_TIMEOUT |
515 MATCHING_UNQUALIFIED |
516 PARALLEL_PORTCONN |
517 PARALLEL_PORTMAP |
518 PARALLEL_PTC |
519 PARALLEL_UNQUALIFIED |
520 PORTEVENT_DUALRECV |
521 PORTEVENT_DUALSEND |
522 PORTEVENT_MCRECV |
523 PORTEVENT_MCSEND |
524 PORTEVENT_MMRECV |
525 PORTEVENT_MMSEND |
526 PORTEVENT_MQUEUE |
527 PORTEVENT_PCIN |
528 PORTEVENT_PCOUT |
529 PORTEVENT_PMIN |
530 PORTEVENT_PMOUT |
531 PORTEVENT_PQUEUE |
532 PORTEVENT_STATE |
533 PORTEVENT_UNQUALIFIED |
534 STATISTICS_UNQUALIFIED |
535 STATISTICS_VERDICT |
536 TESTCASE_FINISH |
537 TESTCASE_START |
538 TESTCASE_UNQUALIFIED |
539 TIMEROP_GUARD |
540 TIMEROP_READ |
541 TIMEROP_START |
542 TIMEROP_STOP |
543 TIMEROP_TIMEOUT |
544 TIMEROP_UNQUALIFIED |
545 USER_UNQUALIFIED |
546 VERDICTOP_FINAL |
547 VERDICTOP_GETVERDICT |
548 VERDICTOP_SETVERDICT |
549 VERDICTOP_UNQUALIFIED |
550 WARNING_UNQUALIFIED RETURN(LoggingBit);
551
552 [Tt][Ii][Mm][Ee] {yylval.ts_val=TSF_TIME; RETURN(TimestampValue);}
553 [Dd][Aa][Tt][Ee][Tt][Ii][Mm][Ee] {yylval.ts_val=TSF_DATE_TIME; RETURN(TimestampValue);}
554 [Ss][Ee][Cc][Oo][Nn][Dd][Ss] {yylval.ts_val=TSF_SEC; RETURN(TimestampValue);}
555
556 [Nn][Oo][Nn][Ee] |
557 [Ss][Ii][Nn][Gg][Ll][Ee] |
558 [Ss][Tt][Aa][Cc][Kk] RETURN(SourceInfoValue);
559
560 [Yy][Ee][Ss] |
561 [Nn][Oo] RETURN(YesNo);
562
563 [Dd]etailed RETURN(Detailed);
564 [Cc]ompact RETURN(Compact);
565 [Ss]ub[Cc]ategories RETURN(SubCategories);
566
567 [Ee]rror RETURN(Error);
568
569 [Ss]top RETURN(Stop);
570
571 [Rr]etry RETURN(Re_try);
572
573 [Dd]elete RETURN(Delete);
574 }
575
576 <SC_PROFILER>
577 {
578 [Dd]isable[Pp]rofiler RETURN(DisableProfilerKeyword);
579 [Dd]isable[Cc]overage RETURN(DisableCoverageKeyword);
580 [Dd]ata[Bb]ase[Ff]ile RETURN(DatabaseFileKeyword);
581 [Aa]ggregate[Dd]ata RETURN(AggregateDataKeyword);
582 [Ss]tatistics[Ff]ile RETURN(StatisticsFileKeyword);
583 [Dd]isable[Ss]tatistics RETURN(DisableStatisticsKeyword);
584 [Ss]tatistics[Ff]ilter RETURN(StatisticsFilterKeyword);
585 [Ss]tart[Aa]utomatically RETURN(StartAutomaticallyKeyword);
586 [Nn]et[Ll]ine[Tt]imes RETURN(NetLineTimesKeyword);
587 [Nn]et[Ff]unction[Tt]imes RETURN(NetFunctionTimesKeyword);
588
589 /* statistics filters */
590 [Nn]umber[Oo]f[Ll]ines |
591 [Ll]ine[Dd]ata[Rr]aw |
592 [Ff]unc[Dd]ata[Rr]aw |
593 [Ll]ine[Aa]vg[Rr]aw |
594 [Ff]unc[Aa]vg[Rr]aw |
595 [Ll]ine[Tt]imes[Ss]orted[Bb]y[Mm]od |
596 [Ff]unc[Tt]imes[Ss]orted[Bb]y[Mm]od |
597 [Ll]ine[Tt]imes[Ss]orted[Tt]otal |
598 [Ff]unc[Tt]imes[Ss]orted[Tt]otal |
599 [Ll]ine[Cc]ount[Ss]orted[Bb]y[Mm]od |
600 [Ff]unc[Cc]ount[Ss]orted[Bb]y[Mm]od |
601 [Ll]ine[Cc]ount[Ss]orted[Tt]otal |
602 [Ff]unc[Cc]ount[Ss]orted[Tt]otal |
603 [Ll]ine[Aa]vg[Ss]orted[Bb]y[Mm]od |
604 [Ff]unc[Aa]vg[Ss]orted[Bb]y[Mm]od |
605 [Ll]ine[Aa]vg[Ss]orted[Tt]otal |
606 [Ff]unc[Aa]vg[Ss]orted[Tt]otal |
607 [Tt]op10[Ll]ine[Tt]imes |
608 [Tt]op10[Ff]unc[Tt]imes |
609 [Tt]op10[Ll]ine[Cc]ount |
610 [Tt]op10[Ff]unc[Cc]ount |
611 [Tt]op10[Ll]ine[Aa]vg |
612 [Tt]op10[Ff]unc[Aa]vg |
613 [Uu]nused[Ll]ines |
614 [Uu]nused[Ff]unc |
615 [Aa]ll[Rr]aw[Dd]ata |
616 [Ll]ine[Dd]ata[Ss]orted[Bb]y[Mm]od |
617 [Ff]unc[Dd]ata[Ss]orted[Bb]y[Mm]od |
618 [Ll]ine[Dd]ata[Ss]orted[Tt]otal |
619 [Ff]unc[Dd]ata[Ss]orted[Tt]otal |
620 [Ll]ine[Dd]ata[Ss]orted |
621 [Ff]unc[Dd]ata[Ss]orted |
622 [Aa]ll[Dd]ata[Ss]orted |
623 [Tt]op10[Ll]ine[Dd]ata |
624 [Tt]op10[Ff]unc[Dd]ata |
625 [Tt]op10[Aa]ll[Dd]ata |
626 [Uu]nused[Dd]ata |
627 [Aa]ll RETURN(ProfilerStatsFlag);
628 }
629
630 <SC_EXECUTE>control RETURN(ControlKeyword);
631
632 <SC_EXTERNAL_COMMANDS>
633 {
634 [Bb]egin[Cc]ontrol[Pp]art RETURN(BeginControlPart);
635 [Ee]nd[Cc]ontrol[Pp]art RETURN(EndControlPart);
636 [Bb]egin[Tt]est[Cc]ase RETURN(BeginTestCase);
637 [Ee]nd[Tt]est[Cc]ase RETURN(EndTestCase);
638 }
639
640 <SC_MAIN_CONTROLLER>
641 {
642 [Ll]ocal[Aa]ddress RETURN(LocalAddress);
643 [Tt][Cc][Pp][Pp]ort RETURN(TCPPort);
644 [Kk]ill[Tt]imer RETURN(KillTimer);
645 [Nn]um[Hh][Cc]s RETURN(NumHCs);
646 [Uu]nix[Ss]ockets[Ee]nabled RETURN(UnixSocketEnabled);
647 [Yy][Ee][Ss] RETURN(YesToken);
648 [Nn][Oo] RETURN(NoToken);
649 }
650
651 {TTCN3IDENTIFIER} {
652 switch (YY_START) {
653 case SC_GROUPS:
654 case SC_COMPONENTS:
655 case SC_EXECUTE:
656 case SC_MAIN_CONTROLLER:
657 yylval.str_val = (char*)Malloc(yyleng + 1);
658 memcpy(yylval.str_val, yytext, yyleng + 1);
659 break;
660 default:
661 yylval.str_val = NULL;
662 }
663 RETURN(Identifier);
664 }
665
666 <SC_MODULE_PARAMETERS>{ASN1LOWERIDENTIFIER} {
667 char *ttcn3_id = (char*)Malloc(yyleng + 1);
668 for (size_t i = 0; i < yyleng; i++) {
669 if (yytext[i] == '-') ttcn3_id[i] = '_';
670 else ttcn3_id[i] = yytext[i];
671 }
672 ttcn3_id[yyleng] = '\0';
673 config_read_warning("`%s' is not a valid TTCN-3 identifier. Did you mean "
674 "`%s'?", yytext, ttcn3_id);
675 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%s ", ttcn3_id);
676 Free(ttcn3_id);
677 return ASN1LowerIdentifier;
678 }
679
680 <SC_GROUPS,SC_COMPONENTS,SC_MAIN_CONTROLLER>{DNSNAME}|{IPV6} {
681 yylval.str_val = (char*)Malloc(yyleng + 1);
682 for (size_t i = 0; i < yyleng; i++) yylval.str_val[i] = tolower(yytext[i]);
683 yylval.str_val[yyleng] = '\0';
684 RETURN(DNSName);
685 }
686
687 {MACRO_BOOL} {
688 char *macroname = get_macro_id_from_ref(yytext);
689 size_t macrolen;
690 const char *macrovalue =
691 string_map_get_bykey(config_defines, macroname, &macrolen);
692 boolean bool_val;
693 if (macrovalue != NULL) {
694 if (!strcmp(macrovalue, "true")) bool_val = TRUE;
695 else if (!strcmp(macrovalue, "false")) bool_val = FALSE;
696 else {
697 config_read_error("Macro `%s' cannot be interpreted as boolean value: "
698 "`%s'", macroname, macrovalue);
699 bool_val = FALSE;
700 }
701 } else {
702 config_read_error("No macro or environmental variable defined with name "
703 "`%s'", macroname);
704 bool_val = FALSE;
705 }
706 Free(macroname);
707 if (whether_update_buffer()) cfg->config_read_buffer =
708 mputprintf(cfg->config_read_buffer, "%s ", bool_val ? "true" : "false");
709 return BooleanValue;
710 }
711
712 {MACRO_INT} {
713 char *macroname = get_macro_id_from_ref(yytext);
714 size_t macrolen = 0;
715 BIGNUM *BN_0 = BN_new();
716 BN_set_word(BN_0, 0);
717 const char *macrovalue =
718 string_map_get_bykey(config_defines, macroname, &macrolen);
719 if (macrovalue != NULL) {
720 if (string_is_int(macrovalue, macrolen)) {
721 yylval.int_val = NULL;
722 BN_dec2bn(&yylval.int_val,
723 *macrovalue == '+' ? macrovalue + 1 : macrovalue);
724 } else {
725 config_read_error("Macro `%s' cannot be interpreted as integer value: "
726 "`%s'", macroname, macrovalue);
727 yylval.int_val = BN_dup(BN_0);
728 }
729 } else {
730 config_read_error("No macro or environmental variable defined with name "
731 "`%s'", macroname);
732 yylval.int_val = BN_dup(BN_0);
733 }
734 BN_free(BN_0);
735 Free(macroname);
736 char *int_val_str = BN_bn2dec(yylval.int_val);
737 if (whether_update_buffer())
738 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%s ", int_val_str);
739 OPENSSL_free(int_val_str);
740 if (YY_START == SC_MODULE_PARAMETERS) {
741 return MPNumber;
742 }
743 return Number;
744 }
745
746 {MACRO_FLOAT} {
747 char *macroname = get_macro_id_from_ref(yytext);
748 size_t macrolen;
749 const char *macrovalue =
750 string_map_get_bykey(config_defines, macroname, &macrolen);
751 if (macrovalue != NULL) {
752 if (string_is_float(macrovalue, macrolen))
753 yylval.float_val = atof(macrovalue);
754 else {
755 config_read_error("Macro `%s' cannot be interpreted as float value: "
756 "`%s'", macroname, macrovalue);
757 yylval.float_val = 0.0;
758 }
759 } else {
760 config_read_error("No macro or environmental variable defined"
761 " with name `%s'", macroname);
762 yylval.float_val = 0.0;
763 }
764 Free(macroname);
765 if (whether_update_buffer()) cfg->config_read_buffer =
766 mputprintf(cfg->config_read_buffer, "%f ", yylval.float_val);
767 if (YY_START == SC_MODULE_PARAMETERS) {
768 return MPFloat;
769 }
770 return Float;
771 }
772
773 {MACRO_ID} {
774 char *macroname = get_macro_id_from_ref(yytext);
775 size_t macrolen;
776 const char *macrovalue =
777 string_map_get_bykey(config_defines, macroname, &macrolen);
778 boolean is_asn = FALSE;
779 if (macrovalue != NULL) {
780 if (string_is_id(macrovalue, macrolen)) {
781 yylval.str_val = mcopystr(macrovalue);
782 for (size_t i = 0; i < macrolen; i++) {
783 if (yylval.str_val[i] == '-') {
784 is_asn = TRUE;
785 yylval.str_val[i] = '_';
786 }
787 }
788 if (is_asn) config_read_warning("`%s' is not a valid TTCN-3 identifier. "
789 "Did you mean `%s'?", macrovalue, yylval.str_val);
790 if (whether_update_buffer()) cfg->config_read_buffer =
791 mputprintf(cfg->config_read_buffer, "%s ", yylval.str_val);
792 } else {
793 config_read_error("Macro `%s' cannot be interpreted as identifier: `%s'",
794 macroname, macrovalue);
795 yylval.str_val = NULL;
796 }
797 } else {
798 config_read_error("No macro or environmental variable defined with name "
799 "`%s'", macroname);
800 yylval.str_val = NULL;
801 }
802 Free(macroname);
803 return Identifier;
804 }
805
806 {MACRO_CSTR} {
807 char *macroname;
808 if (yytext[1] == '{') macroname = get_macro_id_from_ref(yytext);
809 else macroname = mcopystr(yytext + 1);
810 size_t macrolen;
811 const char *macrovalue = string_map_get_bykey
812 (config_defines, macroname, &macrolen);
813 if (macrovalue == NULL) {
814 config_read_error("No macro or environmental variable defined with "
815 "name `%s'", macroname);
816 yylval.str_val = memptystr();
817 Free(macroname);
818 if (YY_START == SC_MODULE_PARAMETERS) {
819 return MPCstring;
820 }
821 return Cstring;
822 }
823
824 if (macrolen > 0 && macrovalue[0] == '{') { // structured
825 main_buffer = YY_CURRENT_BUFFER;
826 expansion_buffer = yy_scan_string(macrovalue);
827 yy_switch_to_buffer(expansion_buffer);
828 Free(macroname);
829 } else {
830 if (whether_update_buffer()) {
831 cfg->config_read_buffer=mputc(cfg->config_read_buffer, '"');
832 for (size_t i = 0; i < macrolen; i++) {
833 switch (macrovalue[i]) {
834 case '"':
835 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\\"");
836 break;
837 case '\\':
838 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\\\");
839 break;
840 case '\0':
841 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\000");
842 break;
843 default:
844 cfg->config_read_buffer = mputc(cfg->config_read_buffer, macrovalue[i]);
845 } /* switch */
846 } /* for */
847 cfg->config_read_buffer=mputstr(cfg->config_read_buffer, "\" ");
848 }
849 Free(macroname);
850 yylval.str_val = mcopystr(macrovalue);
851 if (YY_START == SC_MODULE_PARAMETERS) {
852 return MPCstring;
853 }
854 return Cstring;
855 }
856 }
857
858 {MACRO_BSTR} {
859 char *macroname = get_macro_id_from_ref(yytext);
860 size_t macrolen;
861 const char *macrovalue =
862 string_map_get_bykey(config_defines, macroname, &macrolen);
863 if (macrovalue != NULL) {
864 if (string_is_bstr(macrovalue, macrolen)) {
865 if (whether_update_buffer()) cfg->config_read_buffer =
866 mputprintf(cfg->config_read_buffer, "'%s'B ", macrovalue);
867 } else config_read_error("Macro `%s' cannot be interpreted as bitstring "
868 "value: `%s'", macroname, macrovalue);
869 } else config_read_error("No macro or environmental variable defined with "
870 "name `%s'", macroname);
871 Free(macroname);
872 return Bstring;
873 }
874
875 {MACRO_HSTR} {
876 char *macroname = get_macro_id_from_ref(yytext);
877 size_t macrolen;
878 const char *macrovalue =
879 string_map_get_bykey(config_defines, macroname, &macrolen);
880 if (macrovalue != NULL) {
881 if (string_is_hstr(macrovalue, macrolen)) {
882 if (whether_update_buffer()) cfg->config_read_buffer =
883 mputprintf(cfg->config_read_buffer, "'%s'H ", macrovalue);
884 } else config_read_error("Macro `%s' cannot be interpreted as hexstring "
885 "value: `%s'", macroname, macrovalue);
886 } else config_read_error("No macro or environmental variable defined with "
887 "name `%s'", macroname);
888 Free(macroname);
889 return Hstring;
890 }
891
892 {MACRO_OSTR} {
893 char *macroname = get_macro_id_from_ref(yytext);
894 size_t macrolen;
895 const char *macrovalue =
896 string_map_get_bykey(config_defines, macroname, &macrolen);
897 if (macrovalue != NULL) {
898 if (string_is_ostr(macrovalue, macrolen)) {
899 if (whether_update_buffer()) cfg->config_read_buffer =
900 mputprintf(cfg->config_read_buffer, "'%s'O ", macrovalue);
901 } else config_read_error("Macro `%s' cannot be interpreted as octetstring "
902 "value: `%s'", macroname, macrovalue);
903 } else config_read_error("No macro or environmental variable defined with "
904 "name `%s'", macroname);
905 Free(macroname);
906 return Ostring;
907 }
908
909 {MACRO_BINARY} {
910 char *macroname = get_macro_id_from_ref(yytext);
911 size_t macrolen;
912 const char *macrovalue =
913 string_map_get_bykey(config_defines, macroname, &macrolen);
914 if (macrovalue != NULL) {
915 if (whether_update_buffer()) {
916 cfg->config_read_buffer = mputc(cfg->config_read_buffer, '\'');
917 for (size_t i = 0; i < macrolen; i++) {
918 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%02X",
919 macrovalue[i]);
920 }
921 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "'O ");
922 }
923 } else config_read_error("No macro or environmental variable defined with "
924 "name `%s'", macroname);
925 Free(macroname);
926 return Ostring;
927 }
928
929 {MACRO_HOSTNAME} {
930 char *macroname = get_macro_id_from_ref(yytext);
931 size_t macrolen;
932 const char *macrovalue =
933 string_map_get_bykey(config_defines, macroname, &macrolen);
934 if (macrovalue != NULL) {
935 if (string_is_hostname(macrovalue, macrolen)) {
936 if (whether_update_buffer()) {
937 for (size_t i = 0; i < macrolen; i++) {
938 cfg->config_read_buffer =
939 mputc(cfg->config_read_buffer, tolower(macrovalue[i]));
940 }
941 yylval.str_val = NULL;
942 } else {
943 yylval.str_val = (char*)Malloc(macrolen + 1);
944 for (size_t i = 0; i < macrolen; i++)
945 yylval.str_val[i] = tolower(macrovalue[i]);
946 yylval.str_val[macrolen] = '\0';
947 }
948 } else {
949 config_read_error("Macro `%s' cannot be interpreted as host name: "
950 "`%s'", macroname, macrovalue);
951 yylval.str_val = NULL;
952 }
953 } else {
954 config_read_error("No macro or environmental variable defined with "
955 "name `%s'", macroname);
956 yylval.str_val = NULL;
957 }
958 Free(macroname);
959 return DNSName;
960 }
961
962 ":="|"=" RETURN(AssignmentChar);
963 "&=" RETURN(ConcatChar);
964
965 . RETURN(yytext[0]);
966
967 <*><<EOF>> {
968 if (expansion_buffer) {
969 yy_switch_to_buffer(main_buffer);
970 yy_delete_buffer(expansion_buffer);
971 expansion_buffer = NULL;
972 } else {
973 if (YY_START == SC_blockcomment) {
974 config_read_error("Unterminated block "
975 "comment (missing */ at the end of file).");
976 return EOF;
977 } else {
978 if (include_chain->size() > 1) {
979 yy_delete_buffer(YY_CURRENT_BUFFER);
980 fclose(include_chain->back().fp);
981 include_chain->pop_back();
982 yy_switch_to_buffer(include_chain->back().buffer_state);
983 yylineno = include_chain->back().line_number;
984 BEGIN(SC_ORDERED_INCLUDE);
985 } else {
986 return EOF;
987 }
988 }
989 }
990 }
991
992 %%
993
994 static void update_buffer()
995 {
996 if (whether_update_buffer()) {
997 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, yytext);
998 cfg->config_read_buffer = mputc (cfg->config_read_buffer, ' ');
999 }
1000 }
1001
1002 static boolean whether_update_buffer()
1003 {
1004 switch (YY_START) {
1005 case SC_MODULE_PARAMETERS:
1006 case SC_LOGGING:
1007 case SC_TESTPORT_PARAMETERS:
1008 case SC_EXTERNAL_COMMANDS:
1009 case SC_PROFILER:
1010 return TRUE;
1011 default:
1012 return FALSE;
1013 } /* switch */
1014 }
1015
1016 void config_read_reset(const char* current_filename_) {
1017 if (!include_chain) {
1018 include_chain = new std::deque<IncludeElem<YY_BUFFER_STATE> >();
1019 }
1020
1021 include_chain->clear();
1022 include_chain->push_back(
1023 IncludeElem<YY_BUFFER_STATE>(std::string(current_filename_), config_read_in));
1024 }
1025
1026 void config_read_close() {
1027 delete include_chain;
1028 include_chain = NULL;
1029 }
1030
This page took 0.059601 seconds and 5 git commands to generate.