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 ******************************************************************************/
17 #include <openssl/bn.h>
19 #include "../common/config_preproc.h"
21 #include "Param_Types.hh"
26 #include "Verdicttype.hh"
27 #include "Bitstring.hh"
28 #include "Hexstring.hh"
29 #include "Octetstring.hh"
30 #include "Charstring.hh"
31 #include "Universal_charstring.hh"
33 #include "Module_list.hh"
37 #include "LoggingBits.hh"
38 #include "LoggingParam.hh"
40 #include "Profiler.hh"
42 #define YYERROR_VERBOSE
44 #include "config_process.lex.hh"
46 extern void reset_config_process_lex(const char* fname);
47 extern void config_process_close();
48 extern int config_process_get_current_line();
49 extern std::string get_cfg_process_current_file();
51 static int config_process_parse();
52 static void check_duplicate_option(const char *section_name,
53 const char *option_name, boolean& option_flag);
54 static void check_ignored_section(const char *section_name);
55 static void set_param(Module_Param& module_param);
56 static unsigned char char_to_hexdigit(char c);
58 static boolean error_flag = FALSE;
60 static Module_Param* parsed_module_param = NULL;
61 static char * parsing_error_messages = NULL;
64 For detecting duplicate entries in the config file. Start out as FALSE,
65 set to TRUE bycheck_duplicate_option().
66 Exception: duplication of parameters that can be component specific is checked
67 by set_xxx(), these start out as TRUE.
69 static boolean file_name_set = FALSE,
71 console_mask_set = TRUE,
72 timestamp_format_set = FALSE,
73 source_info_format_set = FALSE,
74 append_file_set = FALSE,
75 log_event_types_set = FALSE,
76 log_entity_name_set = FALSE,
77 begin_controlpart_command_set = FALSE,
78 end_controlpart_command_set = FALSE,
79 begin_testcase_command_set = FALSE,
80 end_testcase_command_set = FALSE,
81 log_file_size_set = TRUE,
82 log_file_number_set = TRUE,
83 log_disk_full_action_set = TRUE,
84 matching_verbosity_set = FALSE,
85 logger_plugins_set = FALSE,
86 plugin_specific_set = FALSE;
88 int execute_list_len = 0;
89 execute_list_item *execute_list = NULL;
91 string_map_t *config_defines;
99 unsigned int uint_val;
102 param_objid_t objid_val;
103 verdicttype verdict_val;
104 param_bitstring_t bitstring_val;
105 param_hexstring_t hexstring_val;
106 param_charstring_t charstring_val;
107 param_octetstring_t octetstring_val;
108 universal_char universal_char_val;
109 param_universal_charstring_t universal_charstring_val;
110 Module_Param::operation_type_t param_optype_val;
111 Vector<Module_Param*>* module_param_list;
112 Module_Param* module_param_val;
113 Module_Param_Length_Restriction* module_param_length_restriction;
114 Vector<char*>* name_vector;
115 component_id_t comp_id;
116 execute_list_item execute_item_val;
117 TTCN_Logger::emergency_logging_behaviour_t emergency_logging_behaviour_value;
118 TTCN_Logger::timestamp_format_t timestamp_value;
119 TTCN_Logger::source_info_format_t source_info_value;
120 TTCN_Logger::log_event_types_t log_event_types_value;
121 TTCN_Logger::disk_full_action_t disk_full_action_value;
122 TTCN_Logger::matching_verbosity_t matching_verbosity_value;
123 TTCN_Logger::Severity logseverity_val;
124 Logging_Bits logoptions_val;
126 logging_plugin_t *logging_plugins;
127 logging_param_t logging_params;
128 logging_setting_t logging_param_line;
131 %token ModuleParametersKeyword
132 %token LoggingKeyword
133 %token ProfilerKeyword
134 %token TestportParametersKeyword
135 %token ExecuteKeyword
136 %token ExternalCommandsKeyword
138 %token ComponentsKeyword
139 %token MainControllerKeyword
140 %token IncludeKeyword
145 %token ObjIdKeyword "objid"
146 %token CharKeyword "char"
147 %token ControlKeyword "control"
148 %token MTCKeyword "mtc"
149 %token SystemKeyword "system"
150 %token NULLKeyword "NULL"
151 %token nullKeyword "null"
152 %token OmitKeyword "omit"
153 %token ComplementKeyword "complement"
155 %token SupersetKeyword "superset"
156 %token SubsetKeyword "subset"
157 %token PatternKeyword "pattern"
158 %token PermutationKeyword "permutation"
159 %token LengthKeyword "length"
160 %token IfpresentKeyword "ifpresent"
161 %token InfinityKeyword "infinity"
162 %token AssignmentChar ":= or ="
163 %token ConcatChar "&="
164 %token LogFile "LogFile or FileName"
165 %token EmergencyLogging
166 %token EmergencyLoggingBehaviour
167 %token EmergencyLoggingMask
172 %token TimestampFormat
173 %token ConsoleTimestampFormat
174 %token SourceInfoFormat "LogSourceInfo or SourceInfoFormat"
178 %token BeginControlPart
179 %token EndControlPart
182 %token <str_val> Identifier
183 %token <str_val> ASN1LowerIdentifier "ASN.1 identifier beginning with a lowercase letter"
184 %token <int_val> Number MPNumber "integer value"
185 %token <float_val> Float MPFloat "float value"
186 %token <bool_val> BooleanValue "true or false"
187 %token <verdict_val> VerdictValue
188 %token <bitstring_val> Bstring "bit string value"
189 %token <hexstring_val> Hstring "hex string value"
190 %token <octetstring_val> Ostring "octet string value"
191 %token <str_val> BstringMatch "bit string template"
192 %token <str_val> HstringMatch "hex string template"
193 %token <str_val> OstringMatch "octet string template"
194 %token <charstring_val> Cstring MPCstring "charstring value"
195 %token DNSName "hostname"
197 %token <logseverity_val> LoggingBit
198 /* a collection of bits */
199 %token <logseverity_val> LoggingBitCollection
201 %token <emergency_logging_behaviour_value> EmergencyLoggingBehaviourValue "BufferAll or BufferMasked"
202 %token <timestamp_value> TimestampValue "Time, Datetime or Seconds"
203 %token <source_info_value> SourceInfoValue "None, Single or Stack"
204 %token <bool_val> YesNo "yes or no"
209 %token UnixSocketEnabled
210 %token YesToken "yes"
214 %token DiskFullAction
221 %token TtcnStringParsingKeyword
222 %token DisableProfilerKeyword "DisableProfiler"
223 %token DisableCoverageKeyword "DisableCoverage"
224 %token DatabaseFileKeyword "DatabaseFile"
225 %token AggregateDataKeyword "AggregateData"
226 %token StatisticsFileKeyword "StatisticsFile"
227 %token DisableStatisticsKeyword "DisableStatistics"
228 %token StatisticsFilterKeyword "StatisticsFilter"
229 %token StartAutomaticallyKeyword "StartAutomatically"
230 %token NetLineTimesKeyword "NetLineTimes"
231 %token NetFunctionTimesKeyword "NetFunctionTimes"
232 %token <uint_val> ProfilerStatsFlag "profiler statistics filter"
234 %type <int_val> IntegerValue
235 %type <float_val> FloatValue
236 %type <objid_val> ObjIdValue ObjIdComponentList
237 %type <int_val> ObjIdComponent NumberForm NameAndNumberForm
239 %type <universal_charstring_val> UniversalCharstringValue UniversalCharstringFragment
240 %type <universal_char_val> Quadruple
242 %type <str_val> LoggerPluginId
243 %type <logging_plugins> LoggerPlugin LoggerPluginList
244 %type <logging_params> LoggingParam
245 %type <logging_param_line> LoggingParamLines
246 %type <str_val> LogFileName StringValue
247 /* a collection of bits */
248 %type <logoptions_val> LoggingBitmask
249 %type <logoptions_val> LoggingBitOrCollection
250 %type <source_info_value> SourceInfoSetting
251 %type <bool_val> YesNoOrBoolean
252 %type <log_event_types_value> LogEventTypesValue
253 %type <disk_full_action_value> DiskFullActionValue
254 %type <str_val> Command
255 %type <matching_verbosity_value> VerbosityValue
256 %type <comp_id> ComponentId
257 %type <str_val> TestportName ArrayRef TestportParameterName
258 TestportParameterValue
260 %type <execute_item_val> ExecuteItem
262 %type <bitstring_val> BitstringValue
263 %type <hexstring_val> HexstringValue
264 %type <octetstring_val> OctetstringValue
266 %type <name_vector> ParameterName ParameterNameSegment
267 %type <param_optype_val> ParamOpType
268 %type <str_val> FieldName
269 %type <module_param_val> ParameterValue SimpleParameterValue ParameterValueOrNotUsedSymbol
270 FieldValue ArrayItem IndexItem IndexItemList FieldValueList ArrayItemList CompoundValue IntegerRange FloatRange StringRange
271 ParameterExpression ParameterReference
272 %type <module_param_list> TemplateItemList
273 %type <module_param_length_restriction> LengthMatch
274 %type <str_val> PatternChunk
275 %type <int_native> IndexItemIndex LengthBound
276 %type <uint_val> ProfilerStatsFlags
278 %destructor { Free($$); }
287 TestportParameterName
288 TestportParameterValue
294 %destructor { Free($$.components_ptr); }
298 %destructor { Free($$.bits_ptr); }
302 %destructor { Free($$.nibbles_ptr); }
306 %destructor { Free($$.octets_ptr); }
310 %destructor { Free($$.chars_ptr); }
314 %destructor { Free($$.uchars_ptr); }
315 UniversalCharstringFragment
316 UniversalCharstringValue
318 %destructor { if ($$.id_selector == COMPONENT_ID_NAME) Free($$.id_name); }
321 %destructor { Free($$.module_name); Free($$.testcase_name); }
324 %destructor { delete $$; }
333 ParameterValueOrNotUsedSymbol
347 %destructor { delete $$; }
350 %destructor { for(size_t i=0; i<$$->size(); i++) { delete $$->at(i); } delete $$; }
353 %destructor { for(size_t i=0; i<$$->size(); i++) { Free($$->at(i)); } delete $$; }
357 %left '&' /* to avoid shift/reduce conflicts */
366 When seeing a '*' token after a module parameter expression the parser cannot
367 decide whether the token is a multiplication operator (shift) or it refers to
368 all modules in the next module parameter (reduce).
375 if (Ttcn_String_Parsing::happening()) {
376 config_process_error("Config file cannot be parsed as ttcn string");
379 | TtcnStringParsingKeyword ParameterValue
381 parsed_module_param = $2;
391 ModuleParametersSection
394 | TestportParametersSection
396 | ExternalCommandsSection
399 | MainControllerSection
404 ModuleParametersSection:
405 ModuleParametersKeyword ModuleParameters
410 | ModuleParameters ModuleParameter optSemiColon
414 ParameterName ParamOpType ParameterValue
416 Module_Param* mp = $3;
417 mp->set_id(new Module_Param_Name(*$1));
418 mp->set_operation_type($2);
426 ParameterNameSegment { $$ = $1; }
427 | '*' '.' ParameterNameSegment { $$ = $3; }
430 ParameterNameSegment:
431 ParameterNameSegment '.' Identifier
436 | ParameterNameSegment IndexItemIndex
439 $$->push_back(mprintf("%d", $2));
443 $$ = new Vector<char*>();
453 | ParameterExpression LengthMatch
456 $$->set_length_restriction($2);
458 | ParameterExpression IfpresentKeyword
463 | ParameterExpression LengthMatch IfpresentKeyword
466 $$->set_length_restriction($2);
472 LengthKeyword '(' LengthBound ')'
474 $$ = new Module_Param_Length_Restriction();
475 $$->set_single((size_t)$3);
477 | LengthKeyword '(' LengthBound DotDot LengthBound ')'
480 config_process_error("invalid length restriction: lower bound > upper bound");
482 $$ = new Module_Param_Length_Restriction();
483 $$->set_min((size_t)$3);
484 $$->set_max((size_t)$5);
486 | LengthKeyword '(' LengthBound DotDot InfinityKeyword ')'
488 $$ = new Module_Param_Length_Restriction();
489 $$->set_min((size_t)$3);
496 $1->set_id(new Module_Param_CustomName(mcopystr("length bound")));
499 if (!tmp.get_val().is_native()) {
500 config_process_error("bignum length restriction bound.");
502 } else if (tmp.get_val().is_negative()) {
503 config_process_error("negative length restriction bound.");
512 // one global rule for expressions in module parameters
513 // the expression's result will be calculated by set_param()
515 SimpleParameterValue { $$ = $1; }
516 | ParameterReference { $$ = $1; }
517 | '(' ParameterExpression ')' { $$ = $2; }
518 | '+' ParameterExpression %prec UnarySign { $$ = $2; }
519 | '-' ParameterExpression %prec UnarySign { $$ = new Module_Param_Expression($2); }
520 | ParameterExpression '+' ParameterExpression
522 $$ = new Module_Param_Expression(Module_Param::EXPR_ADD, $1, $3);
524 | ParameterExpression '-' ParameterExpression
526 $$ = new Module_Param_Expression(Module_Param::EXPR_SUBTRACT, $1, $3);
528 | ParameterExpression '*' ParameterExpression
530 $$ = new Module_Param_Expression(Module_Param::EXPR_MULTIPLY, $1, $3);
532 | ParameterExpression '/' ParameterExpression
534 $$ = new Module_Param_Expression(Module_Param::EXPR_DIVIDE, $1, $3);
536 | ParameterExpression '&' ParameterExpression
538 $$ = new Module_Param_Expression(Module_Param::EXPR_CONCATENATE, $1, $3);
543 // enumerated values are also treated as references by the parser,
544 // these will be sorted out later during set_param()
547 $$ = new Module_Param_Reference(new Module_Param_Name(*$1));
551 SimpleParameterValue:
554 $$ = new Module_Param_Integer($1);
558 $$ = new Module_Param_Float($1);
562 $$ = new Module_Param_Boolean($1);
566 $$ = new Module_Param_Objid($1.n_components, $1.components_ptr);
570 $$ = new Module_Param_Verdict($1);
574 $$ = new Module_Param_Bitstring($1.n_bits, $1.bits_ptr);
578 $$ = new Module_Param_Hexstring($1.n_nibbles, $1.nibbles_ptr);
582 $$ = new Module_Param_Octetstring($1.n_octets, $1.octets_ptr);
586 $$ = new Module_Param_Charstring($1.n_chars, $1.chars_ptr);
588 | UniversalCharstringValue
590 $$ = new Module_Param_Universal_Charstring($1.n_uchars, $1.uchars_ptr);
594 $$ = new Module_Param_Omit();
598 $$ = new Module_Param_Asn_Null();
602 $$ = new Module_Param_Ttcn_Null();
606 $$ = new Module_Param_Ttcn_mtc();
610 $$ = new Module_Param_Ttcn_system();
614 $$ = new Module_Param_Any();
618 $$ = new Module_Param_AnyOrNone();
632 | PatternKeyword PatternChunk
634 $$ = new Module_Param_Pattern($2);
639 int n_chars = (int)mstrlen($1);
640 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
641 for (int i=0; i<n_chars; i++) {
657 config_process_error_f("Invalid char (%c) in bitstring template", $1[i]);
661 $$ = new Module_Param_Bitstring_Template(n_chars, chars_ptr);
665 int n_chars = (int)mstrlen($1);
666 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
667 for (int i=0; i<n_chars; i++) {
668 if ($1[i]=='?') chars_ptr[i] = 16;
669 else if ($1[i]=='*') chars_ptr[i] = 17;
670 else chars_ptr[i] = char_to_hexdigit($1[i]);
673 $$ = new Module_Param_Hexstring_Template(n_chars, chars_ptr);
677 Vector<unsigned short> octet_vec;
678 int str_len = (int)mstrlen($1);
679 for (int i=0; i<str_len; i++) {
681 if ($1[i]=='?') num = 256;
682 else if ($1[i]=='*') num = 257;
685 num = 16 * char_to_hexdigit($1[i]);
687 if (i>=str_len) config_process_error("Unexpected end of octetstring pattern");
689 num += char_to_hexdigit($1[i]);
691 octet_vec.push_back(num);
694 int n_chars = (int)octet_vec.size();
695 unsigned short* chars_ptr = (unsigned short*)Malloc(n_chars*sizeof(unsigned short));
696 for (int i=0; i<n_chars; i++) chars_ptr[i] = octet_vec[i];
697 $$ = new Module_Param_Octetstring_Template(n_chars, chars_ptr);
708 $$ = mcopystr($1.chars_ptr);
713 $$ = mprintf("\\q{%d,%d,%d,%d}", $1.uc_group, $1.uc_plane, $1.uc_row, $1.uc_cell);
718 '(' '-' InfinityKeyword DotDot MPNumber ')'
720 $$ = new Module_Param_IntRange(NULL, $5);
722 | '(' MPNumber DotDot MPNumber ')'
724 $$ = new Module_Param_IntRange($2, $4);
726 | '(' MPNumber DotDot InfinityKeyword ')'
728 $$ = new Module_Param_IntRange($2, NULL);
733 '(' '-' InfinityKeyword DotDot MPFloat ')'
735 $$ = new Module_Param_FloatRange(0.0, false, $5, true);
737 | '(' MPFloat DotDot MPFloat ')'
739 $$ = new Module_Param_FloatRange($2, true, $4, true);
741 | '(' MPFloat DotDot InfinityKeyword ')'
743 $$ = new Module_Param_FloatRange($2, true, 0.0, false);
748 '(' UniversalCharstringFragment DotDot UniversalCharstringFragment ')'
750 universal_char lower; lower.uc_group=lower.uc_plane=lower.uc_row=lower.uc_cell=0;
751 universal_char upper; upper.uc_group=upper.uc_plane=upper.uc_row=upper.uc_cell=0;
752 if ($2.n_uchars!=1) {
753 config_process_error("Lower bound of char range must be 1 character only");
754 } else if ($4.n_uchars!=1) {
755 config_process_error("Upper bound of char range must be 1 character only");
757 lower = *($2.uchars_ptr);
758 upper = *($4.uchars_ptr);
760 config_process_error("Lower bound is larger than upper bound in the char range");
766 $$ = new Module_Param_StringRange(lower, upper);
770 // integers outside of the [MODULE_PARAMETERS] section
773 | '(' IntegerValue ')' { $$ = $2; }
774 | '+' IntegerValue %prec UnarySign { $$ = $2; }
775 | '-' IntegerValue %prec UnarySign
779 $$ = new int_val_t((-op1).get_val());
782 | IntegerValue '+' IntegerValue
787 $$ = new int_val_t((op1 + op2).get_val());
791 | IntegerValue '-' IntegerValue
796 $$ = new int_val_t((op1 - op2).get_val());
800 | IntegerValue '*' IntegerValue
805 $$ = new int_val_t((op1 * op2).get_val());
809 | IntegerValue '/' IntegerValue
812 config_process_error("Integer division by zero.");
813 $$ = new int_val_t((RInt)0);
820 $$ = new int_val_t((op1 / op2).get_val());
827 // floats outside of the [MODULE_PARAMETERS] section
830 | '(' FloatValue ')' { $$ = $2; }
831 | '+' FloatValue %prec UnarySign { $$ = $2; }
832 | '-' FloatValue %prec UnarySign { $$ = -$2; }
833 | FloatValue '+' FloatValue { $$ = $1 + $3; }
834 | FloatValue '-' FloatValue { $$ = $1 - $3; }
835 | FloatValue '*' FloatValue { $$ = $1 * $3; }
836 | FloatValue '/' FloatValue
839 config_process_error("Floating point division by zero.");
846 ObjIdKeyword '{' ObjIdComponentList '}' { $$ = $3; }
853 $$.components_ptr = (int *)Malloc(sizeof(int));
854 $$.components_ptr[0] = $1->get_val();
857 | ObjIdComponentList ObjIdComponent
859 $$.n_components = $1.n_components + 1;
860 $$.components_ptr = (int *)Realloc($1.components_ptr,
861 $$.n_components * sizeof(int));
862 $$.components_ptr[$$.n_components - 1] = $2->get_val();
868 NumberForm { $$ = $1; }
869 | NameAndNumberForm { $$ = $1; }
873 MPNumber { $$ = $1; }
877 Identifier '(' MPNumber ')'
896 UniversalCharstringValue:
900 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
901 $$.uchars_ptr[0] = $1;
905 UniversalCharstringFragment:
908 $$.n_uchars = $1.n_chars;
909 $$.uchars_ptr = (universal_char*)
910 Malloc($$.n_uchars * sizeof(universal_char));
911 for (int i = 0; i < $1.n_chars; i++) {
912 $$.uchars_ptr[i].uc_group = 0;
913 $$.uchars_ptr[i].uc_plane = 0;
914 $$.uchars_ptr[i].uc_row = 0;
915 $$.uchars_ptr[i].uc_cell = $1.chars_ptr[i];
922 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
923 $$.uchars_ptr[0] = $1;
928 CharKeyword '(' ParameterExpression ',' ParameterExpression ','
929 ParameterExpression ',' ParameterExpression ')'
931 $3->set_id(new Module_Param_CustomName(mcopystr("quadruple group")));
932 $5->set_id(new Module_Param_CustomName(mcopystr("quadruple plane")));
933 $7->set_id(new Module_Param_CustomName(mcopystr("quadruple row")));
934 $9->set_id(new Module_Param_CustomName(mcopystr("quadruple cell")));
940 if (g < 0 || g > 127) {
941 char *s = g.get_val().as_string();
942 config_process_error_f("The first number of quadruple (group) must be "
943 "within the range 0 .. 127 instead of %s.", s);
945 $$.uc_group = g < 0 ? 0 : 127;
949 if (p < 0 || p > 255) {
950 char *s = p.get_val().as_string();
951 config_process_error_f("The second number of quadruple (plane) must be "
952 "within the range 0 .. 255 instead of %s.", s);
954 $$.uc_plane = p < 0 ? 0 : 255;
958 if (r < 0 || r > 255) {
959 char *s = r.get_val().as_string();
960 config_process_error_f("The third number of quadruple (row) must be "
961 "within the range 0 .. 255 instead of %s.", s);
963 $$.uc_row = r < 0 ? 0 : 255;
967 if (c < 0 || c > 255) {
968 char *s = c.get_val().as_string();
969 config_process_error_f("The fourth number of quadruple (cell) must be "
970 "within the range 0 .. 255 instead of %s.", s);
972 $$.uc_cell = c < 0 ? 0 : 255;
983 // character strings outside of the [MODULE_PARAMETERS] section
987 $$ = mcopystr($1.chars_ptr);
990 | StringValue '&' Cstring
992 $$ = mputstr($1, $3.chars_ptr);
1000 $$ = new Module_Param_Value_List();
1002 | '{' FieldValueList '}'
1006 | '{' ArrayItemList '}'
1010 | '{' IndexItemList '}'
1014 | '(' ParameterValue ',' TemplateItemList ')' /* at least 2 elements to avoid shift/reduce conflicts with the ParameterExpression rule */
1016 $$ = new Module_Param_List_Template();
1017 $2->set_id(new Module_Param_Index($$->get_size(),false));
1019 $$->add_list_with_implicit_ids($4);
1022 | ComplementKeyword '(' TemplateItemList ')'
1024 $$ = new Module_Param_ComplementList_Template();
1025 $$->add_list_with_implicit_ids($3);
1028 | SupersetKeyword '(' TemplateItemList ')'
1030 $$ = new Module_Param_Superset_Template();
1031 $$->add_list_with_implicit_ids($3);
1034 | SubsetKeyword '(' TemplateItemList ')'
1036 $$ = new Module_Param_Subset_Template();
1037 $$->add_list_with_implicit_ids($3);
1042 ParameterValueOrNotUsedSymbol:
1049 $$ = new Module_Param_NotUsed();
1056 $$ = new Vector<Module_Param*>();
1059 | TemplateItemList ',' ParameterValue
1069 $$ = new Module_Param_Assignment_List();
1072 | FieldValueList ',' FieldValue
1080 FieldName AssignmentChar ParameterValueOrNotUsedSymbol
1083 $$->set_id(new Module_Param_FieldName($1));
1092 | ASN1LowerIdentifier
1101 $$ = new Module_Param_Value_List();
1102 $1->set_id(new Module_Param_Index($$->get_size(),false));
1105 | ArrayItemList ',' ArrayItem
1108 $3->set_id(new Module_Param_Index($$->get_size(),false));
1114 ParameterValueOrNotUsedSymbol
1118 | PermutationKeyword '(' TemplateItemList ')'
1120 $$ = new Module_Param_Permutation_Template();
1121 $$->add_list_with_implicit_ids($3);
1129 $$ = new Module_Param_Indexed_List();
1132 | IndexItemList ',' IndexItem
1140 IndexItemIndex AssignmentChar ParameterValue
1143 $$->set_id(new Module_Param_Index((size_t)$1,true));
1148 '[' ParameterExpression ']'
1150 $2->set_id(new Module_Param_CustomName(mcopystr("array index")));
1153 if (!tmp.get_val().is_native()) {
1154 config_process_error("bignum index."); // todo
1156 if (tmp.get_val().is_negative()) {
1157 config_process_error("negative index."); // todo
1164 /*************** [LOGGING] section *********************************/
1167 LoggingKeyword LoggingParamList
1172 | LoggingParamList LoggingParamLines optSemiColon
1174 // Centralized duplication handling for `[LOGGING]'.
1175 if ($2.logparam.log_param_selection != LP_UNKNOWN && TTCN_Logger::add_parameter($2)) {
1176 switch ($2.logparam.log_param_selection) {
1178 check_duplicate_option("LOGGING", "FileMask", file_mask_set);
1180 case LP_CONSOLEMASK:
1181 check_duplicate_option("LOGGING", "ConsoleMask", console_mask_set);
1183 case LP_LOGFILESIZE:
1184 check_duplicate_option("LOGGING", "LogFileSize", log_file_size_set);
1186 case LP_LOGFILENUMBER:
1187 check_duplicate_option("LOGGING", "LogFileNumber", log_file_number_set);
1189 case LP_DISKFULLACTION:
1190 check_duplicate_option("LOGGING", "DiskFullAction", log_disk_full_action_set);
1193 check_duplicate_option("LOGGING", "LogFile", file_name_set);
1195 case LP_TIMESTAMPFORMAT:
1196 check_duplicate_option("LOGGING", "TimeStampFormat", timestamp_format_set);
1198 case LP_SOURCEINFOFORMAT:
1199 check_duplicate_option("LOGGING", "SourceInfoFormat", source_info_format_set);
1202 check_duplicate_option("LOGGING", "AppendFile", append_file_set);
1204 case LP_LOGEVENTTYPES:
1205 check_duplicate_option("LOGGING", "LogEventTypes", log_event_types_set);
1207 case LP_LOGENTITYNAME:
1208 check_duplicate_option("LOGGING", "LogEntityName", log_entity_name_set);
1210 case LP_MATCHINGHINTS:
1211 check_duplicate_option("LOGGING", "MatchingVerbosity", matching_verbosity_set);
1213 case LP_PLUGIN_SPECIFIC:
1214 // It would be an overkill to check for the infinite number of custom parameters...
1215 check_duplicate_option("LOGGING", "PluginSpecific", plugin_specific_set);
1227 $$.component.id_selector = COMPONENT_ID_ALL;
1228 $$.component.id_name = NULL;
1229 $$.plugin_id = NULL;
1232 | ComponentId '.' LoggingParam
1235 $$.plugin_id = NULL;
1238 | ComponentId '.' LoggerPluginId '.' LoggingParam
1244 | LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1246 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1247 component_id_t comp;
1248 comp.id_selector = COMPONENT_ID_ALL;
1249 comp.id_name = NULL;
1250 logging_plugin_t *plugin = $4;
1251 while (plugin != NULL) {
1252 // `identifier' and `filename' are reused. Various checks and
1253 // validations must be done in the logger itself (e.g. looking for
1254 // duplicate options).
1255 TTCN_Logger::register_plugin(comp, plugin->identifier, plugin->filename);
1256 logging_plugin_t *tmp = plugin;
1260 $$.logparam.log_param_selection = LP_UNKNOWN;
1262 | ComponentId '.' LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1264 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1265 logging_plugin_t *plugin = $6;
1266 while (plugin != NULL) {
1267 TTCN_Logger::register_plugin($1, plugin->identifier, plugin->filename);
1268 logging_plugin_t *tmp = plugin;
1272 // Component names shall be duplicated in `register_plugin()'.
1273 if ($1.id_selector == COMPONENT_ID_NAME)
1275 $$.logparam.log_param_selection = LP_UNKNOWN;
1284 | LoggerPluginList ',' LoggerPlugin
1294 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1295 $$->identifier = $1;
1296 $$->filename = NULL;
1299 | Identifier AssignmentChar StringValue
1301 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1302 $$->identifier = $1;
1309 '*' { $$ = mcopystr("*"); }
1310 | Identifier { $$ = $1; }
1314 FileMask AssignmentChar LoggingBitmask
1316 $$.log_param_selection = LP_FILEMASK;
1317 $$.logoptions_val = $3;
1319 | ConsoleMask AssignmentChar LoggingBitmask
1321 $$.log_param_selection = LP_CONSOLEMASK;
1322 $$.logoptions_val = $3;
1324 | LogFileSize AssignmentChar Number
1326 $$.log_param_selection = LP_LOGFILESIZE;
1327 $$.int_val = (int)$3->get_val();
1330 | EmergencyLogging AssignmentChar Number
1332 $$.log_param_selection = LP_EMERGENCY;
1333 $$.int_val = (int)$3->get_val();
1336 | EmergencyLoggingBehaviour AssignmentChar EmergencyLoggingBehaviourValue
1338 $$.log_param_selection = LP_EMERGENCYBEHAVIOR;
1339 $$.emergency_logging_behaviour_value = $3;
1341 | EmergencyLoggingMask AssignmentChar LoggingBitmask
1343 $$.log_param_selection = LP_EMERGENCYMASK;
1344 $$.logoptions_val = $3;
1346 | LogFileNumber AssignmentChar Number
1348 $$.log_param_selection = LP_LOGFILENUMBER;
1349 $$.int_val = (int)$3->get_val();
1352 | DiskFullAction AssignmentChar DiskFullActionValue
1354 $$.log_param_selection = LP_DISKFULLACTION;
1355 $$.disk_full_action_value = $3;
1357 | LogFile AssignmentChar LogFileName
1359 $$.log_param_selection = LP_LOGFILE;
1362 | TimestampFormat AssignmentChar TimestampValue
1364 $$.log_param_selection = LP_TIMESTAMPFORMAT;
1365 $$.timestamp_value = $3;
1367 | ConsoleTimestampFormat AssignmentChar TimestampValue
1369 $$.log_param_selection = LP_UNKNOWN;
1371 | SourceInfoFormat AssignmentChar SourceInfoSetting
1373 $$.log_param_selection = LP_SOURCEINFOFORMAT;
1374 $$.source_info_value = $3;
1376 | AppendFile AssignmentChar YesNoOrBoolean
1378 $$.log_param_selection = LP_APPENDFILE;
1381 | LogEventTypes AssignmentChar LogEventTypesValue
1383 $$.log_param_selection = LP_LOGEVENTTYPES;
1384 $$.log_event_types_value = $3;
1386 | LogEntityName AssignmentChar YesNoOrBoolean
1388 $$.log_param_selection = LP_LOGENTITYNAME;
1391 | MatchingHints AssignmentChar VerbosityValue
1393 $$.log_param_selection = LP_MATCHINGHINTS;
1394 $$.matching_verbosity_value = $3;
1396 | Identifier AssignmentChar StringValue
1398 $$.log_param_selection = LP_PLUGIN_SPECIFIC;
1405 Compact { $$ = TTCN_Logger::VERBOSITY_COMPACT; }
1406 | Detailed { $$ = TTCN_Logger::VERBOSITY_FULL; }
1409 DiskFullActionValue:
1410 Error { $$.type = TTCN_Logger::DISKFULL_ERROR; }
1411 | Stop { $$.type = TTCN_Logger::DISKFULL_STOP; }
1414 $$.type = TTCN_Logger::DISKFULL_RETRY;
1415 $$.retry_interval = 30; /* default retry interval */
1417 | Retry '(' Number ')'
1419 $$.type = TTCN_Logger::DISKFULL_RETRY;
1420 $$.retry_interval = (size_t)$3->get_val();
1423 | Delete { $$.type = TTCN_Logger::DISKFULL_DELETE; }
1427 StringValue { $$ = $1; }
1430 LoggingBitOrCollection:
1436 | LoggingBitCollection
1441 case TTCN_Logger::ACTION_UNQUALIFIED:
1442 $$.add_sev(TTCN_Logger::ACTION_UNQUALIFIED);
1444 case TTCN_Logger::DEFAULTOP_UNQUALIFIED:
1445 $$.add_sev(TTCN_Logger::DEFAULTOP_ACTIVATE);
1446 $$.add_sev(TTCN_Logger::DEFAULTOP_DEACTIVATE);
1447 $$.add_sev(TTCN_Logger::DEFAULTOP_EXIT);
1448 $$.add_sev(TTCN_Logger::DEFAULTOP_UNQUALIFIED);
1450 case TTCN_Logger::ERROR_UNQUALIFIED:
1451 $$.add_sev(TTCN_Logger::ERROR_UNQUALIFIED);
1453 case TTCN_Logger::EXECUTOR_UNQUALIFIED:
1454 $$.add_sev(TTCN_Logger::EXECUTOR_RUNTIME);
1455 $$.add_sev(TTCN_Logger::EXECUTOR_CONFIGDATA);
1456 $$.add_sev(TTCN_Logger::EXECUTOR_EXTCOMMAND);
1457 $$.add_sev(TTCN_Logger::EXECUTOR_COMPONENT);
1458 $$.add_sev(TTCN_Logger::EXECUTOR_LOGOPTIONS);
1459 $$.add_sev(TTCN_Logger::EXECUTOR_UNQUALIFIED);
1461 case TTCN_Logger::FUNCTION_UNQUALIFIED:
1462 $$.add_sev(TTCN_Logger::FUNCTION_RND);
1463 $$.add_sev(TTCN_Logger::FUNCTION_UNQUALIFIED);
1465 case TTCN_Logger::PARALLEL_UNQUALIFIED:
1466 $$.add_sev(TTCN_Logger::PARALLEL_PTC);
1467 $$.add_sev(TTCN_Logger::PARALLEL_PORTCONN);
1468 $$.add_sev(TTCN_Logger::PARALLEL_PORTMAP);
1469 $$.add_sev(TTCN_Logger::PARALLEL_UNQUALIFIED);
1471 case TTCN_Logger::PORTEVENT_UNQUALIFIED:
1472 $$.add_sev(TTCN_Logger::PORTEVENT_PQUEUE);
1473 $$.add_sev(TTCN_Logger::PORTEVENT_MQUEUE);
1474 $$.add_sev(TTCN_Logger::PORTEVENT_STATE);
1475 $$.add_sev(TTCN_Logger::PORTEVENT_PMIN);
1476 $$.add_sev(TTCN_Logger::PORTEVENT_PMOUT);
1477 $$.add_sev(TTCN_Logger::PORTEVENT_PCIN);
1478 $$.add_sev(TTCN_Logger::PORTEVENT_PCOUT);
1479 $$.add_sev(TTCN_Logger::PORTEVENT_MMRECV);
1480 $$.add_sev(TTCN_Logger::PORTEVENT_MMSEND);
1481 $$.add_sev(TTCN_Logger::PORTEVENT_MCRECV);
1482 $$.add_sev(TTCN_Logger::PORTEVENT_MCSEND);
1483 $$.add_sev(TTCN_Logger::PORTEVENT_DUALRECV);
1484 $$.add_sev(TTCN_Logger::PORTEVENT_DUALSEND);
1485 $$.add_sev(TTCN_Logger::PORTEVENT_UNQUALIFIED);
1487 case TTCN_Logger::TESTCASE_UNQUALIFIED:
1488 $$.add_sev(TTCN_Logger::TESTCASE_START);
1489 $$.add_sev(TTCN_Logger::TESTCASE_FINISH);
1490 $$.add_sev(TTCN_Logger::TESTCASE_UNQUALIFIED);
1492 case TTCN_Logger::TIMEROP_UNQUALIFIED:
1493 $$.add_sev(TTCN_Logger::TIMEROP_READ);
1494 $$.add_sev(TTCN_Logger::TIMEROP_START);
1495 $$.add_sev(TTCN_Logger::TIMEROP_GUARD);
1496 $$.add_sev(TTCN_Logger::TIMEROP_STOP);
1497 $$.add_sev(TTCN_Logger::TIMEROP_TIMEOUT);
1498 $$.add_sev(TTCN_Logger::TIMEROP_UNQUALIFIED);
1500 case TTCN_Logger::USER_UNQUALIFIED:
1501 $$.add_sev(TTCN_Logger::USER_UNQUALIFIED);
1503 case TTCN_Logger::STATISTICS_UNQUALIFIED:
1504 $$.add_sev(TTCN_Logger::STATISTICS_VERDICT);
1505 $$.add_sev(TTCN_Logger::STATISTICS_UNQUALIFIED);
1507 case TTCN_Logger::VERDICTOP_UNQUALIFIED:
1508 $$.add_sev(TTCN_Logger::VERDICTOP_GETVERDICT);
1509 $$.add_sev(TTCN_Logger::VERDICTOP_SETVERDICT);
1510 $$.add_sev(TTCN_Logger::VERDICTOP_FINAL);
1511 $$.add_sev(TTCN_Logger::VERDICTOP_UNQUALIFIED);
1513 case TTCN_Logger::WARNING_UNQUALIFIED:
1514 $$.add_sev(TTCN_Logger::WARNING_UNQUALIFIED);
1516 case TTCN_Logger::MATCHING_UNQUALIFIED:
1517 $$.add_sev(TTCN_Logger::MATCHING_DONE);
1518 $$.add_sev(TTCN_Logger::MATCHING_TIMEOUT);
1519 $$.add_sev(TTCN_Logger::MATCHING_PCSUCCESS);
1520 $$.add_sev(TTCN_Logger::MATCHING_PCUNSUCC);
1521 $$.add_sev(TTCN_Logger::MATCHING_PMSUCCESS);
1522 $$.add_sev(TTCN_Logger::MATCHING_PMUNSUCC);
1523 $$.add_sev(TTCN_Logger::MATCHING_MCSUCCESS);
1524 $$.add_sev(TTCN_Logger::MATCHING_MCUNSUCC);
1525 $$.add_sev(TTCN_Logger::MATCHING_MMSUCCESS);
1526 $$.add_sev(TTCN_Logger::MATCHING_MMUNSUCC);
1527 $$.add_sev(TTCN_Logger::MATCHING_PROBLEM);
1528 $$.add_sev(TTCN_Logger::MATCHING_UNQUALIFIED);
1530 case TTCN_Logger::DEBUG_UNQUALIFIED:
1531 $$.add_sev(TTCN_Logger::DEBUG_ENCDEC);
1532 $$.add_sev(TTCN_Logger::DEBUG_TESTPORT);
1533 $$.add_sev(TTCN_Logger::DEBUG_USER);
1534 $$.add_sev(TTCN_Logger::DEBUG_FRAMEWORK);
1535 $$.add_sev(TTCN_Logger::DEBUG_UNQUALIFIED);
1537 case TTCN_Logger::LOG_ALL_IMPORTANT:
1538 $$ = Logging_Bits::log_all;
1541 /* The lexer sent something the parser doesn't understand!
1542 Parser needs to be updated.
1544 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
1545 "Internal error: unknown logbit from lexer.");
1552 LoggingBitOrCollection
1556 | LoggingBitmask '|' LoggingBitOrCollection
1564 SourceInfoValue { $$ = $1; }
1567 $$ = $1 ? TTCN_Logger::SINFO_SINGLE : TTCN_Logger::SINFO_NONE;
1573 | BooleanValue { $$ = $1; }
1577 YesNoOrBoolean { $$ = $1 ? TTCN_Logger::LOGEVENTTYPES_YES :
1578 TTCN_Logger::LOGEVENTTYPES_NO; }
1579 | SubCategories { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1580 | Detailed { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1583 /*********************** [PROFILER] ********************************/
1586 ProfilerKeyword ProfilerSettings
1591 | ProfilerSettings ProfilerSetting optSemiColon
1595 DisableProfilerSetting
1596 | DisableCoverageSetting
1597 | DatabaseFileSetting
1598 | AggregateDataSetting
1599 | StatisticsFileSetting
1600 | DisableStatisticsSetting
1601 | StatisticsFilterSetting
1602 | StartAutomaticallySetting
1603 | NetLineTimesSetting
1604 | NetFunctionTimesSetting
1607 DisableProfilerSetting:
1608 DisableProfilerKeyword AssignmentChar BooleanValue {
1609 ttcn3_prof.set_disable_profiler($3);
1613 DisableCoverageSetting:
1614 DisableCoverageKeyword AssignmentChar BooleanValue {
1615 ttcn3_prof.set_disable_coverage($3);
1619 DatabaseFileSetting:
1620 DatabaseFileKeyword AssignmentChar StringValue {
1621 ttcn3_prof.set_database_filename($3);
1625 AggregateDataSetting:
1626 AggregateDataKeyword AssignmentChar BooleanValue {
1627 ttcn3_prof.set_aggregate_data($3);
1631 StatisticsFileSetting:
1632 StatisticsFileKeyword AssignmentChar StringValue {
1633 ttcn3_prof.set_stats_filename($3);
1637 DisableStatisticsSetting:
1638 DisableStatisticsKeyword AssignmentChar BooleanValue {
1639 ttcn3_prof.set_disable_stats($3);
1643 StatisticsFilterSetting:
1644 StatisticsFilterKeyword AssignmentChar ProfilerStatsFlags {
1645 ttcn3_prof.reset_stats_flags();
1646 ttcn3_prof.add_stats_flags($3);
1648 | StatisticsFilterKeyword ConcatChar ProfilerStatsFlags {
1649 ttcn3_prof.add_stats_flags($3);
1654 ProfilerStatsFlag { $$ = $1; }
1655 | ProfilerStatsFlag '&' ProfilerStatsFlags { $$ = $1 | $3; }
1656 | ProfilerStatsFlag '|' ProfilerStatsFlags { $$ = $1 | $3; }
1659 StartAutomaticallySetting:
1660 StartAutomaticallyKeyword AssignmentChar BooleanValue {
1670 NetLineTimesSetting:
1671 NetLineTimesKeyword AssignmentChar BooleanValue {
1672 TTCN3_Stack_Depth::set_net_line_times($3);
1676 NetFunctionTimesSetting:
1677 NetFunctionTimesKeyword AssignmentChar BooleanValue {
1678 TTCN3_Stack_Depth::set_net_func_times($3);
1683 /**************** [TESTPORT_PARAMETERS] ****************************/
1685 TestportParametersSection:
1686 TestportParametersKeyword TestportParameterList
1689 TestportParameterList:
1691 | TestportParameterList TestportParameter optSemiColon
1695 ComponentId '.' TestportName '.' TestportParameterName AssignmentChar
1696 TestportParameterValue
1698 PORT::add_parameter($1, $3, $5, $7);
1699 if ($1.id_selector == COMPONENT_ID_NAME) Free($1.id_name);
1709 $$.id_selector = COMPONENT_ID_NAME;
1714 $$.id_selector = COMPONENT_ID_NAME;
1715 $$.id_name = $1.chars_ptr;
1719 $$.id_selector = COMPONENT_ID_COMPREF;
1720 $$.id_compref = (component)$1->get_val();
1725 $$.id_selector = COMPONENT_ID_COMPREF;
1726 $$.id_compref = MTC_COMPREF;
1730 $$.id_selector = COMPONENT_ID_ALL;
1735 $$.id_selector = COMPONENT_ID_SYSTEM;
1741 Identifier { $$ = $1; }
1742 | Identifier ArrayRef
1744 $$ = mputstr($1, $2);
1747 | '*' { $$ = NULL; }
1751 '[' IntegerValue ']'
1753 char *s = $2->as_string();
1755 $$ = mputc ($$, '[');
1756 $$ = mputstr($$, s);
1757 $$ = mputc ($$, ']');
1761 | ArrayRef '[' IntegerValue ']'
1763 char *s = $3->as_string();
1764 $$ = mputc ($1, '[');
1765 $$ = mputstr($$, s);
1766 $$ = mputc ($$, ']');
1772 TestportParameterName:
1773 Identifier { $$ = $1; }
1776 TestportParameterValue:
1777 StringValue { $$ = $1; }
1780 /****************** [EXECUTE] section *************/
1783 ExecuteKeyword ExecuteList
1785 if (!TTCN_Runtime::is_single()) config_process_error("Internal error: "
1786 "the Main Controller must not send section [EXECUTE] of the "
1787 "configuration file.");
1793 | ExecuteList ExecuteItem optSemiColon
1795 if (TTCN_Runtime::is_single()) {
1796 execute_list = (execute_list_item *)Realloc(
1797 execute_list, (execute_list_len + 1) *
1798 sizeof(*execute_list));
1799 execute_list[execute_list_len++] = $2;
1801 Free($2.module_name);
1802 Free($2.testcase_name);
1810 $$.module_name = $1;
1811 $$.testcase_name = NULL;
1813 | Identifier '.' ControlKeyword
1815 $$.module_name = $1;
1816 $$.testcase_name = NULL;
1818 | Identifier '.' Identifier
1820 $$.module_name = $1;
1821 $$.testcase_name = $3;
1823 | Identifier '.' '*'
1825 $$.module_name = $1;
1826 $$.testcase_name = mcopystr("*");
1830 /****************** [EXTERNAL_COMMANDS] section **********************/
1832 ExternalCommandsSection:
1833 ExternalCommandsKeyword ExternalCommandList
1836 ExternalCommandList:
1838 | ExternalCommandList ExternalCommand optSemiColon
1842 BeginControlPart AssignmentChar Command
1844 check_duplicate_option("EXTERNAL_COMMANDS", "BeginControlPart",
1845 begin_controlpart_command_set);
1847 TTCN_Runtime::set_begin_controlpart_command($3);
1851 | EndControlPart AssignmentChar Command
1853 check_duplicate_option("EXTERNAL_COMMANDS", "EndControlPart",
1854 end_controlpart_command_set);
1856 TTCN_Runtime::set_end_controlpart_command($3);
1860 | BeginTestCase AssignmentChar Command
1862 check_duplicate_option("EXTERNAL_COMMANDS", "BeginTestCase",
1863 begin_testcase_command_set);
1865 TTCN_Runtime::set_begin_testcase_command($3);
1869 | EndTestCase AssignmentChar Command
1871 check_duplicate_option("EXTERNAL_COMMANDS", "EndTestCase",
1872 end_testcase_command_set);
1874 TTCN_Runtime::set_end_testcase_command($3);
1881 StringValue { $$ = $1; }
1884 /***************** [GROUPS] section *******************/
1887 GroupsKeyword GroupList
1889 check_ignored_section("GROUPS");
1895 | GroupList Group optSemiColon
1899 GroupName AssignmentChar GroupMembers
1903 Identifier { Free($1); }
1913 | seqGroupMember ',' HostName
1918 | Identifier { Free($1); }
1921 /******************** [COMPONENTS] section *******************/
1923 ComponentsKeyword ComponentList
1925 check_ignored_section("COMPONENTS");
1931 | ComponentList ComponentItem optSemiColon
1935 ComponentName AssignmentChar ComponentLocation
1939 Identifier { Free($1); }
1944 Identifier { Free($1); }
1948 /****************** [MAIN_CONTROLLER] section *********************/
1949 MainControllerSection:
1950 MainControllerKeyword MCParameterList
1952 check_ignored_section("MAIN_CONTROLLER");
1958 | MCParameterList MCParameter optSemiColon
1962 LocalAddress AssignmentChar HostName { }
1963 | TCPPort AssignmentChar IntegerValue { delete $3; }
1964 | KillTimer AssignmentChar KillTimerValue { }
1965 | NumHCs AssignmentChar IntegerValue { delete $3; }
1966 | UnixSocketEnabled AssignmentChar YesToken {}
1967 | UnixSocketEnabled AssignmentChar NoToken {}
1968 | UnixSocketEnabled AssignmentChar HostName {}
1973 | IntegerValue { delete $1; }
1976 /****************** [INCLUDE] section *********************/
1978 IncludeKeyword IncludeFiles
1980 if(!TTCN_Runtime::is_single())
1981 config_process_error
1982 ("Internal error: the Main Controller must not send section [INCLUDE]"
1983 " of the configuration file.");
1989 | IncludeFiles IncludeFile
1993 Cstring { Free($1.chars_ptr); }
1996 /****************** [DEFINE] section *********************/
2000 if(!TTCN_Runtime::is_single())
2001 config_process_error
2002 ("Internal error: the Main Controller must not send section [DEFINE]"
2003 " of the configuration file.");
2007 /*********************************************************/
2012 $$ = Module_Param::OT_ASSIGN;
2017 $$ = Module_Param::OT_CONCAT;
2028 static void reset_configuration_options()
2030 /* Section [MODULE_PARAMETERS */
2031 /** \todo reset module parameters to their default values */
2032 /* Section [LOGGING] */
2033 TTCN_Logger::close_file();
2034 TTCN_Logger::reset_configuration();
2035 file_name_set = FALSE;
2036 file_mask_set = TRUE;
2037 console_mask_set = TRUE;
2038 timestamp_format_set = FALSE;
2039 source_info_format_set = FALSE;
2040 append_file_set = FALSE;
2041 log_event_types_set = FALSE;
2042 log_entity_name_set = FALSE;
2043 /* Section [TESTPORT_PARAMETERS] */
2044 PORT::clear_parameters();
2045 /* Section [EXTERNAL_COMMANDS] */
2047 TTCN_Runtime::clear_external_commands();
2049 begin_controlpart_command_set = FALSE;
2050 end_controlpart_command_set = FALSE;
2051 begin_testcase_command_set = FALSE;
2052 end_testcase_command_set = FALSE;
2055 Module_Param* process_config_string2ttcn(const char* mp_str, bool is_component)
2057 if (parsed_module_param!=NULL || parsing_error_messages!=NULL) TTCN_error("Internal error: previously parsed ttcn string was not cleared.");
2058 // add the hidden keyword
2059 std::string mp_string = (is_component) ? std::string("$#&&&(#TTCNSTRINGPARSING_COMPONENT$#&&^#% ") + mp_str
2060 : std::string("$#&&&(#TTCNSTRINGPARSING$#&&^#% ") + mp_str;
2061 struct yy_buffer_state *flex_buffer = config_process__scan_bytes(mp_string.c_str(), (int)mp_string.size());
2062 if (flex_buffer == NULL) TTCN_error("Internal error: flex buffer creation failed.");
2063 reset_config_process_lex(NULL);
2066 Ttcn_String_Parsing ttcn_string_parsing;
2067 if (config_process_parse()) error_flag = TRUE;
2068 } catch (const TC_Error& TC_error) {
2069 if (parsed_module_param!=NULL) { delete parsed_module_param; parsed_module_param = NULL; }
2072 config_process_close();
2073 config_process_lex_destroy();
2075 if (error_flag || parsing_error_messages!=NULL) {
2076 delete parsed_module_param;
2077 parsed_module_param = NULL;
2078 char* pem = parsing_error_messages!=NULL ? parsing_error_messages : mcopystr("Unknown parsing error");
2079 parsing_error_messages = NULL;
2080 TTCN_error_begin("%s", pem);
2085 if (parsed_module_param==NULL) TTCN_error("Internal error: could not parse ttcn string.");
2086 Module_Param* ret_val = parsed_module_param;
2087 parsed_module_param = NULL;
2092 boolean process_config_string(const char *config_string, int string_len)
2096 struct yy_buffer_state *flex_buffer =
2097 config_process__scan_bytes(config_string, string_len);
2098 if (flex_buffer == NULL) {
2099 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
2100 "Internal error: flex buffer creation failed.");
2105 reset_configuration_options();
2106 reset_config_process_lex(NULL);
2107 if (config_process_parse()) error_flag = TRUE;
2109 } catch (const TC_Error& TC_error) {
2113 config_process_close();
2114 config_process_lex_destroy();
2120 boolean process_config_file(const char *file_name)
2123 string_chain_t *filenames=NULL;
2125 reset_configuration_options();
2127 if(preproc_parse_file(file_name, &filenames, &config_defines))
2131 char *fn=string_chain_cut(&filenames);
2132 reset_config_process_lex(fn);
2133 /* The lexer can modify config_process_in
2134 * when it's input buffer is changed */
2135 config_process_in = fopen(fn, "r");
2136 FILE* tmp_cfg = config_process_in;
2137 if (config_process_in != NULL) {
2139 if(config_process_parse()) error_flag=TRUE;
2140 } catch (const TC_Error& TC_error) {
2144 config_process_close();
2145 config_process_lex_destroy();
2147 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2148 TTCN_Logger::log_event("Cannot open configuration file: %s", fn);
2149 TTCN_Logger::OS_error();
2150 TTCN_Logger::end_event();
2153 /* During parsing flex or libc may use some system calls (e.g. ioctl)
2154 * that fail with an error status. Such error codes shall be ignored in
2155 * future error messages. */
2161 string_map_free(config_defines);
2162 config_defines = NULL;
2167 void config_process_error_f(const char *error_str, ...)
2169 if (Ttcn_String_Parsing::happening()) {
2171 va_start(p_var, error_str);
2172 char* error_msg_str = mprintf_va_list(error_str, p_var);
2174 if (parsing_error_messages!=NULL) parsing_error_messages = mputc(parsing_error_messages, '\n');
2175 parsing_error_messages = mputprintf(parsing_error_messages,
2176 "Parse error in line %d, at or before token `%s': %s", config_process_get_current_line(), config_process_text, error_msg_str);
2177 Free(error_msg_str);
2181 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2182 if (!get_cfg_process_current_file().empty()) {
2183 TTCN_Logger::log_event("Parse error in configuration file `%s': in line %d, "
2184 "at or before token `%s': ",
2185 get_cfg_process_current_file().c_str(), config_process_get_current_line(),
2189 TTCN_Logger::log_event("Parse error while reading configuration "
2190 "information: in line %d, at or before token `%s': ",
2191 config_process_get_current_line(), config_process_text);
2194 va_start(pvar, error_str);
2195 TTCN_Logger::log_event_va_list(error_str, pvar);
2197 TTCN_Logger::end_event();
2201 void config_process_error(const char *error_str)
2203 config_process_error_f("%s", error_str);
2206 void config_preproc_error(const char *error_str, ...)
2208 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2209 TTCN_Logger::log_event("Parse error while pre-processing configuration"
2210 " file `%s': in line %d: ",
2211 get_cfg_preproc_current_file().c_str(),
2212 config_preproc_yylineno);
2214 va_start(pvar, error_str);
2215 TTCN_Logger::log_event_va_list(error_str, pvar);
2217 TTCN_Logger::end_event();
2221 void path_error(const char *fmt, ...)
2224 fprintf(stderr, "File error: ");
2225 va_start(parameters, fmt);
2226 vfprintf(stderr, fmt, parameters);
2228 fprintf(stderr, "\n");
2231 static void check_duplicate_option(const char *section_name,
2232 const char *option_name, boolean& option_flag)
2235 TTCN_warning("Option `%s' was given more than once in section [%s] of the "
2236 "configuration file.", option_name, section_name);
2237 } else option_flag = TRUE;
2240 static void check_ignored_section(const char *section_name)
2242 if (TTCN_Runtime::is_single()) TTCN_warning("Section [%s] of "
2243 "configuration file is ignored in single mode.", section_name);
2244 else config_process_error_f("Internal error: the Main Controller must not "
2245 "send section [%s] of the configuration file.", section_name);
2248 static void set_param(Module_Param& param)
2251 Module_List::set_param(param);
2253 catch (const TC_Error& TC_error) {
2258 unsigned char char_to_hexdigit(char c)
2260 if (c >= '0' && c <= '9') return c - '0';
2261 else if (c >= 'A' && c <= 'F') return c - 'A' + 10;
2262 else if (c >= 'a' && c <= 'f') return c - 'a' + 10;
2264 config_process_error_f("char_to_hexdigit(): invalid argument: %c", c);
2265 return 0; // to avoid warning