conformance_test/positive_tests added
[deliverable/titan.core.git] / core / config_process.y
1 /******************************************************************************
2 * Copyright (c) 2000-2016 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 * Contributors:
9 *
10 * Baji, Laszlo
11 * Balasko, Jeno
12 * Baranyi, Botond
13 * Beres, Szabolcs
14 * Delic, Adam
15 * Forstner, Matyas
16 * Kovacs, Ferenc
17 * Pandi, Krisztian
18 * Raduly, Csaba
19 * Szabados, Kristof
20 * Szabo, Janos Zoltan – initial implementation
21 * Szalai, Gabor
22 * Zalanyi, Balazs Andor
23 *
24 ******************************************************************************/
25 %{
26
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <stdarg.h>
31 #include <ctype.h>
32 #include <errno.h>
33
34 #include <openssl/bn.h>
35
36 #include "../common/config_preproc.h"
37
38 #include "Param_Types.hh"
39 #include "Integer.hh"
40 #include "Float.hh"
41 #include "Boolean.hh"
42 #include "Objid.hh"
43 #include "Verdicttype.hh"
44 #include "Bitstring.hh"
45 #include "Hexstring.hh"
46 #include "Octetstring.hh"
47 #include "Charstring.hh"
48 #include "Universal_charstring.hh"
49
50 #include "Module_list.hh"
51 #include "Port.hh"
52 #include "Runtime.hh"
53
54 #include "LoggingBits.hh"
55 #include "LoggingParam.hh"
56
57 #include "Profiler.hh"
58
59 #define YYERROR_VERBOSE
60
61 #include "config_process.lex.hh"
62
63 extern void reset_config_process_lex(const char* fname);
64 extern void config_process_close();
65 extern int config_process_get_current_line();
66 extern std::string get_cfg_process_current_file();
67
68 static int config_process_parse();
69 static void check_duplicate_option(const char *section_name,
70 const char *option_name, boolean& option_flag);
71 static void check_ignored_section(const char *section_name);
72 static void set_param(Module_Param& module_param);
73 static unsigned char char_to_hexdigit(char c);
74
75 static boolean error_flag = FALSE;
76
77 static Module_Param* parsed_module_param = NULL;
78 static char * parsing_error_messages = NULL;
79
80 /*
81 For detecting duplicate entries in the config file. Start out as FALSE,
82 set to TRUE bycheck_duplicate_option().
83 Exception: duplication of parameters that can be component specific is checked
84 by set_xxx(), these start out as TRUE.
85 */
86 static boolean file_name_set = FALSE,
87 file_mask_set = TRUE,
88 console_mask_set = TRUE,
89 timestamp_format_set = FALSE,
90 source_info_format_set = FALSE,
91 append_file_set = FALSE,
92 log_event_types_set = FALSE,
93 log_entity_name_set = FALSE,
94 begin_controlpart_command_set = FALSE,
95 end_controlpart_command_set = FALSE,
96 begin_testcase_command_set = FALSE,
97 end_testcase_command_set = FALSE,
98 log_file_size_set = TRUE,
99 log_file_number_set = TRUE,
100 log_disk_full_action_set = TRUE,
101 matching_verbosity_set = FALSE,
102 logger_plugins_set = FALSE,
103 plugin_specific_set = FALSE;
104
105 int execute_list_len = 0;
106 execute_list_item *execute_list = NULL;
107
108 string_map_t *config_defines;
109
110 %}
111
112 %union{
113 char *str_val;
114 int_val_t *int_val;
115 int int_native;
116 unsigned int uint_val;
117 double float_val;
118 boolean bool_val;
119 param_objid_t objid_val;
120 verdicttype verdict_val;
121 param_bitstring_t bitstring_val;
122 param_hexstring_t hexstring_val;
123 param_charstring_t charstring_val;
124 param_octetstring_t octetstring_val;
125 universal_char universal_char_val;
126 param_universal_charstring_t universal_charstring_val;
127 Module_Param::operation_type_t param_optype_val;
128 Vector<Module_Param*>* module_param_list;
129 Module_Param* module_param_val;
130 Module_Param_Length_Restriction* module_param_length_restriction;
131 Vector<char*>* name_vector;
132 component_id_t comp_id;
133 execute_list_item execute_item_val;
134 TTCN_Logger::emergency_logging_behaviour_t emergency_logging_behaviour_value;
135 TTCN_Logger::timestamp_format_t timestamp_value;
136 TTCN_Logger::source_info_format_t source_info_value;
137 TTCN_Logger::log_event_types_t log_event_types_value;
138 TTCN_Logger::disk_full_action_t disk_full_action_value;
139 TTCN_Logger::matching_verbosity_t matching_verbosity_value;
140 TTCN_Logger::Severity logseverity_val;
141 Logging_Bits logoptions_val;
142
143 logging_plugin_t *logging_plugins;
144 logging_param_t logging_params;
145 logging_setting_t logging_param_line;
146 }
147
148 %token ModuleParametersKeyword
149 %token LoggingKeyword
150 %token ProfilerKeyword
151 %token TestportParametersKeyword
152 %token ExecuteKeyword
153 %token ExternalCommandsKeyword
154 %token GroupsKeyword
155 %token ComponentsKeyword
156 %token MainControllerKeyword
157 %token IncludeKeyword
158 %token DefineKeyword
159
160 %token Detailed
161 %token Compact
162 %token ObjIdKeyword "objid"
163 %token CharKeyword "char"
164 %token ControlKeyword "control"
165 %token MTCKeyword "mtc"
166 %token SystemKeyword "system"
167 %token NULLKeyword "NULL"
168 %token nullKeyword "null"
169 %token OmitKeyword "omit"
170 %token ComplementKeyword "complement"
171 %token DotDot ".."
172 %token SupersetKeyword "superset"
173 %token SubsetKeyword "subset"
174 %token PatternKeyword "pattern"
175 %token PermutationKeyword "permutation"
176 %token LengthKeyword "length"
177 %token IfpresentKeyword "ifpresent"
178 %token InfinityKeyword "infinity"
179 %token AssignmentChar ":= or ="
180 %token ConcatChar "&="
181 %token LogFile "LogFile or FileName"
182 %token EmergencyLogging
183 %token EmergencyLoggingBehaviour
184 %token EmergencyLoggingMask
185 %token EmergencyLoggingForFailVerdict
186 %token BufferAll
187 %token BufferMasked
188 %token FileMask
189 %token ConsoleMask
190 %token TimestampFormat
191 %token ConsoleTimestampFormat
192 %token SourceInfoFormat "LogSourceInfo or SourceInfoFormat"
193 %token AppendFile
194 %token LogEventTypes
195 %token LogEntityName
196 %token BeginControlPart
197 %token EndControlPart
198 %token BeginTestCase
199 %token EndTestCase
200 %token <str_val> Identifier
201 %token <str_val> ASN1LowerIdentifier "ASN.1 identifier beginning with a lowercase letter"
202 %token <int_val> Number MPNumber "integer value"
203 %token <float_val> Float MPFloat "float value"
204 %token <bool_val> BooleanValue "true or false"
205 %token <verdict_val> VerdictValue
206 %token <bitstring_val> Bstring "bit string value"
207 %token <hexstring_val> Hstring "hex string value"
208 %token <octetstring_val> Ostring "octet string value"
209 %token <str_val> BstringMatch "bit string template"
210 %token <str_val> HstringMatch "hex string template"
211 %token <str_val> OstringMatch "octet string template"
212 %token <charstring_val> Cstring MPCstring "charstring value"
213 %token DNSName "hostname"
214 /* a single bit */
215 %token <logseverity_val> LoggingBit
216 /* a collection of bits */
217 %token <logseverity_val> LoggingBitCollection
218 %token SubCategories
219 %token <emergency_logging_behaviour_value> EmergencyLoggingBehaviourValue "BufferAll or BufferMasked"
220 %token <timestamp_value> TimestampValue "Time, Datetime or Seconds"
221 %token <source_info_value> SourceInfoValue "None, Single or Stack"
222 %token <bool_val> YesNo "yes or no"
223 %token LocalAddress
224 %token TCPPort
225 %token KillTimer
226 %token NumHCs
227 %token UnixSocketEnabled
228 %token YesToken "yes"
229 %token NoToken "no"
230 %token LogFileSize
231 %token LogFileNumber
232 %token DiskFullAction
233 %token MatchingHints
234 %token LoggerPlugins
235 %token Error
236 %token Stop
237 %token Retry
238 %token Delete
239 %token TtcnStringParsingKeyword
240 %token DisableProfilerKeyword "DisableProfiler"
241 %token DisableCoverageKeyword "DisableCoverage"
242 %token DatabaseFileKeyword "DatabaseFile"
243 %token AggregateDataKeyword "AggregateData"
244 %token StatisticsFileKeyword "StatisticsFile"
245 %token DisableStatisticsKeyword "DisableStatistics"
246 %token StatisticsFilterKeyword "StatisticsFilter"
247 %token StartAutomaticallyKeyword "StartAutomatically"
248 %token NetLineTimesKeyword "NetLineTimes"
249 %token NetFunctionTimesKeyword "NetFunctionTimes"
250 %token <uint_val> ProfilerStatsFlag "profiler statistics filter"
251
252 %type <int_val> IntegerValue
253 %type <float_val> FloatValue
254 %type <objid_val> ObjIdValue ObjIdComponentList
255 %type <int_val> ObjIdComponent NumberForm NameAndNumberForm
256
257 %type <universal_charstring_val> UniversalCharstringValue UniversalCharstringFragment
258 %type <universal_char_val> Quadruple
259
260 %type <str_val> LoggerPluginId
261 %type <logging_plugins> LoggerPlugin LoggerPluginList
262 %type <logging_params> LoggingParam
263 %type <logging_param_line> LoggingParamLines
264 %type <str_val> LogFileName StringValue
265 /* a collection of bits */
266 %type <logoptions_val> LoggingBitmask
267 %type <logoptions_val> LoggingBitOrCollection
268 %type <source_info_value> SourceInfoSetting
269 %type <bool_val> YesNoOrBoolean
270 %type <log_event_types_value> LogEventTypesValue
271 %type <disk_full_action_value> DiskFullActionValue
272 %type <str_val> Command
273 %type <matching_verbosity_value> VerbosityValue
274 %type <comp_id> ComponentId
275 %type <str_val> TestportName ArrayRef TestportParameterName
276 TestportParameterValue
277
278 %type <execute_item_val> ExecuteItem
279
280 %type <bitstring_val> BitstringValue
281 %type <hexstring_val> HexstringValue
282 %type <octetstring_val> OctetstringValue
283
284 %type <name_vector> ParameterName ParameterNameSegment
285 %type <param_optype_val> ParamOpType
286 %type <str_val> FieldName
287 %type <module_param_val> ParameterValue SimpleParameterValue ParameterValueOrNotUsedSymbol
288 FieldValue ArrayItem IndexItem IndexItemList FieldValueList ArrayItemList CompoundValue IntegerRange FloatRange StringRange
289 ParameterExpression ParameterReference
290 %type <module_param_list> TemplateItemList
291 %type <module_param_length_restriction> LengthMatch
292 %type <str_val> PatternChunk
293 %type <int_native> IndexItemIndex LengthBound
294 %type <uint_val> ProfilerStatsFlags
295
296 %destructor { Free($$); }
297 ArrayRef
298 ASN1LowerIdentifier
299 Command
300 FieldName
301 Identifier
302 LogFileName
303 StringValue
304 TestportName
305 TestportParameterName
306 TestportParameterValue
307 PatternChunk
308 BstringMatch
309 HstringMatch
310 OstringMatch
311
312 %destructor { Free($$.components_ptr); }
313 ObjIdComponentList
314 ObjIdValue
315
316 %destructor { Free($$.bits_ptr); }
317 Bstring
318 BitstringValue
319
320 %destructor { Free($$.nibbles_ptr); }
321 Hstring
322 HexstringValue
323
324 %destructor { Free($$.octets_ptr); }
325 Ostring
326 OctetstringValue
327
328 %destructor { Free($$.chars_ptr); }
329 Cstring
330 MPCstring
331
332 %destructor { Free($$.uchars_ptr); }
333 UniversalCharstringFragment
334 UniversalCharstringValue
335
336 %destructor { if ($$.id_selector == COMPONENT_ID_NAME) Free($$.id_name); }
337 ComponentId
338
339 %destructor { Free($$.module_name); Free($$.testcase_name); }
340 ExecuteItem
341
342 %destructor { delete $$; }
343 IntegerValue
344 NameAndNumberForm
345 Number
346 MPNumber
347 NumberForm
348 ObjIdComponent
349 ParameterValue
350 SimpleParameterValue
351 ParameterValueOrNotUsedSymbol
352 ArrayItemList
353 FieldValueList
354 IndexItemList
355 CompoundValue
356 ArrayItem
357 FieldValue
358 IndexItem
359 IntegerRange
360 FloatRange
361 StringRange
362 ParameterExpression
363 ParameterReference
364
365 %destructor { delete $$; }
366 LengthMatch
367
368 %destructor { for(size_t i=0; i<$$->size(); i++) { delete $$->at(i); } delete $$; }
369 TemplateItemList
370
371 %destructor { for(size_t i=0; i<$$->size(); i++) { Free($$->at(i)); } delete $$; }
372 ParameterName
373 ParameterNameSegment
374
375 %left '&' /* to avoid shift/reduce conflicts */
376 %left '+' '-'
377 %left '*' '/'
378 %left UnarySign
379
380 %expect 1
381
382 /*
383 1 conflict:
384 When seeing a '*' token after a module parameter expression the parser cannot
385 decide whether the token is a multiplication operator (shift) or it refers to
386 all modules in the next module parameter (reduce).
387 */
388 %%
389
390 GrammarRoot:
391 ConfigFile
392 {
393 if (Ttcn_String_Parsing::happening()) {
394 config_process_error("Config file cannot be parsed as ttcn string");
395 }
396 }
397 | TtcnStringParsingKeyword ParameterValue
398 {
399 parsed_module_param = $2;
400 }
401 ;
402
403 ConfigFile:
404 /* empty */
405 | ConfigFile Section
406 ;
407
408 Section:
409 ModuleParametersSection
410 | LoggingSection
411 | ProfilerSection
412 | TestportParametersSection
413 | ExecuteSection
414 | ExternalCommandsSection
415 | GroupsSection
416 | ComponentsSection
417 | MainControllerSection
418 | IncludeSection
419 | DefineSection
420 ;
421
422 ModuleParametersSection:
423 ModuleParametersKeyword ModuleParameters
424 ;
425
426 ModuleParameters:
427 /* empty */
428 | ModuleParameters ModuleParameter optSemiColon
429 ;
430
431 ModuleParameter:
432 ParameterName ParamOpType ParameterValue
433 {
434 Module_Param* mp = $3;
435 mp->set_id(new Module_Param_Name(*$1));
436 mp->set_operation_type($2);
437 set_param(*mp);
438 delete mp;
439 delete $1;
440 }
441 ;
442
443 ParameterName:
444 ParameterNameSegment { $$ = $1; }
445 | '*' '.' ParameterNameSegment { $$ = $3; }
446 ;
447
448 ParameterNameSegment:
449 ParameterNameSegment '.' Identifier
450 {
451 $$ = $1;
452 $$->push_back($3);
453 }
454 | ParameterNameSegment IndexItemIndex
455 {
456 $$ = $1;
457 $$->push_back(mprintf("%d", $2));
458 }
459 | Identifier
460 {
461 $$ = new Vector<char*>();
462 $$->push_back($1);
463 }
464 ;
465
466 ParameterValue:
467 ParameterExpression
468 {
469 $$ = $1;
470 }
471 | ParameterExpression LengthMatch
472 {
473 $$ = $1;
474 $$->set_length_restriction($2);
475 }
476 | ParameterExpression IfpresentKeyword
477 {
478 $$ = $1;
479 $$->set_ifpresent();
480 }
481 | ParameterExpression LengthMatch IfpresentKeyword
482 {
483 $$ = $1;
484 $$->set_length_restriction($2);
485 $$->set_ifpresent();
486 }
487 ;
488
489 LengthMatch:
490 LengthKeyword '(' LengthBound ')'
491 {
492 $$ = new Module_Param_Length_Restriction();
493 $$->set_single((size_t)$3);
494 }
495 | LengthKeyword '(' LengthBound DotDot LengthBound ')'
496 {
497 if ($3>$5) {
498 config_process_error("invalid length restriction: lower bound > upper bound");
499 }
500 $$ = new Module_Param_Length_Restriction();
501 $$->set_min((size_t)$3);
502 $$->set_max((size_t)$5);
503 }
504 | LengthKeyword '(' LengthBound DotDot InfinityKeyword ')'
505 {
506 $$ = new Module_Param_Length_Restriction();
507 $$->set_min((size_t)$3);
508 }
509 ;
510
511 LengthBound:
512 ParameterExpression
513 {
514 $1->set_id(new Module_Param_CustomName(mcopystr("length bound")));
515 INTEGER tmp;
516 tmp.set_param(*$1);
517 if (!tmp.get_val().is_native()) {
518 config_process_error("bignum length restriction bound.");
519 $$ = 0;
520 } else if (tmp.get_val().is_negative()) {
521 config_process_error("negative length restriction bound.");
522 $$ = 0;
523 } else {
524 $$ = tmp;
525 }
526 delete $1;
527 }
528 ;
529
530 // one global rule for expressions in module parameters
531 // the expression's result will be calculated by set_param()
532 ParameterExpression:
533 SimpleParameterValue { $$ = $1; }
534 | ParameterReference { $$ = $1; }
535 | '(' ParameterExpression ')' { $$ = $2; }
536 | '+' ParameterExpression %prec UnarySign { $$ = $2; }
537 | '-' ParameterExpression %prec UnarySign { $$ = new Module_Param_Expression($2); }
538 | ParameterExpression '+' ParameterExpression
539 {
540 $$ = new Module_Param_Expression(Module_Param::EXPR_ADD, $1, $3);
541 }
542 | ParameterExpression '-' ParameterExpression
543 {
544 $$ = new Module_Param_Expression(Module_Param::EXPR_SUBTRACT, $1, $3);
545 }
546 | ParameterExpression '*' ParameterExpression
547 {
548 $$ = new Module_Param_Expression(Module_Param::EXPR_MULTIPLY, $1, $3);
549 }
550 | ParameterExpression '/' ParameterExpression
551 {
552 $$ = new Module_Param_Expression(Module_Param::EXPR_DIVIDE, $1, $3);
553 }
554 | ParameterExpression '&' ParameterExpression
555 {
556 $$ = new Module_Param_Expression(Module_Param::EXPR_CONCATENATE, $1, $3);
557 }
558 ;
559
560 ParameterReference:
561 // enumerated values are also treated as references by the parser,
562 // these will be sorted out later during set_param()
563 ParameterNameSegment
564 {
565 $$ = new Module_Param_Reference(new Module_Param_Name(*$1));
566 }
567 ;
568
569 SimpleParameterValue:
570 MPNumber
571 {
572 $$ = new Module_Param_Integer($1);
573 }
574 | MPFloat
575 {
576 $$ = new Module_Param_Float($1);
577 }
578 | BooleanValue
579 {
580 $$ = new Module_Param_Boolean($1);
581 }
582 | ObjIdValue
583 {
584 $$ = new Module_Param_Objid($1.n_components, $1.components_ptr);
585 }
586 | VerdictValue
587 {
588 $$ = new Module_Param_Verdict($1);
589 }
590 | BitstringValue
591 {
592 $$ = new Module_Param_Bitstring($1.n_bits, $1.bits_ptr);
593 }
594 | HexstringValue
595 {
596 $$ = new Module_Param_Hexstring($1.n_nibbles, $1.nibbles_ptr);
597 }
598 | OctetstringValue
599 {
600 $$ = new Module_Param_Octetstring($1.n_octets, $1.octets_ptr);
601 }
602 | MPCstring
603 {
604 $$ = new Module_Param_Charstring($1.n_chars, $1.chars_ptr);
605 }
606 | UniversalCharstringValue
607 {
608 $$ = new Module_Param_Universal_Charstring($1.n_uchars, $1.uchars_ptr);
609 }
610 | OmitKeyword
611 {
612 $$ = new Module_Param_Omit();
613 }
614 | NULLKeyword
615 {
616 $$ = new Module_Param_Asn_Null();
617 }
618 | nullKeyword
619 {
620 $$ = new Module_Param_Ttcn_Null();
621 }
622 | MTCKeyword
623 {
624 $$ = new Module_Param_Ttcn_mtc();
625 }
626 | SystemKeyword
627 {
628 $$ = new Module_Param_Ttcn_system();
629 }
630 | '?'
631 {
632 $$ = new Module_Param_Any();
633 }
634 | '*'
635 {
636 $$ = new Module_Param_AnyOrNone();
637 }
638 | IntegerRange
639 {
640 $$ = $1;
641 }
642 | FloatRange
643 {
644 $$ = $1;
645 }
646 | StringRange
647 {
648 $$ = $1;
649 }
650 | PatternKeyword PatternChunk
651 {
652 $$ = new Module_Param_Pattern($2);
653 }
654 | BstringMatch
655 {
656 // conversion
657 int n_chars = (int)mstrlen($1);
658 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
659 for (int i=0; i<n_chars; i++) {
660 switch ($1[i]) {
661 case '0':
662 chars_ptr[i] = 0;
663 break;
664 case '1':
665 chars_ptr[i] = 1;
666 break;
667 case '?':
668 chars_ptr[i] = 2;
669 break;
670 case '*':
671 chars_ptr[i] = 3;
672 break;
673 default:
674 chars_ptr[i] = 0;
675 config_process_error_f("Invalid char (%c) in bitstring template", $1[i]);
676 }
677 }
678 Free($1);
679 $$ = new Module_Param_Bitstring_Template(n_chars, chars_ptr);
680 }
681 | HstringMatch
682 {
683 int n_chars = (int)mstrlen($1);
684 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
685 for (int i=0; i<n_chars; i++) {
686 if ($1[i]=='?') chars_ptr[i] = 16;
687 else if ($1[i]=='*') chars_ptr[i] = 17;
688 else chars_ptr[i] = char_to_hexdigit($1[i]);
689 }
690 Free($1);
691 $$ = new Module_Param_Hexstring_Template(n_chars, chars_ptr);
692 }
693 | OstringMatch
694 {
695 Vector<unsigned short> octet_vec;
696 int str_len = (int)mstrlen($1);
697 for (int i=0; i<str_len; i++) {
698 unsigned short num;
699 if ($1[i]=='?') num = 256;
700 else if ($1[i]=='*') num = 257;
701 else {
702 // first digit
703 num = 16 * char_to_hexdigit($1[i]);
704 i++;
705 if (i>=str_len) config_process_error("Unexpected end of octetstring pattern");
706 // second digit
707 num += char_to_hexdigit($1[i]);
708 }
709 octet_vec.push_back(num);
710 }
711 Free($1);
712 int n_chars = (int)octet_vec.size();
713 unsigned short* chars_ptr = (unsigned short*)Malloc(n_chars*sizeof(unsigned short));
714 for (int i=0; i<n_chars; i++) chars_ptr[i] = octet_vec[i];
715 $$ = new Module_Param_Octetstring_Template(n_chars, chars_ptr);
716 }
717 | CompoundValue
718 {
719 $$ = $1;
720 }
721 ;
722
723 PatternChunk:
724 MPCstring
725 {
726 $$ = mcopystr($1.chars_ptr);
727 Free($1.chars_ptr);
728 }
729 | Quadruple
730 {
731 $$ = mprintf("\\q{%d,%d,%d,%d}", $1.uc_group, $1.uc_plane, $1.uc_row, $1.uc_cell);
732 }
733 ;
734
735 IntegerRange:
736 '(' '-' InfinityKeyword DotDot MPNumber ')'
737 {
738 $$ = new Module_Param_IntRange(NULL, $5);
739 }
740 | '(' MPNumber DotDot MPNumber ')'
741 {
742 $$ = new Module_Param_IntRange($2, $4);
743 }
744 | '(' MPNumber DotDot InfinityKeyword ')'
745 {
746 $$ = new Module_Param_IntRange($2, NULL);
747 }
748 ;
749
750 FloatRange:
751 '(' '-' InfinityKeyword DotDot MPFloat ')'
752 {
753 $$ = new Module_Param_FloatRange(0.0, false, $5, true);
754 }
755 | '(' MPFloat DotDot MPFloat ')'
756 {
757 $$ = new Module_Param_FloatRange($2, true, $4, true);
758 }
759 | '(' MPFloat DotDot InfinityKeyword ')'
760 {
761 $$ = new Module_Param_FloatRange($2, true, 0.0, false);
762 }
763 ;
764
765 StringRange:
766 '(' UniversalCharstringFragment DotDot UniversalCharstringFragment ')'
767 {
768 universal_char lower; lower.uc_group=lower.uc_plane=lower.uc_row=lower.uc_cell=0;
769 universal_char upper; upper.uc_group=upper.uc_plane=upper.uc_row=upper.uc_cell=0;
770 if ($2.n_uchars!=1) {
771 config_process_error("Lower bound of char range must be 1 character only");
772 } else if ($4.n_uchars!=1) {
773 config_process_error("Upper bound of char range must be 1 character only");
774 } else {
775 lower = *($2.uchars_ptr);
776 upper = *($4.uchars_ptr);
777 if (upper<lower) {
778 config_process_error("Lower bound is larger than upper bound in the char range");
779 lower = upper;
780 }
781 }
782 Free($2.uchars_ptr);
783 Free($4.uchars_ptr);
784 $$ = new Module_Param_StringRange(lower, upper);
785 }
786 ;
787
788 // integers outside of the [MODULE_PARAMETERS] section
789 IntegerValue:
790 Number { $$ = $1; }
791 | '(' IntegerValue ')' { $$ = $2; }
792 | '+' IntegerValue %prec UnarySign { $$ = $2; }
793 | '-' IntegerValue %prec UnarySign
794 {
795 INTEGER op1;
796 op1.set_val(*$2);
797 $$ = new int_val_t((-op1).get_val());
798 delete $2;
799 }
800 | IntegerValue '+' IntegerValue
801 {
802 INTEGER op1, op2;
803 op1.set_val(*$1);
804 op2.set_val(*$3);
805 $$ = new int_val_t((op1 + op2).get_val());
806 delete $1;
807 delete $3;
808 }
809 | IntegerValue '-' IntegerValue
810 {
811 INTEGER op1, op2;
812 op1.set_val(*$1);
813 op2.set_val(*$3);
814 $$ = new int_val_t((op1 - op2).get_val());
815 delete $1;
816 delete $3;
817 }
818 | IntegerValue '*' IntegerValue
819 {
820 INTEGER op1, op2;
821 op1.set_val(*$1);
822 op2.set_val(*$3);
823 $$ = new int_val_t((op1 * op2).get_val());
824 delete $1;
825 delete $3;
826 }
827 | IntegerValue '/' IntegerValue
828 {
829 if (*$3 == 0) {
830 config_process_error("Integer division by zero.");
831 $$ = new int_val_t((RInt)0);
832 delete $1;
833 delete $3;
834 } else {
835 INTEGER op1, op2;
836 op1.set_val(*$1);
837 op2.set_val(*$3);
838 $$ = new int_val_t((op1 / op2).get_val());
839 delete $1;
840 delete $3;
841 }
842 }
843 ;
844
845 // floats outside of the [MODULE_PARAMETERS] section
846 FloatValue:
847 Float { $$ = $1; }
848 | '(' FloatValue ')' { $$ = $2; }
849 | '+' FloatValue %prec UnarySign { $$ = $2; }
850 | '-' FloatValue %prec UnarySign { $$ = -$2; }
851 | FloatValue '+' FloatValue { $$ = $1 + $3; }
852 | FloatValue '-' FloatValue { $$ = $1 - $3; }
853 | FloatValue '*' FloatValue { $$ = $1 * $3; }
854 | FloatValue '/' FloatValue
855 {
856 if ($3 == 0.0) {
857 config_process_error("Floating point division by zero.");
858 $$ = 0.0;
859 } else $$ = $1 / $3;
860 }
861 ;
862
863 ObjIdValue:
864 ObjIdKeyword '{' ObjIdComponentList '}' { $$ = $3; }
865 ;
866
867 ObjIdComponentList:
868 ObjIdComponent
869 {
870 $$.n_components = 1;
871 $$.components_ptr = (int *)Malloc(sizeof(int));
872 $$.components_ptr[0] = $1->get_val();
873 delete $1;
874 }
875 | ObjIdComponentList ObjIdComponent
876 {
877 $$.n_components = $1.n_components + 1;
878 $$.components_ptr = (int *)Realloc($1.components_ptr,
879 $$.n_components * sizeof(int));
880 $$.components_ptr[$$.n_components - 1] = $2->get_val();
881 delete $2;
882 }
883 ;
884
885 ObjIdComponent:
886 NumberForm { $$ = $1; }
887 | NameAndNumberForm { $$ = $1; }
888 ;
889
890 NumberForm:
891 MPNumber { $$ = $1; }
892 ;
893
894 NameAndNumberForm:
895 Identifier '(' MPNumber ')'
896 {
897 Free($1);
898 $$ = $3;
899 }
900 ;
901
902 BitstringValue:
903 Bstring { $$ = $1; }
904 ;
905
906 HexstringValue:
907 Hstring { $$ = $1; }
908 ;
909
910 OctetstringValue:
911 Ostring { $$ = $1; }
912 ;
913
914 UniversalCharstringValue:
915 Quadruple
916 {
917 $$.n_uchars = 1;
918 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
919 $$.uchars_ptr[0] = $1;
920 }
921 ;
922
923 UniversalCharstringFragment:
924 MPCstring
925 {
926 $$.n_uchars = $1.n_chars;
927 $$.uchars_ptr = (universal_char*)
928 Malloc($$.n_uchars * sizeof(universal_char));
929 for (int i = 0; i < $1.n_chars; i++) {
930 $$.uchars_ptr[i].uc_group = 0;
931 $$.uchars_ptr[i].uc_plane = 0;
932 $$.uchars_ptr[i].uc_row = 0;
933 $$.uchars_ptr[i].uc_cell = $1.chars_ptr[i];
934 }
935 Free($1.chars_ptr);
936 }
937 | Quadruple
938 {
939 $$.n_uchars = 1;
940 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
941 $$.uchars_ptr[0] = $1;
942 }
943 ;
944
945 Quadruple:
946 CharKeyword '(' ParameterExpression ',' ParameterExpression ','
947 ParameterExpression ',' ParameterExpression ')'
948 {
949 $3->set_id(new Module_Param_CustomName(mcopystr("quadruple group")));
950 $5->set_id(new Module_Param_CustomName(mcopystr("quadruple plane")));
951 $7->set_id(new Module_Param_CustomName(mcopystr("quadruple row")));
952 $9->set_id(new Module_Param_CustomName(mcopystr("quadruple cell")));
953 INTEGER g, p, r, c;
954 g.set_param(*$3);
955 p.set_param(*$5);
956 r.set_param(*$7);
957 c.set_param(*$9);
958 if (g < 0 || g > 127) {
959 char *s = g.get_val().as_string();
960 config_process_error_f("The first number of quadruple (group) must be "
961 "within the range 0 .. 127 instead of %s.", s);
962 Free(s);
963 $$.uc_group = g < 0 ? 0 : 127;
964 } else {
965 $$.uc_group = g;
966 }
967 if (p < 0 || p > 255) {
968 char *s = p.get_val().as_string();
969 config_process_error_f("The second number of quadruple (plane) must be "
970 "within the range 0 .. 255 instead of %s.", s);
971 Free(s);
972 $$.uc_plane = p < 0 ? 0 : 255;
973 } else {
974 $$.uc_plane = p;
975 }
976 if (r < 0 || r > 255) {
977 char *s = r.get_val().as_string();
978 config_process_error_f("The third number of quadruple (row) must be "
979 "within the range 0 .. 255 instead of %s.", s);
980 Free(s);
981 $$.uc_row = r < 0 ? 0 : 255;
982 } else {
983 $$.uc_row = r;
984 }
985 if (c < 0 || c > 255) {
986 char *s = c.get_val().as_string();
987 config_process_error_f("The fourth number of quadruple (cell) must be "
988 "within the range 0 .. 255 instead of %s.", s);
989 Free(s);
990 $$.uc_cell = c < 0 ? 0 : 255;
991 } else {
992 $$.uc_cell = c;
993 }
994 delete $3;
995 delete $5;
996 delete $7;
997 delete $9;
998 }
999 ;
1000
1001 // character strings outside of the [MODULE_PARAMETERS] section
1002 StringValue:
1003 Cstring
1004 {
1005 $$ = mcopystr($1.chars_ptr);
1006 Free($1.chars_ptr);
1007 }
1008 | StringValue '&' Cstring
1009 {
1010 $$ = mputstr($1, $3.chars_ptr);
1011 Free($3.chars_ptr);
1012 }
1013 ;
1014
1015 CompoundValue:
1016 '{' '}'
1017 {
1018 $$ = new Module_Param_Value_List();
1019 }
1020 | '{' FieldValueList '}'
1021 {
1022 $$ = $2;
1023 }
1024 | '{' ArrayItemList '}'
1025 {
1026 $$ = $2;
1027 }
1028 | '{' IndexItemList '}'
1029 {
1030 $$ = $2;
1031 }
1032 | '(' ParameterValue ',' TemplateItemList ')' /* at least 2 elements to avoid shift/reduce conflicts with the ParameterExpression rule */
1033 {
1034 $$ = new Module_Param_List_Template();
1035 $2->set_id(new Module_Param_Index($$->get_size(),false));
1036 $$->add_elem($2);
1037 $$->add_list_with_implicit_ids($4);
1038 delete $4;
1039 }
1040 | ComplementKeyword '(' TemplateItemList ')'
1041 {
1042 $$ = new Module_Param_ComplementList_Template();
1043 $$->add_list_with_implicit_ids($3);
1044 delete $3;
1045 }
1046 | SupersetKeyword '(' TemplateItemList ')'
1047 {
1048 $$ = new Module_Param_Superset_Template();
1049 $$->add_list_with_implicit_ids($3);
1050 delete $3;
1051 }
1052 | SubsetKeyword '(' TemplateItemList ')'
1053 {
1054 $$ = new Module_Param_Subset_Template();
1055 $$->add_list_with_implicit_ids($3);
1056 delete $3;
1057 }
1058 ;
1059
1060 ParameterValueOrNotUsedSymbol:
1061 ParameterValue
1062 {
1063 $$ = $1;
1064 }
1065 | '-'
1066 {
1067 $$ = new Module_Param_NotUsed();
1068 }
1069 ;
1070
1071 TemplateItemList:
1072 ParameterValue
1073 {
1074 $$ = new Vector<Module_Param*>();
1075 $$->push_back($1);
1076 }
1077 | TemplateItemList ',' ParameterValue
1078 {
1079 $$ = $1;
1080 $$->push_back($3);
1081 }
1082 ;
1083
1084 FieldValueList:
1085 FieldValue
1086 {
1087 $$ = new Module_Param_Assignment_List();
1088 $$->add_elem($1);
1089 }
1090 | FieldValueList ',' FieldValue
1091 {
1092 $$ = $1;
1093 $$->add_elem($3);
1094 }
1095 ;
1096
1097 FieldValue:
1098 FieldName AssignmentChar ParameterValueOrNotUsedSymbol
1099 {
1100 $$ = $3;
1101 $$->set_id(new Module_Param_FieldName($1));
1102 }
1103 ;
1104
1105 FieldName:
1106 Identifier
1107 {
1108 $$ = $1;
1109 }
1110 | ASN1LowerIdentifier
1111 {
1112 $$ = $1;
1113 }
1114 ;
1115
1116 ArrayItemList:
1117 ArrayItem
1118 {
1119 $$ = new Module_Param_Value_List();
1120 $1->set_id(new Module_Param_Index($$->get_size(),false));
1121 $$->add_elem($1);
1122 }
1123 | ArrayItemList ',' ArrayItem
1124 {
1125 $$ = $1;
1126 $3->set_id(new Module_Param_Index($$->get_size(),false));
1127 $$->add_elem($3);
1128 }
1129 ;
1130
1131 ArrayItem:
1132 ParameterValueOrNotUsedSymbol
1133 {
1134 $$ = $1;
1135 }
1136 | PermutationKeyword '(' TemplateItemList ')'
1137 {
1138 $$ = new Module_Param_Permutation_Template();
1139 $$->add_list_with_implicit_ids($3);
1140 delete $3;
1141 }
1142 ;
1143
1144 IndexItemList:
1145 IndexItem
1146 {
1147 $$ = new Module_Param_Indexed_List();
1148 $$->add_elem($1);
1149 }
1150 | IndexItemList ',' IndexItem
1151 {
1152 $$ = $1;
1153 $$->add_elem($3);
1154 }
1155 ;
1156
1157 IndexItem:
1158 IndexItemIndex AssignmentChar ParameterValue
1159 {
1160 $$ = $3;
1161 $$->set_id(new Module_Param_Index((size_t)$1,true));
1162 }
1163 ;
1164
1165 IndexItemIndex:
1166 '[' ParameterExpression ']'
1167 {
1168 $2->set_id(new Module_Param_CustomName(mcopystr("array index")));
1169 INTEGER tmp;
1170 tmp.set_param(*$2);
1171 if (!tmp.get_val().is_native()) {
1172 config_process_error("bignum index."); // todo
1173 }
1174 if (tmp.get_val().is_negative()) {
1175 config_process_error("negative index."); // todo
1176 }
1177 $$ = tmp;
1178 delete $2;
1179 }
1180 ;
1181
1182 /*************** [LOGGING] section *********************************/
1183
1184 LoggingSection:
1185 LoggingKeyword LoggingParamList
1186 ;
1187
1188 LoggingParamList:
1189 /* empty */
1190 | LoggingParamList LoggingParamLines optSemiColon
1191 {
1192 // Centralized duplication handling for `[LOGGING]'.
1193 if ($2.logparam.log_param_selection != LP_UNKNOWN && TTCN_Logger::add_parameter($2)) {
1194 switch ($2.logparam.log_param_selection) {
1195 case LP_FILEMASK:
1196 check_duplicate_option("LOGGING", "FileMask", file_mask_set);
1197 break;
1198 case LP_CONSOLEMASK:
1199 check_duplicate_option("LOGGING", "ConsoleMask", console_mask_set);
1200 break;
1201 case LP_LOGFILESIZE:
1202 check_duplicate_option("LOGGING", "LogFileSize", log_file_size_set);
1203 break;
1204 case LP_LOGFILENUMBER:
1205 check_duplicate_option("LOGGING", "LogFileNumber", log_file_number_set);
1206 break;
1207 case LP_DISKFULLACTION:
1208 check_duplicate_option("LOGGING", "DiskFullAction", log_disk_full_action_set);
1209 break;
1210 case LP_LOGFILE:
1211 check_duplicate_option("LOGGING", "LogFile", file_name_set);
1212 break;
1213 case LP_TIMESTAMPFORMAT:
1214 check_duplicate_option("LOGGING", "TimeStampFormat", timestamp_format_set);
1215 break;
1216 case LP_SOURCEINFOFORMAT:
1217 check_duplicate_option("LOGGING", "SourceInfoFormat", source_info_format_set);
1218 break;
1219 case LP_APPENDFILE:
1220 check_duplicate_option("LOGGING", "AppendFile", append_file_set);
1221 break;
1222 case LP_LOGEVENTTYPES:
1223 check_duplicate_option("LOGGING", "LogEventTypes", log_event_types_set);
1224 break;
1225 case LP_LOGENTITYNAME:
1226 check_duplicate_option("LOGGING", "LogEntityName", log_entity_name_set);
1227 break;
1228 case LP_MATCHINGHINTS:
1229 check_duplicate_option("LOGGING", "MatchingVerbosity", matching_verbosity_set);
1230 break;
1231 case LP_PLUGIN_SPECIFIC:
1232 // It would be an overkill to check for the infinite number of custom parameters...
1233 check_duplicate_option("LOGGING", "PluginSpecific", plugin_specific_set);
1234 break;
1235 default:
1236 break;
1237 }
1238 }
1239 }
1240 ;
1241
1242 LoggingParamLines:
1243 LoggingParam
1244 {
1245 $$.component.id_selector = COMPONENT_ID_ALL;
1246 $$.component.id_name = NULL;
1247 $$.plugin_id = NULL;
1248 $$.logparam = $1;
1249 }
1250 | ComponentId '.' LoggingParam
1251 {
1252 $$.component = $1;
1253 $$.plugin_id = NULL;
1254 $$.logparam = $3;
1255 }
1256 | ComponentId '.' LoggerPluginId '.' LoggingParam
1257 {
1258 $$.component = $1;
1259 $$.plugin_id = $3;
1260 $$.logparam = $5;
1261 }
1262 | LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1263 {
1264 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1265 component_id_t comp;
1266 comp.id_selector = COMPONENT_ID_ALL;
1267 comp.id_name = NULL;
1268 logging_plugin_t *plugin = $4;
1269 while (plugin != NULL) {
1270 // `identifier' and `filename' are reused. Various checks and
1271 // validations must be done in the logger itself (e.g. looking for
1272 // duplicate options).
1273 TTCN_Logger::register_plugin(comp, plugin->identifier, plugin->filename);
1274 logging_plugin_t *tmp = plugin;
1275 plugin = tmp->next;
1276 Free(tmp);
1277 }
1278 $$.logparam.log_param_selection = LP_UNKNOWN;
1279 }
1280 | ComponentId '.' LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1281 {
1282 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1283 logging_plugin_t *plugin = $6;
1284 while (plugin != NULL) {
1285 TTCN_Logger::register_plugin($1, plugin->identifier, plugin->filename);
1286 logging_plugin_t *tmp = plugin;
1287 plugin = tmp->next;
1288 Free(tmp);
1289 }
1290 // Component names shall be duplicated in `register_plugin()'.
1291 if ($1.id_selector == COMPONENT_ID_NAME)
1292 Free($1.id_name);
1293 $$.logparam.log_param_selection = LP_UNKNOWN;
1294 }
1295 ;
1296
1297 LoggerPluginList:
1298 LoggerPlugin
1299 {
1300 $$ = $1;
1301 }
1302 | LoggerPluginList ',' LoggerPlugin
1303 {
1304 $$ = $3;
1305 $$->next = $1;
1306 }
1307 ;
1308
1309 LoggerPlugin:
1310 Identifier
1311 {
1312 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1313 $$->identifier = $1;
1314 $$->filename = NULL;
1315 $$->next = NULL;
1316 }
1317 | Identifier AssignmentChar StringValue
1318 {
1319 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1320 $$->identifier = $1;
1321 $$->filename = $3;
1322 $$->next = NULL;
1323 }
1324 ;
1325
1326 LoggerPluginId:
1327 '*' { $$ = mcopystr("*"); }
1328 | Identifier { $$ = $1; }
1329 ;
1330
1331 LoggingParam:
1332 FileMask AssignmentChar LoggingBitmask
1333 {
1334 $$.log_param_selection = LP_FILEMASK;
1335 $$.logoptions_val = $3;
1336 }
1337 | ConsoleMask AssignmentChar LoggingBitmask
1338 {
1339 $$.log_param_selection = LP_CONSOLEMASK;
1340 $$.logoptions_val = $3;
1341 }
1342 | LogFileSize AssignmentChar Number
1343 {
1344 $$.log_param_selection = LP_LOGFILESIZE;
1345 $$.int_val = (int)$3->get_val();
1346 delete $3;
1347 }
1348 | EmergencyLogging AssignmentChar Number
1349 {
1350 $$.log_param_selection = LP_EMERGENCY;
1351 $$.int_val = (int)$3->get_val();
1352 delete $3;
1353 }
1354 | EmergencyLoggingBehaviour AssignmentChar EmergencyLoggingBehaviourValue
1355 {
1356 $$.log_param_selection = LP_EMERGENCYBEHAVIOR;
1357 $$.emergency_logging_behaviour_value = $3;
1358 }
1359 | EmergencyLoggingMask AssignmentChar LoggingBitmask
1360 {
1361 $$.log_param_selection = LP_EMERGENCYMASK;
1362 $$.logoptions_val = $3;
1363 }
1364 | EmergencyLoggingForFailVerdict AssignmentChar YesNoOrBoolean
1365 {
1366 $$.log_param_selection = LP_EMERGENCYFORFAIL;
1367 $$.bool_val = $3;
1368 }
1369 | LogFileNumber AssignmentChar Number
1370 {
1371 $$.log_param_selection = LP_LOGFILENUMBER;
1372 $$.int_val = (int)$3->get_val();
1373 delete $3;
1374 }
1375 | DiskFullAction AssignmentChar DiskFullActionValue
1376 {
1377 $$.log_param_selection = LP_DISKFULLACTION;
1378 $$.disk_full_action_value = $3;
1379 }
1380 | LogFile AssignmentChar LogFileName
1381 {
1382 $$.log_param_selection = LP_LOGFILE;
1383 $$.str_val = $3;
1384 }
1385 | TimestampFormat AssignmentChar TimestampValue
1386 {
1387 $$.log_param_selection = LP_TIMESTAMPFORMAT;
1388 $$.timestamp_value = $3;
1389 }
1390 | ConsoleTimestampFormat AssignmentChar TimestampValue
1391 {
1392 $$.log_param_selection = LP_UNKNOWN;
1393 }
1394 | SourceInfoFormat AssignmentChar SourceInfoSetting
1395 {
1396 $$.log_param_selection = LP_SOURCEINFOFORMAT;
1397 $$.source_info_value = $3;
1398 }
1399 | AppendFile AssignmentChar YesNoOrBoolean
1400 {
1401 $$.log_param_selection = LP_APPENDFILE;
1402 $$.bool_val = $3;
1403 }
1404 | LogEventTypes AssignmentChar LogEventTypesValue
1405 {
1406 $$.log_param_selection = LP_LOGEVENTTYPES;
1407 $$.log_event_types_value = $3;
1408 }
1409 | LogEntityName AssignmentChar YesNoOrBoolean
1410 {
1411 $$.log_param_selection = LP_LOGENTITYNAME;
1412 $$.bool_val = $3;
1413 }
1414 | MatchingHints AssignmentChar VerbosityValue
1415 {
1416 $$.log_param_selection = LP_MATCHINGHINTS;
1417 $$.matching_verbosity_value = $3;
1418 }
1419 | Identifier AssignmentChar StringValue
1420 {
1421 $$.log_param_selection = LP_PLUGIN_SPECIFIC;
1422 $$.param_name = $1;
1423 $$.str_val = $3;
1424 }
1425 ;
1426
1427 VerbosityValue:
1428 Compact { $$ = TTCN_Logger::VERBOSITY_COMPACT; }
1429 | Detailed { $$ = TTCN_Logger::VERBOSITY_FULL; }
1430 ;
1431
1432 DiskFullActionValue:
1433 Error { $$.type = TTCN_Logger::DISKFULL_ERROR; }
1434 | Stop { $$.type = TTCN_Logger::DISKFULL_STOP; }
1435 | Retry
1436 {
1437 $$.type = TTCN_Logger::DISKFULL_RETRY;
1438 $$.retry_interval = 30; /* default retry interval */
1439 }
1440 | Retry '(' Number ')'
1441 {
1442 $$.type = TTCN_Logger::DISKFULL_RETRY;
1443 $$.retry_interval = (size_t)$3->get_val();
1444 delete $3;
1445 }
1446 | Delete { $$.type = TTCN_Logger::DISKFULL_DELETE; }
1447 ;
1448
1449 LogFileName:
1450 StringValue { $$ = $1; }
1451 ;
1452
1453 LoggingBitOrCollection:
1454 LoggingBit
1455 {
1456 $$.clear();
1457 $$.add_sev($1);
1458 }
1459 | LoggingBitCollection
1460 {
1461 $$.clear();
1462 switch($1)
1463 {
1464 case TTCN_Logger::ACTION_UNQUALIFIED:
1465 $$.add_sev(TTCN_Logger::ACTION_UNQUALIFIED);
1466 break;
1467 case TTCN_Logger::DEFAULTOP_UNQUALIFIED:
1468 $$.add_sev(TTCN_Logger::DEFAULTOP_ACTIVATE);
1469 $$.add_sev(TTCN_Logger::DEFAULTOP_DEACTIVATE);
1470 $$.add_sev(TTCN_Logger::DEFAULTOP_EXIT);
1471 $$.add_sev(TTCN_Logger::DEFAULTOP_UNQUALIFIED);
1472 break;
1473 case TTCN_Logger::ERROR_UNQUALIFIED:
1474 $$.add_sev(TTCN_Logger::ERROR_UNQUALIFIED);
1475 break;
1476 case TTCN_Logger::EXECUTOR_UNQUALIFIED:
1477 $$.add_sev(TTCN_Logger::EXECUTOR_RUNTIME);
1478 $$.add_sev(TTCN_Logger::EXECUTOR_CONFIGDATA);
1479 $$.add_sev(TTCN_Logger::EXECUTOR_EXTCOMMAND);
1480 $$.add_sev(TTCN_Logger::EXECUTOR_COMPONENT);
1481 $$.add_sev(TTCN_Logger::EXECUTOR_LOGOPTIONS);
1482 $$.add_sev(TTCN_Logger::EXECUTOR_UNQUALIFIED);
1483 break;
1484 case TTCN_Logger::FUNCTION_UNQUALIFIED:
1485 $$.add_sev(TTCN_Logger::FUNCTION_RND);
1486 $$.add_sev(TTCN_Logger::FUNCTION_UNQUALIFIED);
1487 break;
1488 case TTCN_Logger::PARALLEL_UNQUALIFIED:
1489 $$.add_sev(TTCN_Logger::PARALLEL_PTC);
1490 $$.add_sev(TTCN_Logger::PARALLEL_PORTCONN);
1491 $$.add_sev(TTCN_Logger::PARALLEL_PORTMAP);
1492 $$.add_sev(TTCN_Logger::PARALLEL_UNQUALIFIED);
1493 break;
1494 case TTCN_Logger::PORTEVENT_UNQUALIFIED:
1495 $$.add_sev(TTCN_Logger::PORTEVENT_PQUEUE);
1496 $$.add_sev(TTCN_Logger::PORTEVENT_MQUEUE);
1497 $$.add_sev(TTCN_Logger::PORTEVENT_STATE);
1498 $$.add_sev(TTCN_Logger::PORTEVENT_PMIN);
1499 $$.add_sev(TTCN_Logger::PORTEVENT_PMOUT);
1500 $$.add_sev(TTCN_Logger::PORTEVENT_PCIN);
1501 $$.add_sev(TTCN_Logger::PORTEVENT_PCOUT);
1502 $$.add_sev(TTCN_Logger::PORTEVENT_MMRECV);
1503 $$.add_sev(TTCN_Logger::PORTEVENT_MMSEND);
1504 $$.add_sev(TTCN_Logger::PORTEVENT_MCRECV);
1505 $$.add_sev(TTCN_Logger::PORTEVENT_MCSEND);
1506 $$.add_sev(TTCN_Logger::PORTEVENT_DUALRECV);
1507 $$.add_sev(TTCN_Logger::PORTEVENT_DUALSEND);
1508 $$.add_sev(TTCN_Logger::PORTEVENT_UNQUALIFIED);
1509 break;
1510 case TTCN_Logger::TESTCASE_UNQUALIFIED:
1511 $$.add_sev(TTCN_Logger::TESTCASE_START);
1512 $$.add_sev(TTCN_Logger::TESTCASE_FINISH);
1513 $$.add_sev(TTCN_Logger::TESTCASE_UNQUALIFIED);
1514 break;
1515 case TTCN_Logger::TIMEROP_UNQUALIFIED:
1516 $$.add_sev(TTCN_Logger::TIMEROP_READ);
1517 $$.add_sev(TTCN_Logger::TIMEROP_START);
1518 $$.add_sev(TTCN_Logger::TIMEROP_GUARD);
1519 $$.add_sev(TTCN_Logger::TIMEROP_STOP);
1520 $$.add_sev(TTCN_Logger::TIMEROP_TIMEOUT);
1521 $$.add_sev(TTCN_Logger::TIMEROP_UNQUALIFIED);
1522 break;
1523 case TTCN_Logger::USER_UNQUALIFIED:
1524 $$.add_sev(TTCN_Logger::USER_UNQUALIFIED);
1525 break;
1526 case TTCN_Logger::STATISTICS_UNQUALIFIED:
1527 $$.add_sev(TTCN_Logger::STATISTICS_VERDICT);
1528 $$.add_sev(TTCN_Logger::STATISTICS_UNQUALIFIED);
1529 break;
1530 case TTCN_Logger::VERDICTOP_UNQUALIFIED:
1531 $$.add_sev(TTCN_Logger::VERDICTOP_GETVERDICT);
1532 $$.add_sev(TTCN_Logger::VERDICTOP_SETVERDICT);
1533 $$.add_sev(TTCN_Logger::VERDICTOP_FINAL);
1534 $$.add_sev(TTCN_Logger::VERDICTOP_UNQUALIFIED);
1535 break;
1536 case TTCN_Logger::WARNING_UNQUALIFIED:
1537 $$.add_sev(TTCN_Logger::WARNING_UNQUALIFIED);
1538 break;
1539 case TTCN_Logger::MATCHING_UNQUALIFIED:
1540 $$.add_sev(TTCN_Logger::MATCHING_DONE);
1541 $$.add_sev(TTCN_Logger::MATCHING_TIMEOUT);
1542 $$.add_sev(TTCN_Logger::MATCHING_PCSUCCESS);
1543 $$.add_sev(TTCN_Logger::MATCHING_PCUNSUCC);
1544 $$.add_sev(TTCN_Logger::MATCHING_PMSUCCESS);
1545 $$.add_sev(TTCN_Logger::MATCHING_PMUNSUCC);
1546 $$.add_sev(TTCN_Logger::MATCHING_MCSUCCESS);
1547 $$.add_sev(TTCN_Logger::MATCHING_MCUNSUCC);
1548 $$.add_sev(TTCN_Logger::MATCHING_MMSUCCESS);
1549 $$.add_sev(TTCN_Logger::MATCHING_MMUNSUCC);
1550 $$.add_sev(TTCN_Logger::MATCHING_PROBLEM);
1551 $$.add_sev(TTCN_Logger::MATCHING_UNQUALIFIED);
1552 break;
1553 case TTCN_Logger::DEBUG_UNQUALIFIED:
1554 $$.add_sev(TTCN_Logger::DEBUG_ENCDEC);
1555 $$.add_sev(TTCN_Logger::DEBUG_TESTPORT);
1556 $$.add_sev(TTCN_Logger::DEBUG_USER);
1557 $$.add_sev(TTCN_Logger::DEBUG_FRAMEWORK);
1558 $$.add_sev(TTCN_Logger::DEBUG_UNQUALIFIED);
1559 break;
1560 case TTCN_Logger::LOG_ALL_IMPORTANT:
1561 $$ = Logging_Bits::log_all;
1562 break;
1563 default:
1564 /* The lexer sent something the parser doesn't understand!
1565 Parser needs to be updated.
1566 */
1567 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
1568 "Internal error: unknown logbit from lexer.");
1569 break;
1570 } // switch
1571 }
1572 ;
1573
1574 LoggingBitmask:
1575 LoggingBitOrCollection
1576 {
1577 $$ = $1;
1578 }
1579 | LoggingBitmask '|' LoggingBitOrCollection
1580 {
1581 $$ = $1;
1582 $$.merge($3);
1583 }
1584 ;
1585
1586 SourceInfoSetting:
1587 SourceInfoValue { $$ = $1; }
1588 | YesNoOrBoolean
1589 {
1590 $$ = $1 ? TTCN_Logger::SINFO_SINGLE : TTCN_Logger::SINFO_NONE;
1591 }
1592 ;
1593
1594 YesNoOrBoolean:
1595 YesNo { $$ = $1; }
1596 | BooleanValue { $$ = $1; }
1597 ;
1598
1599 LogEventTypesValue:
1600 YesNoOrBoolean { $$ = $1 ? TTCN_Logger::LOGEVENTTYPES_YES :
1601 TTCN_Logger::LOGEVENTTYPES_NO; }
1602 | SubCategories { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1603 | Detailed { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1604 ;
1605
1606 /*********************** [PROFILER] ********************************/
1607
1608 ProfilerSection:
1609 ProfilerKeyword ProfilerSettings
1610 ;
1611
1612 ProfilerSettings:
1613 /* empty */
1614 | ProfilerSettings ProfilerSetting optSemiColon
1615 ;
1616
1617 ProfilerSetting:
1618 DisableProfilerSetting
1619 | DisableCoverageSetting
1620 | DatabaseFileSetting
1621 | AggregateDataSetting
1622 | StatisticsFileSetting
1623 | DisableStatisticsSetting
1624 | StatisticsFilterSetting
1625 | StartAutomaticallySetting
1626 | NetLineTimesSetting
1627 | NetFunctionTimesSetting
1628 ;
1629
1630 DisableProfilerSetting:
1631 DisableProfilerKeyword AssignmentChar BooleanValue {
1632 ttcn3_prof.set_disable_profiler($3);
1633 }
1634 ;
1635
1636 DisableCoverageSetting:
1637 DisableCoverageKeyword AssignmentChar BooleanValue {
1638 ttcn3_prof.set_disable_coverage($3);
1639 }
1640 ;
1641
1642 DatabaseFileSetting:
1643 DatabaseFileKeyword AssignmentChar StringValue {
1644 ttcn3_prof.set_database_filename($3);
1645 }
1646 ;
1647
1648 AggregateDataSetting:
1649 AggregateDataKeyword AssignmentChar BooleanValue {
1650 ttcn3_prof.set_aggregate_data($3);
1651 }
1652 ;
1653
1654 StatisticsFileSetting:
1655 StatisticsFileKeyword AssignmentChar StringValue {
1656 ttcn3_prof.set_stats_filename($3);
1657 }
1658 ;
1659
1660 DisableStatisticsSetting:
1661 DisableStatisticsKeyword AssignmentChar BooleanValue {
1662 ttcn3_prof.set_disable_stats($3);
1663 }
1664 ;
1665
1666 StatisticsFilterSetting:
1667 StatisticsFilterKeyword AssignmentChar ProfilerStatsFlags {
1668 ttcn3_prof.reset_stats_flags();
1669 ttcn3_prof.add_stats_flags($3);
1670 }
1671 | StatisticsFilterKeyword ConcatChar ProfilerStatsFlags {
1672 ttcn3_prof.add_stats_flags($3);
1673 }
1674 ;
1675
1676 ProfilerStatsFlags:
1677 ProfilerStatsFlag { $$ = $1; }
1678 | ProfilerStatsFlag '&' ProfilerStatsFlags { $$ = $1 | $3; }
1679 | ProfilerStatsFlag '|' ProfilerStatsFlags { $$ = $1 | $3; }
1680 ;
1681
1682 StartAutomaticallySetting:
1683 StartAutomaticallyKeyword AssignmentChar BooleanValue {
1684 if ($3) {
1685 ttcn3_prof.start();
1686 }
1687 else {
1688 ttcn3_prof.stop();
1689 }
1690 }
1691 ;
1692
1693 NetLineTimesSetting:
1694 NetLineTimesKeyword AssignmentChar BooleanValue {
1695 TTCN3_Stack_Depth::set_net_line_times($3);
1696 }
1697 ;
1698
1699 NetFunctionTimesSetting:
1700 NetFunctionTimesKeyword AssignmentChar BooleanValue {
1701 TTCN3_Stack_Depth::set_net_func_times($3);
1702 }
1703 ;
1704
1705
1706 /**************** [TESTPORT_PARAMETERS] ****************************/
1707
1708 TestportParametersSection:
1709 TestportParametersKeyword TestportParameterList
1710 ;
1711
1712 TestportParameterList:
1713 /* empty */
1714 | TestportParameterList TestportParameter optSemiColon
1715 ;
1716
1717 TestportParameter:
1718 ComponentId '.' TestportName '.' TestportParameterName AssignmentChar
1719 TestportParameterValue
1720 {
1721 PORT::add_parameter($1, $3, $5, $7);
1722 if ($1.id_selector == COMPONENT_ID_NAME) Free($1.id_name);
1723 Free($3);
1724 Free($5);
1725 Free($7);
1726 }
1727 ;
1728
1729 ComponentId:
1730 Identifier
1731 {
1732 $$.id_selector = COMPONENT_ID_NAME;
1733 $$.id_name = $1;
1734 }
1735 | Cstring
1736 {
1737 $$.id_selector = COMPONENT_ID_NAME;
1738 $$.id_name = $1.chars_ptr;
1739 }
1740 | Number
1741 {
1742 $$.id_selector = COMPONENT_ID_COMPREF;
1743 $$.id_compref = (component)$1->get_val();
1744 delete $1;
1745 }
1746 | MTCKeyword
1747 {
1748 $$.id_selector = COMPONENT_ID_COMPREF;
1749 $$.id_compref = MTC_COMPREF;
1750 }
1751 | '*'
1752 {
1753 $$.id_selector = COMPONENT_ID_ALL;
1754 $$.id_name = NULL;
1755 }
1756 | SystemKeyword
1757 {
1758 $$.id_selector = COMPONENT_ID_SYSTEM;
1759 $$.id_name = NULL;
1760 }
1761 ;
1762
1763 TestportName:
1764 Identifier { $$ = $1; }
1765 | Identifier ArrayRef
1766 {
1767 $$ = mputstr($1, $2);
1768 Free($2);
1769 }
1770 | '*' { $$ = NULL; }
1771 ;
1772
1773 ArrayRef:
1774 '[' IntegerValue ']'
1775 {
1776 char *s = $2->as_string();
1777 $$ = memptystr();
1778 $$ = mputc ($$, '[');
1779 $$ = mputstr($$, s);
1780 $$ = mputc ($$, ']');
1781 Free(s);
1782 delete $2;
1783 }
1784 | ArrayRef '[' IntegerValue ']'
1785 {
1786 char *s = $3->as_string();
1787 $$ = mputc ($1, '[');
1788 $$ = mputstr($$, s);
1789 $$ = mputc ($$, ']');
1790 Free(s);
1791 delete $3;
1792 }
1793 ;
1794
1795 TestportParameterName:
1796 Identifier { $$ = $1; }
1797 ;
1798
1799 TestportParameterValue:
1800 StringValue { $$ = $1; }
1801 ;
1802
1803 /****************** [EXECUTE] section *************/
1804
1805 ExecuteSection:
1806 ExecuteKeyword ExecuteList
1807 {
1808 if (!TTCN_Runtime::is_single()) config_process_error("Internal error: "
1809 "the Main Controller must not send section [EXECUTE] of the "
1810 "configuration file.");
1811 }
1812 ;
1813
1814 ExecuteList:
1815 /* empty */
1816 | ExecuteList ExecuteItem optSemiColon
1817 {
1818 if (TTCN_Runtime::is_single()) {
1819 execute_list = (execute_list_item *)Realloc(
1820 execute_list, (execute_list_len + 1) *
1821 sizeof(*execute_list));
1822 execute_list[execute_list_len++] = $2;
1823 } else {
1824 Free($2.module_name);
1825 Free($2.testcase_name);
1826 }
1827 }
1828 ;
1829
1830 ExecuteItem:
1831 Identifier
1832 {
1833 $$.module_name = $1;
1834 $$.testcase_name = NULL;
1835 }
1836 | Identifier '.' ControlKeyword
1837 {
1838 $$.module_name = $1;
1839 $$.testcase_name = NULL;
1840 }
1841 | Identifier '.' Identifier
1842 {
1843 $$.module_name = $1;
1844 $$.testcase_name = $3;
1845 }
1846 | Identifier '.' '*'
1847 {
1848 $$.module_name = $1;
1849 $$.testcase_name = mcopystr("*");
1850 }
1851 ;
1852
1853 /****************** [EXTERNAL_COMMANDS] section **********************/
1854
1855 ExternalCommandsSection:
1856 ExternalCommandsKeyword ExternalCommandList
1857 ;
1858
1859 ExternalCommandList:
1860 /* empty */
1861 | ExternalCommandList ExternalCommand optSemiColon
1862 ;
1863
1864 ExternalCommand:
1865 BeginControlPart AssignmentChar Command
1866 {
1867 check_duplicate_option("EXTERNAL_COMMANDS", "BeginControlPart",
1868 begin_controlpart_command_set);
1869
1870 TTCN_Runtime::set_begin_controlpart_command($3);
1871
1872 Free($3);
1873 }
1874 | EndControlPart AssignmentChar Command
1875 {
1876 check_duplicate_option("EXTERNAL_COMMANDS", "EndControlPart",
1877 end_controlpart_command_set);
1878
1879 TTCN_Runtime::set_end_controlpart_command($3);
1880
1881 Free($3);
1882 }
1883 | BeginTestCase AssignmentChar Command
1884 {
1885 check_duplicate_option("EXTERNAL_COMMANDS", "BeginTestCase",
1886 begin_testcase_command_set);
1887
1888 TTCN_Runtime::set_begin_testcase_command($3);
1889
1890 Free($3);
1891 }
1892 | EndTestCase AssignmentChar Command
1893 {
1894 check_duplicate_option("EXTERNAL_COMMANDS", "EndTestCase",
1895 end_testcase_command_set);
1896
1897 TTCN_Runtime::set_end_testcase_command($3);
1898
1899 Free($3);
1900 }
1901 ;
1902
1903 Command:
1904 StringValue { $$ = $1; }
1905 ;
1906
1907 /***************** [GROUPS] section *******************/
1908
1909 GroupsSection:
1910 GroupsKeyword GroupList
1911 {
1912 check_ignored_section("GROUPS");
1913 }
1914 ;
1915
1916 GroupList:
1917 /* empty */
1918 | GroupList Group optSemiColon
1919 ;
1920
1921 Group:
1922 GroupName AssignmentChar GroupMembers
1923 ;
1924
1925 GroupName:
1926 Identifier { Free($1); }
1927 ;
1928
1929 GroupMembers:
1930 '*'
1931 | seqGroupMember
1932 ;
1933
1934 seqGroupMember:
1935 HostName
1936 | seqGroupMember ',' HostName
1937 ;
1938
1939 HostName:
1940 DNSName
1941 | Identifier { Free($1); }
1942 ;
1943
1944 /******************** [COMPONENTS] section *******************/
1945 ComponentsSection:
1946 ComponentsKeyword ComponentList
1947 {
1948 check_ignored_section("COMPONENTS");
1949 }
1950 ;
1951
1952 ComponentList:
1953 /* empty */
1954 | ComponentList ComponentItem optSemiColon
1955 ;
1956
1957 ComponentItem:
1958 ComponentName AssignmentChar ComponentLocation
1959 ;
1960
1961 ComponentName:
1962 Identifier { Free($1); }
1963 | '*'
1964 ;
1965
1966 ComponentLocation:
1967 Identifier { Free($1); }
1968 | DNSName
1969 ;
1970
1971 /****************** [MAIN_CONTROLLER] section *********************/
1972 MainControllerSection:
1973 MainControllerKeyword MCParameterList
1974 {
1975 check_ignored_section("MAIN_CONTROLLER");
1976 }
1977 ;
1978
1979 MCParameterList:
1980 /* empty */
1981 | MCParameterList MCParameter optSemiColon
1982 ;
1983
1984 MCParameter:
1985 LocalAddress AssignmentChar HostName { }
1986 | TCPPort AssignmentChar IntegerValue { delete $3; }
1987 | KillTimer AssignmentChar KillTimerValue { }
1988 | NumHCs AssignmentChar IntegerValue { delete $3; }
1989 | UnixSocketEnabled AssignmentChar YesToken {}
1990 | UnixSocketEnabled AssignmentChar NoToken {}
1991 | UnixSocketEnabled AssignmentChar HostName {}
1992 ;
1993
1994 KillTimerValue:
1995 FloatValue { }
1996 | IntegerValue { delete $1; }
1997 ;
1998
1999 /****************** [INCLUDE] section *********************/
2000 IncludeSection:
2001 IncludeKeyword IncludeFiles
2002 {
2003 if(!TTCN_Runtime::is_single())
2004 config_process_error
2005 ("Internal error: the Main Controller must not send section [INCLUDE]"
2006 " of the configuration file.");
2007 }
2008 ;
2009
2010 IncludeFiles:
2011 /* empty */
2012 | IncludeFiles IncludeFile
2013 ;
2014
2015 IncludeFile:
2016 Cstring { Free($1.chars_ptr); }
2017 ;
2018
2019 /****************** [DEFINE] section *********************/
2020 DefineSection:
2021 DefineKeyword
2022 {
2023 if(!TTCN_Runtime::is_single())
2024 config_process_error
2025 ("Internal error: the Main Controller must not send section [DEFINE]"
2026 " of the configuration file.");
2027 }
2028 ;
2029
2030 /*********************************************************/
2031
2032 ParamOpType:
2033 AssignmentChar
2034 {
2035 $$ = Module_Param::OT_ASSIGN;
2036 }
2037 |
2038 ConcatChar
2039 {
2040 $$ = Module_Param::OT_CONCAT;
2041 }
2042 ;
2043
2044 optSemiColon:
2045 /* empty */
2046 | ';'
2047 ;
2048
2049 %%
2050
2051 static void reset_configuration_options()
2052 {
2053 /* Section [MODULE_PARAMETERS */
2054 /** \todo reset module parameters to their default values */
2055 /* Section [LOGGING] */
2056 TTCN_Logger::close_file();
2057 TTCN_Logger::reset_configuration();
2058 file_name_set = FALSE;
2059 file_mask_set = TRUE;
2060 console_mask_set = TRUE;
2061 timestamp_format_set = FALSE;
2062 source_info_format_set = FALSE;
2063 append_file_set = FALSE;
2064 log_event_types_set = FALSE;
2065 log_entity_name_set = FALSE;
2066 /* Section [TESTPORT_PARAMETERS] */
2067 PORT::clear_parameters();
2068 /* Section [EXTERNAL_COMMANDS] */
2069
2070 TTCN_Runtime::clear_external_commands();
2071
2072 begin_controlpart_command_set = FALSE;
2073 end_controlpart_command_set = FALSE;
2074 begin_testcase_command_set = FALSE;
2075 end_testcase_command_set = FALSE;
2076 }
2077
2078 Module_Param* process_config_string2ttcn(const char* mp_str, bool is_component)
2079 {
2080 if (parsed_module_param!=NULL || parsing_error_messages!=NULL) TTCN_error("Internal error: previously parsed ttcn string was not cleared.");
2081 // add the hidden keyword
2082 std::string mp_string = (is_component) ? std::string("$#&&&(#TTCNSTRINGPARSING_COMPONENT$#&&^#% ") + mp_str
2083 : std::string("$#&&&(#TTCNSTRINGPARSING$#&&^#% ") + mp_str;
2084 struct yy_buffer_state *flex_buffer = config_process__scan_bytes(mp_string.c_str(), (int)mp_string.size());
2085 if (flex_buffer == NULL) TTCN_error("Internal error: flex buffer creation failed.");
2086 reset_config_process_lex(NULL);
2087 error_flag = FALSE;
2088 try {
2089 Ttcn_String_Parsing ttcn_string_parsing;
2090 if (config_process_parse()) error_flag = TRUE;
2091 } catch (const TC_Error& TC_error) {
2092 if (parsed_module_param!=NULL) { delete parsed_module_param; parsed_module_param = NULL; }
2093 error_flag = TRUE;
2094 }
2095 config_process_close();
2096 config_process_lex_destroy();
2097
2098 if (error_flag || parsing_error_messages!=NULL) {
2099 delete parsed_module_param;
2100 parsed_module_param = NULL;
2101 char* pem = parsing_error_messages!=NULL ? parsing_error_messages : mcopystr("Unknown parsing error");
2102 parsing_error_messages = NULL;
2103 TTCN_error_begin("%s", pem);
2104 Free(pem);
2105 TTCN_error_end();
2106 return NULL;
2107 } else {
2108 if (parsed_module_param==NULL) TTCN_error("Internal error: could not parse ttcn string.");
2109 Module_Param* ret_val = parsed_module_param;
2110 parsed_module_param = NULL;
2111 return ret_val;
2112 }
2113 }
2114
2115 boolean process_config_string(const char *config_string, int string_len)
2116 {
2117 error_flag = FALSE;
2118
2119 struct yy_buffer_state *flex_buffer =
2120 config_process__scan_bytes(config_string, string_len);
2121 if (flex_buffer == NULL) {
2122 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
2123 "Internal error: flex buffer creation failed.");
2124 return FALSE;
2125 }
2126
2127 try {
2128 reset_configuration_options();
2129 reset_config_process_lex(NULL);
2130 if (config_process_parse()) error_flag = TRUE;
2131
2132 } catch (const TC_Error& TC_error) {
2133 error_flag = TRUE;
2134 }
2135
2136 config_process_close();
2137 config_process_lex_destroy();
2138
2139 return !error_flag;
2140 }
2141
2142
2143 boolean process_config_file(const char *file_name)
2144 {
2145 error_flag = FALSE;
2146 string_chain_t *filenames=NULL;
2147
2148 reset_configuration_options();
2149
2150 if(preproc_parse_file(file_name, &filenames, &config_defines))
2151 error_flag=TRUE;
2152
2153 while(filenames) {
2154 char *fn=string_chain_cut(&filenames);
2155 reset_config_process_lex(fn);
2156 /* The lexer can modify config_process_in
2157 * when it's input buffer is changed */
2158 config_process_in = fopen(fn, "r");
2159 FILE* tmp_cfg = config_process_in;
2160 if (config_process_in != NULL) {
2161 try {
2162 if(config_process_parse()) error_flag=TRUE;
2163 } catch (const TC_Error& TC_error) {
2164 error_flag=TRUE;
2165 }
2166 fclose(tmp_cfg);
2167 config_process_close();
2168 config_process_lex_destroy();
2169 } else {
2170 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2171 TTCN_Logger::log_event("Cannot open configuration file: %s", fn);
2172 TTCN_Logger::OS_error();
2173 TTCN_Logger::end_event();
2174 error_flag=TRUE;
2175 }
2176 /* During parsing flex or libc may use some system calls (e.g. ioctl)
2177 * that fail with an error status. Such error codes shall be ignored in
2178 * future error messages. */
2179 errno = 0;
2180
2181 Free(fn);
2182 }
2183
2184 string_map_free(config_defines);
2185 config_defines = NULL;
2186
2187 return !error_flag;
2188 }
2189
2190 void config_process_error_f(const char *error_str, ...)
2191 {
2192 if (Ttcn_String_Parsing::happening()) {
2193 va_list p_var;
2194 va_start(p_var, error_str);
2195 char* error_msg_str = mprintf_va_list(error_str, p_var);
2196 va_end(p_var);
2197 if (parsing_error_messages!=NULL) parsing_error_messages = mputc(parsing_error_messages, '\n');
2198 parsing_error_messages = mputprintf(parsing_error_messages,
2199 "Parse error in line %d, at or before token `%s': %s", config_process_get_current_line(), config_process_text, error_msg_str);
2200 Free(error_msg_str);
2201 error_flag = TRUE;
2202 return;
2203 }
2204 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2205 if (!get_cfg_process_current_file().empty()) {
2206 TTCN_Logger::log_event("Parse error in configuration file `%s': in line %d, "
2207 "at or before token `%s': ",
2208 get_cfg_process_current_file().c_str(), config_process_get_current_line(),
2209 config_process_text
2210 );
2211 } else {
2212 TTCN_Logger::log_event("Parse error while reading configuration "
2213 "information: in line %d, at or before token `%s': ",
2214 config_process_get_current_line(), config_process_text);
2215 }
2216 va_list pvar;
2217 va_start(pvar, error_str);
2218 TTCN_Logger::log_event_va_list(error_str, pvar);
2219 va_end(pvar);
2220 TTCN_Logger::end_event();
2221 error_flag = TRUE;
2222 }
2223
2224 void config_process_error(const char *error_str)
2225 {
2226 config_process_error_f("%s", error_str);
2227 }
2228
2229 void config_preproc_error(const char *error_str, ...)
2230 {
2231 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2232 TTCN_Logger::log_event("Parse error while pre-processing configuration"
2233 " file `%s': in line %d: ",
2234 get_cfg_preproc_current_file().c_str(),
2235 config_preproc_yylineno);
2236 va_list pvar;
2237 va_start(pvar, error_str);
2238 TTCN_Logger::log_event_va_list(error_str, pvar);
2239 va_end(pvar);
2240 TTCN_Logger::end_event();
2241 error_flag = TRUE;
2242 }
2243
2244 void path_error(const char *fmt, ...)
2245 {
2246 va_list parameters;
2247 fprintf(stderr, "File error: ");
2248 va_start(parameters, fmt);
2249 vfprintf(stderr, fmt, parameters);
2250 va_end(parameters);
2251 fprintf(stderr, "\n");
2252 }
2253
2254 static void check_duplicate_option(const char *section_name,
2255 const char *option_name, boolean& option_flag)
2256 {
2257 if (option_flag) {
2258 TTCN_warning("Option `%s' was given more than once in section [%s] of the "
2259 "configuration file.", option_name, section_name);
2260 } else option_flag = TRUE;
2261 }
2262
2263 static void check_ignored_section(const char *section_name)
2264 {
2265 if (TTCN_Runtime::is_single()) TTCN_warning("Section [%s] of "
2266 "configuration file is ignored in single mode.", section_name);
2267 else config_process_error_f("Internal error: the Main Controller must not "
2268 "send section [%s] of the configuration file.", section_name);
2269 }
2270
2271 static void set_param(Module_Param& param)
2272 {
2273 try {
2274 Module_List::set_param(param);
2275 }
2276 catch (const TC_Error& TC_error) {
2277 error_flag = TRUE;
2278 }
2279 }
2280
2281 unsigned char char_to_hexdigit(char c)
2282 {
2283 if (c >= '0' && c <= '9') return c - '0';
2284 else if (c >= 'A' && c <= 'F') return c - 'A' + 10;
2285 else if (c >= 'a' && c <= 'f') return c - 'a' + 10;
2286 else {
2287 config_process_error_f("char_to_hexdigit(): invalid argument: %c", c);
2288 return 0; // to avoid warning
2289 }
2290 }
This page took 0.078053 seconds and 5 git commands to generate.