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
21 * Szabo, Janos Zoltan – initial implementation
23 * Zalanyi, Balazs Andor
25 ******************************************************************************/
35 #include <openssl/bn.h>
37 #include "../common/config_preproc.h"
39 #include "Param_Types.hh"
44 #include "Verdicttype.hh"
45 #include "Bitstring.hh"
46 #include "Hexstring.hh"
47 #include "Octetstring.hh"
48 #include "Charstring.hh"
49 #include "Universal_charstring.hh"
51 #include "Module_list.hh"
55 #include "LoggingBits.hh"
56 #include "LoggingParam.hh"
58 #include "Profiler.hh"
60 #define YYERROR_VERBOSE
62 #include "config_process.lex.hh"
64 extern void reset_config_process_lex(const char* fname);
65 extern void config_process_close();
66 extern int config_process_get_current_line();
67 extern std::string get_cfg_process_current_file();
69 static int config_process_parse();
70 static void check_duplicate_option(const char *section_name,
71 const char *option_name, boolean& option_flag);
72 static void check_ignored_section(const char *section_name);
73 static void set_param(Module_Param& module_param);
74 static unsigned char char_to_hexdigit(char c);
76 static boolean error_flag = FALSE;
78 static Module_Param* parsed_module_param = NULL;
79 static char * parsing_error_messages = NULL;
82 For detecting duplicate entries in the config file. Start out as FALSE,
83 set to TRUE bycheck_duplicate_option().
84 Exception: duplication of parameters that can be component specific is checked
85 by set_xxx(), these start out as TRUE.
87 static boolean file_name_set = FALSE,
89 console_mask_set = TRUE,
90 timestamp_format_set = FALSE,
91 source_info_format_set = FALSE,
92 append_file_set = FALSE,
93 log_event_types_set = FALSE,
94 log_entity_name_set = FALSE,
95 begin_controlpart_command_set = FALSE,
96 end_controlpart_command_set = FALSE,
97 begin_testcase_command_set = FALSE,
98 end_testcase_command_set = FALSE,
99 log_file_size_set = TRUE,
100 log_file_number_set = TRUE,
101 log_disk_full_action_set = TRUE,
102 matching_verbosity_set = FALSE,
103 logger_plugins_set = FALSE,
104 plugin_specific_set = FALSE;
106 int execute_list_len = 0;
107 execute_list_item *execute_list = NULL;
109 string_map_t *config_defines;
117 unsigned int uint_val;
120 param_objid_t objid_val;
121 verdicttype verdict_val;
122 param_bitstring_t bitstring_val;
123 param_hexstring_t hexstring_val;
124 param_charstring_t charstring_val;
125 param_octetstring_t octetstring_val;
126 universal_char universal_char_val;
127 param_universal_charstring_t universal_charstring_val;
128 Module_Param::operation_type_t param_optype_val;
129 Vector<Module_Param*>* module_param_list;
130 Module_Param* module_param_val;
131 Module_Param_Length_Restriction* module_param_length_restriction;
132 Vector<char*>* name_vector;
133 component_id_t comp_id;
134 execute_list_item execute_item_val;
135 TTCN_Logger::emergency_logging_behaviour_t emergency_logging_behaviour_value;
136 TTCN_Logger::timestamp_format_t timestamp_value;
137 TTCN_Logger::source_info_format_t source_info_value;
138 TTCN_Logger::log_event_types_t log_event_types_value;
139 TTCN_Logger::disk_full_action_t disk_full_action_value;
140 TTCN_Logger::matching_verbosity_t matching_verbosity_value;
141 TTCN_Logger::Severity logseverity_val;
142 Logging_Bits logoptions_val;
144 logging_plugin_t *logging_plugins;
145 logging_param_t logging_params;
146 logging_setting_t logging_param_line;
149 const char **elements;
153 %token ModuleParametersKeyword
154 %token LoggingKeyword
155 %token ProfilerKeyword
156 %token TestportParametersKeyword
157 %token ExecuteKeyword
158 %token ExternalCommandsKeyword
160 %token ComponentsKeyword
161 %token MainControllerKeyword
162 %token IncludeKeyword
167 %token ObjIdKeyword "objid"
168 %token CharKeyword "char"
169 %token ControlKeyword "control"
170 %token MTCKeyword "mtc"
171 %token SystemKeyword "system"
172 %token NULLKeyword "NULL"
173 %token nullKeyword "null"
174 %token OmitKeyword "omit"
175 %token ComplementKeyword "complement"
177 %token SupersetKeyword "superset"
178 %token SubsetKeyword "subset"
179 %token PatternKeyword "pattern"
180 %token PermutationKeyword "permutation"
181 %token LengthKeyword "length"
182 %token IfpresentKeyword "ifpresent"
183 %token InfinityKeyword "infinity"
184 %token AssignmentChar ":= or ="
185 %token ConcatChar "&="
186 %token LogFile "LogFile or FileName"
187 %token EmergencyLogging
188 %token EmergencyLoggingBehaviour
189 %token EmergencyLoggingMask
190 %token EmergencyLoggingForFailVerdict
195 %token TimestampFormat
196 %token ConsoleTimestampFormat
197 %token SourceInfoFormat "LogSourceInfo or SourceInfoFormat"
201 %token BeginControlPart
202 %token EndControlPart
205 %token <str_val> Identifier
206 %token <str_val> ASN1LowerIdentifier "ASN.1 identifier beginning with a lowercase letter"
207 %token <int_val> Number MPNumber "integer value"
208 %token <float_val> Float MPFloat "float value"
209 %token <bool_val> BooleanValue "true or false"
210 %token <verdict_val> VerdictValue
211 %token <bitstring_val> Bstring "bit string value"
212 %token <hexstring_val> Hstring "hex string value"
213 %token <octetstring_val> Ostring "octet string value"
214 %token <str_val> BstringMatch "bit string template"
215 %token <str_val> HstringMatch "hex string template"
216 %token <str_val> OstringMatch "octet string template"
217 %token <charstring_val> Cstring MPCstring "charstring value"
218 %token <str_val> UIDval
219 %token DNSName "hostname"
221 %token <logseverity_val> LoggingBit
222 /* a collection of bits */
223 %token <logseverity_val> LoggingBitCollection
225 %token <emergency_logging_behaviour_value> EmergencyLoggingBehaviourValue "BufferAll or BufferMasked"
226 %token <timestamp_value> TimestampValue "Time, Datetime or Seconds"
227 %token <source_info_value> SourceInfoValue "None, Single or Stack"
228 %token <bool_val> YesNo "yes or no"
233 %token UnixSocketEnabled
234 %token YesToken "yes"
238 %token DiskFullAction
245 %token TtcnStringParsingKeyword
246 %token DisableProfilerKeyword "DisableProfiler"
247 %token DisableCoverageKeyword "DisableCoverage"
248 %token DatabaseFileKeyword "DatabaseFile"
249 %token AggregateDataKeyword "AggregateData"
250 %token StatisticsFileKeyword "StatisticsFile"
251 %token DisableStatisticsKeyword "DisableStatistics"
252 %token StatisticsFilterKeyword "StatisticsFilter"
253 %token StartAutomaticallyKeyword "StartAutomatically"
254 %token NetLineTimesKeyword "NetLineTimes"
255 %token NetFunctionTimesKeyword "NetFunctionTimes"
256 %token <uint_val> ProfilerStatsFlag "profiler statistics filter"
258 %type <int_val> IntegerValue
259 %type <float_val> FloatValue
260 %type <objid_val> ObjIdValue ObjIdComponentList
261 %type <int_val> ObjIdComponent NumberForm NameAndNumberForm
263 %type <universal_charstring_val> UniversalCharstringValue UniversalCharstringFragment
264 %type <universal_char_val> Quadruple
265 %type <uid_list> USI UIDlike
267 %type <str_val> LoggerPluginId
268 %type <logging_plugins> LoggerPlugin LoggerPluginList
269 %type <logging_params> LoggingParam
270 %type <logging_param_line> LoggingParamLines
271 %type <str_val> LogFileName StringValue
272 /* a collection of bits */
273 %type <logoptions_val> LoggingBitmask
274 %type <logoptions_val> LoggingBitOrCollection
275 %type <source_info_value> SourceInfoSetting
276 %type <bool_val> YesNoOrBoolean
277 %type <log_event_types_value> LogEventTypesValue
278 %type <disk_full_action_value> DiskFullActionValue
279 %type <str_val> Command
280 %type <matching_verbosity_value> VerbosityValue
281 %type <comp_id> ComponentId
282 %type <str_val> TestportName ArrayRef TestportParameterName
283 TestportParameterValue
285 %type <execute_item_val> ExecuteItem
287 %type <bitstring_val> BitstringValue
288 %type <hexstring_val> HexstringValue
289 %type <octetstring_val> OctetstringValue
291 %type <name_vector> ParameterName ParameterNameSegment
292 %type <param_optype_val> ParamOpType
293 %type <str_val> FieldName
294 %type <module_param_val> ParameterValue SimpleParameterValue ParameterValueOrNotUsedSymbol
295 FieldValue ArrayItem IndexItem IndexItemList FieldValueList ArrayItemList CompoundValue IntegerRange FloatRange StringRange
296 ParameterExpression ParameterReference
297 %type <module_param_list> TemplateItemList
298 %type <module_param_length_restriction> LengthMatch
299 %type <str_val> PatternChunk
300 %type <int_native> IndexItemIndex LengthBound
301 %type <uint_val> ProfilerStatsFlags
303 %destructor { Free($$); }
312 TestportParameterName
313 TestportParameterValue
319 %destructor { Free($$.components_ptr); }
323 %destructor { Free($$.bits_ptr); }
327 %destructor { Free($$.nibbles_ptr); }
331 %destructor { Free($$.octets_ptr); }
335 %destructor { Free($$.chars_ptr); }
339 %destructor { Free($$.uchars_ptr); }
340 UniversalCharstringFragment
341 UniversalCharstringValue
343 %destructor { if ($$.id_selector == COMPONENT_ID_NAME) Free($$.id_name); }
346 %destructor { Free($$.module_name); Free($$.testcase_name); }
349 %destructor { delete $$; }
358 ParameterValueOrNotUsedSymbol
372 %destructor { delete $$; }
375 %destructor { for(size_t i=0; i<$$->size(); i++) { delete $$->at(i); } delete $$; }
378 %destructor { for(size_t i=0; i<$$->size(); i++) { Free($$->at(i)); } delete $$; }
382 %left '&' /* to avoid shift/reduce conflicts */
391 When seeing a '*' token after a module parameter expression the parser cannot
392 decide whether the token is a multiplication operator (shift) or it refers to
393 all modules in the next module parameter (reduce).
400 if (Ttcn_String_Parsing::happening()) {
401 config_process_error("Config file cannot be parsed as ttcn string");
404 | TtcnStringParsingKeyword ParameterValue
406 parsed_module_param = $2;
416 ModuleParametersSection
419 | TestportParametersSection
421 | ExternalCommandsSection
424 | MainControllerSection
429 ModuleParametersSection:
430 ModuleParametersKeyword ModuleParameters
435 | ModuleParameters ModuleParameter optSemiColon
439 ParameterName ParamOpType ParameterValue
441 Module_Param* mp = $3;
442 mp->set_id(new Module_Param_Name(*$1));
443 mp->set_operation_type($2);
451 ParameterNameSegment { $$ = $1; }
452 | '*' '.' ParameterNameSegment { $$ = $3; }
455 ParameterNameSegment:
456 ParameterNameSegment '.' Identifier
461 | ParameterNameSegment IndexItemIndex
464 $$->push_back(mprintf("%d", $2));
468 $$ = new Vector<char*>();
478 | ParameterExpression LengthMatch
481 $$->set_length_restriction($2);
483 | ParameterExpression IfpresentKeyword
488 | ParameterExpression LengthMatch IfpresentKeyword
491 $$->set_length_restriction($2);
497 LengthKeyword '(' LengthBound ')'
499 $$ = new Module_Param_Length_Restriction();
500 $$->set_single((size_t)$3);
502 | LengthKeyword '(' LengthBound DotDot LengthBound ')'
505 config_process_error("invalid length restriction: lower bound > upper bound");
507 $$ = new Module_Param_Length_Restriction();
508 $$->set_min((size_t)$3);
509 $$->set_max((size_t)$5);
511 | LengthKeyword '(' LengthBound DotDot InfinityKeyword ')'
513 $$ = new Module_Param_Length_Restriction();
514 $$->set_min((size_t)$3);
521 $1->set_id(new Module_Param_CustomName(mcopystr("length bound")));
524 if (!tmp.get_val().is_native()) {
525 config_process_error("bignum length restriction bound.");
527 } else if (tmp.get_val().is_negative()) {
528 config_process_error("negative length restriction bound.");
537 // one global rule for expressions in module parameters
538 // the expression's result will be calculated by set_param()
540 SimpleParameterValue { $$ = $1; }
541 | ParameterReference { $$ = $1; }
542 | '(' ParameterExpression ')' { $$ = $2; }
543 | '+' ParameterExpression %prec UnarySign { $$ = $2; }
544 | '-' ParameterExpression %prec UnarySign { $$ = new Module_Param_Expression($2); }
545 | ParameterExpression '+' ParameterExpression
547 $$ = new Module_Param_Expression(Module_Param::EXPR_ADD, $1, $3);
549 | ParameterExpression '-' ParameterExpression
551 $$ = new Module_Param_Expression(Module_Param::EXPR_SUBTRACT, $1, $3);
553 | ParameterExpression '*' ParameterExpression
555 $$ = new Module_Param_Expression(Module_Param::EXPR_MULTIPLY, $1, $3);
557 | ParameterExpression '/' ParameterExpression
559 $$ = new Module_Param_Expression(Module_Param::EXPR_DIVIDE, $1, $3);
561 | ParameterExpression '&' ParameterExpression
563 $$ = new Module_Param_Expression(Module_Param::EXPR_CONCATENATE, $1, $3);
568 // enumerated values are also treated as references by the parser,
569 // these will be sorted out later during set_param()
572 $$ = new Module_Param_Reference(new Module_Param_Name(*$1));
576 SimpleParameterValue:
579 $$ = new Module_Param_Integer($1);
583 $$ = new Module_Param_Float($1);
587 $$ = new Module_Param_Boolean($1);
591 $$ = new Module_Param_Objid($1.n_components, $1.components_ptr);
595 $$ = new Module_Param_Verdict($1);
599 $$ = new Module_Param_Bitstring($1.n_bits, $1.bits_ptr);
603 $$ = new Module_Param_Hexstring($1.n_nibbles, $1.nibbles_ptr);
607 $$ = new Module_Param_Octetstring($1.n_octets, $1.octets_ptr);
611 $$ = new Module_Param_Charstring($1.n_chars, $1.chars_ptr);
613 | UniversalCharstringValue
615 $$ = new Module_Param_Universal_Charstring($1.n_uchars, $1.uchars_ptr);
619 $$ = new Module_Param_Omit();
623 $$ = new Module_Param_Asn_Null();
627 $$ = new Module_Param_Ttcn_Null();
631 $$ = new Module_Param_Ttcn_mtc();
635 $$ = new Module_Param_Ttcn_system();
639 $$ = new Module_Param_Any();
643 $$ = new Module_Param_AnyOrNone();
657 | PatternKeyword PatternChunk
659 $$ = new Module_Param_Pattern($2);
664 int n_chars = (int)mstrlen($1);
665 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
666 for (int i=0; i<n_chars; i++) {
682 config_process_error_f("Invalid char (%c) in bitstring template", $1[i]);
686 $$ = new Module_Param_Bitstring_Template(n_chars, chars_ptr);
690 int n_chars = (int)mstrlen($1);
691 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
692 for (int i=0; i<n_chars; i++) {
693 if ($1[i]=='?') chars_ptr[i] = 16;
694 else if ($1[i]=='*') chars_ptr[i] = 17;
695 else chars_ptr[i] = char_to_hexdigit($1[i]);
698 $$ = new Module_Param_Hexstring_Template(n_chars, chars_ptr);
702 Vector<unsigned short> octet_vec;
703 int str_len = (int)mstrlen($1);
704 for (int i=0; i<str_len; i++) {
706 if ($1[i]=='?') num = 256;
707 else if ($1[i]=='*') num = 257;
710 num = 16 * char_to_hexdigit($1[i]);
712 if (i>=str_len) config_process_error("Unexpected end of octetstring pattern");
714 num += char_to_hexdigit($1[i]);
716 octet_vec.push_back(num);
719 int n_chars = (int)octet_vec.size();
720 unsigned short* chars_ptr = (unsigned short*)Malloc(n_chars*sizeof(unsigned short));
721 for (int i=0; i<n_chars; i++) chars_ptr[i] = octet_vec[i];
722 $$ = new Module_Param_Octetstring_Template(n_chars, chars_ptr);
733 $$ = mcopystr($1.chars_ptr);
738 $$ = mprintf("\\q{%d,%d,%d,%d}", $1.uc_group, $1.uc_plane, $1.uc_row, $1.uc_cell);
743 '(' '-' InfinityKeyword DotDot MPNumber ')'
745 $$ = new Module_Param_IntRange(NULL, $5);
747 | '(' MPNumber DotDot MPNumber ')'
749 $$ = new Module_Param_IntRange($2, $4);
751 | '(' MPNumber DotDot InfinityKeyword ')'
753 $$ = new Module_Param_IntRange($2, NULL);
758 '(' '-' InfinityKeyword DotDot MPFloat ')'
760 $$ = new Module_Param_FloatRange(0.0, false, $5, true);
762 | '(' MPFloat DotDot MPFloat ')'
764 $$ = new Module_Param_FloatRange($2, true, $4, true);
766 | '(' MPFloat DotDot InfinityKeyword ')'
768 $$ = new Module_Param_FloatRange($2, true, 0.0, false);
773 '(' UniversalCharstringFragment DotDot UniversalCharstringFragment ')'
775 universal_char lower; lower.uc_group=lower.uc_plane=lower.uc_row=lower.uc_cell=0;
776 universal_char upper; upper.uc_group=upper.uc_plane=upper.uc_row=upper.uc_cell=0;
777 if ($2.n_uchars!=1) {
778 config_process_error("Lower bound of char range must be 1 character only");
779 } else if ($4.n_uchars!=1) {
780 config_process_error("Upper bound of char range must be 1 character only");
782 lower = *($2.uchars_ptr);
783 upper = *($4.uchars_ptr);
785 config_process_error("Lower bound is larger than upper bound in the char range");
791 $$ = new Module_Param_StringRange(lower, upper);
795 // integers outside of the [MODULE_PARAMETERS] section
798 | '(' IntegerValue ')' { $$ = $2; }
799 | '+' IntegerValue %prec UnarySign { $$ = $2; }
800 | '-' IntegerValue %prec UnarySign
804 $$ = new int_val_t((-op1).get_val());
807 | IntegerValue '+' IntegerValue
812 $$ = new int_val_t((op1 + op2).get_val());
816 | IntegerValue '-' IntegerValue
821 $$ = new int_val_t((op1 - op2).get_val());
825 | IntegerValue '*' IntegerValue
830 $$ = new int_val_t((op1 * op2).get_val());
834 | IntegerValue '/' IntegerValue
837 config_process_error("Integer division by zero.");
838 $$ = new int_val_t((RInt)0);
845 $$ = new int_val_t((op1 / op2).get_val());
852 // floats outside of the [MODULE_PARAMETERS] section
855 | '(' FloatValue ')' { $$ = $2; }
856 | '+' FloatValue %prec UnarySign { $$ = $2; }
857 | '-' FloatValue %prec UnarySign { $$ = -$2; }
858 | FloatValue '+' FloatValue { $$ = $1 + $3; }
859 | FloatValue '-' FloatValue { $$ = $1 - $3; }
860 | FloatValue '*' FloatValue { $$ = $1 * $3; }
861 | FloatValue '/' FloatValue
864 config_process_error("Floating point division by zero.");
871 ObjIdKeyword '{' ObjIdComponentList '}' { $$ = $3; }
878 $$.components_ptr = (int *)Malloc(sizeof(int));
879 $$.components_ptr[0] = $1->get_val();
882 | ObjIdComponentList ObjIdComponent
884 $$.n_components = $1.n_components + 1;
885 $$.components_ptr = (int *)Realloc($1.components_ptr,
886 $$.n_components * sizeof(int));
887 $$.components_ptr[$$.n_components - 1] = $2->get_val();
893 NumberForm { $$ = $1; }
894 | NameAndNumberForm { $$ = $1; }
898 MPNumber { $$ = $1; }
902 Identifier '(' MPNumber ')'
921 UniversalCharstringValue:
925 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
926 $$.uchars_ptr[0] = $1;
930 $$.n_uchars = $1.nElements;
931 $$.uchars_ptr = (universal_char*)Malloc($$.n_uchars * sizeof(universal_char));
932 for (int i = 0; i < $$.n_uchars; ++i) {
933 size_t offset = 1; //Always starts with u or U
934 offset = $1.elements[i][1] == '+' ? offset + 1 : offset; //Optional '+'
937 unsigned long int_val = strtoul($1.elements[i] + offset, &p, 16);
939 //Error, should not happen
940 config_process_error_f("Invalid hexadecimal string %s.", $1.elements[i] + offset);
943 //Fill in the quadruple
944 $$.uchars_ptr[i].uc_group = (int_val >> 24) & 0xFF;
945 $$.uchars_ptr[i].uc_plane = (int_val >> 16) & 0xFF;
946 $$.uchars_ptr[i].uc_row = (int_val >> 8) & 0xFF;
947 $$.uchars_ptr[i].uc_cell = int_val & 0xFF;
949 Free((char*)$1.elements[i]);
955 UniversalCharstringFragment:
958 $$.n_uchars = $1.n_chars;
959 $$.uchars_ptr = (universal_char*)
960 Malloc($$.n_uchars * sizeof(universal_char));
961 for (int i = 0; i < $1.n_chars; i++) {
962 $$.uchars_ptr[i].uc_group = 0;
963 $$.uchars_ptr[i].uc_plane = 0;
964 $$.uchars_ptr[i].uc_row = 0;
965 $$.uchars_ptr[i].uc_cell = $1.chars_ptr[i];
972 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
973 $$.uchars_ptr[0] = $1;
978 CharKeyword '(' ParameterExpression ',' ParameterExpression ','
979 ParameterExpression ',' ParameterExpression ')'
981 $3->set_id(new Module_Param_CustomName(mcopystr("quadruple group")));
982 $5->set_id(new Module_Param_CustomName(mcopystr("quadruple plane")));
983 $7->set_id(new Module_Param_CustomName(mcopystr("quadruple row")));
984 $9->set_id(new Module_Param_CustomName(mcopystr("quadruple cell")));
990 if (g < 0 || g > 127) {
991 char *s = g.get_val().as_string();
992 config_process_error_f("The first number of quadruple (group) must be "
993 "within the range 0 .. 127 instead of %s.", s);
995 $$.uc_group = g < 0 ? 0 : 127;
999 if (p < 0 || p > 255) {
1000 char *s = p.get_val().as_string();
1001 config_process_error_f("The second number of quadruple (plane) must be "
1002 "within the range 0 .. 255 instead of %s.", s);
1004 $$.uc_plane = p < 0 ? 0 : 255;
1008 if (r < 0 || r > 255) {
1009 char *s = r.get_val().as_string();
1010 config_process_error_f("The third number of quadruple (row) must be "
1011 "within the range 0 .. 255 instead of %s.", s);
1013 $$.uc_row = r < 0 ? 0 : 255;
1017 if (c < 0 || c > 255) {
1018 char *s = c.get_val().as_string();
1019 config_process_error_f("The fourth number of quadruple (cell) must be "
1020 "within the range 0 .. 255 instead of %s.", s);
1022 $$.uc_cell = c < 0 ? 0 : 255;
1034 CharKeyword '(' UIDlike ')'
1044 $$.elements = (const char**)
1045 Malloc($$.nElements * sizeof(*$$.elements));
1046 $$.elements[$$.nElements-1] = $1;
1048 | UIDlike ',' UIDval {
1049 $$.nElements = $1.nElements + 1;
1050 $$.elements = (const char**)
1051 Realloc($1.elements, ($$.nElements) * sizeof(*$1.elements));
1052 $$.elements[$$.nElements-1] = $3;
1056 // character strings outside of the [MODULE_PARAMETERS] section
1060 $$ = mcopystr($1.chars_ptr);
1063 | StringValue '&' Cstring
1065 $$ = mputstr($1, $3.chars_ptr);
1073 $$ = new Module_Param_Value_List();
1075 | '{' FieldValueList '}'
1079 | '{' ArrayItemList '}'
1083 | '{' IndexItemList '}'
1087 | '(' ParameterValue ',' TemplateItemList ')' /* at least 2 elements to avoid shift/reduce conflicts with the ParameterExpression rule */
1089 $$ = new Module_Param_List_Template();
1090 $2->set_id(new Module_Param_Index($$->get_size(),false));
1092 $$->add_list_with_implicit_ids($4);
1095 | ComplementKeyword '(' TemplateItemList ')'
1097 $$ = new Module_Param_ComplementList_Template();
1098 $$->add_list_with_implicit_ids($3);
1101 | SupersetKeyword '(' TemplateItemList ')'
1103 $$ = new Module_Param_Superset_Template();
1104 $$->add_list_with_implicit_ids($3);
1107 | SubsetKeyword '(' TemplateItemList ')'
1109 $$ = new Module_Param_Subset_Template();
1110 $$->add_list_with_implicit_ids($3);
1115 ParameterValueOrNotUsedSymbol:
1122 $$ = new Module_Param_NotUsed();
1129 $$ = new Vector<Module_Param*>();
1132 | TemplateItemList ',' ParameterValue
1142 $$ = new Module_Param_Assignment_List();
1145 | FieldValueList ',' FieldValue
1153 FieldName AssignmentChar ParameterValueOrNotUsedSymbol
1156 $$->set_id(new Module_Param_FieldName($1));
1165 | ASN1LowerIdentifier
1174 $$ = new Module_Param_Value_List();
1175 $1->set_id(new Module_Param_Index($$->get_size(),false));
1178 | ArrayItemList ',' ArrayItem
1181 $3->set_id(new Module_Param_Index($$->get_size(),false));
1187 ParameterValueOrNotUsedSymbol
1191 | PermutationKeyword '(' TemplateItemList ')'
1193 $$ = new Module_Param_Permutation_Template();
1194 $$->add_list_with_implicit_ids($3);
1202 $$ = new Module_Param_Indexed_List();
1205 | IndexItemList ',' IndexItem
1213 IndexItemIndex AssignmentChar ParameterValue
1216 $$->set_id(new Module_Param_Index((size_t)$1,true));
1221 '[' ParameterExpression ']'
1223 $2->set_id(new Module_Param_CustomName(mcopystr("array index")));
1226 if (!tmp.get_val().is_native()) {
1227 config_process_error("bignum index."); // todo
1229 if (tmp.get_val().is_negative()) {
1230 config_process_error("negative index."); // todo
1237 /*************** [LOGGING] section *********************************/
1240 LoggingKeyword LoggingParamList
1245 | LoggingParamList LoggingParamLines optSemiColon
1247 // Centralized duplication handling for `[LOGGING]'.
1248 if ($2.logparam.log_param_selection != LP_UNKNOWN && TTCN_Logger::add_parameter($2)) {
1249 switch ($2.logparam.log_param_selection) {
1251 check_duplicate_option("LOGGING", "FileMask", file_mask_set);
1253 case LP_CONSOLEMASK:
1254 check_duplicate_option("LOGGING", "ConsoleMask", console_mask_set);
1256 case LP_LOGFILESIZE:
1257 check_duplicate_option("LOGGING", "LogFileSize", log_file_size_set);
1259 case LP_LOGFILENUMBER:
1260 check_duplicate_option("LOGGING", "LogFileNumber", log_file_number_set);
1262 case LP_DISKFULLACTION:
1263 check_duplicate_option("LOGGING", "DiskFullAction", log_disk_full_action_set);
1266 check_duplicate_option("LOGGING", "LogFile", file_name_set);
1268 case LP_TIMESTAMPFORMAT:
1269 check_duplicate_option("LOGGING", "TimeStampFormat", timestamp_format_set);
1271 case LP_SOURCEINFOFORMAT:
1272 check_duplicate_option("LOGGING", "SourceInfoFormat", source_info_format_set);
1275 check_duplicate_option("LOGGING", "AppendFile", append_file_set);
1277 case LP_LOGEVENTTYPES:
1278 check_duplicate_option("LOGGING", "LogEventTypes", log_event_types_set);
1280 case LP_LOGENTITYNAME:
1281 check_duplicate_option("LOGGING", "LogEntityName", log_entity_name_set);
1283 case LP_MATCHINGHINTS:
1284 check_duplicate_option("LOGGING", "MatchingVerbosity", matching_verbosity_set);
1286 case LP_PLUGIN_SPECIFIC:
1287 // It would be an overkill to check for the infinite number of custom parameters...
1288 check_duplicate_option("LOGGING", "PluginSpecific", plugin_specific_set);
1300 $$.component.id_selector = COMPONENT_ID_ALL;
1301 $$.component.id_name = NULL;
1302 $$.plugin_id = NULL;
1305 | ComponentId '.' LoggingParam
1308 $$.plugin_id = NULL;
1311 | ComponentId '.' LoggerPluginId '.' LoggingParam
1317 | LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1319 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1320 component_id_t comp;
1321 comp.id_selector = COMPONENT_ID_ALL;
1322 comp.id_name = NULL;
1323 logging_plugin_t *plugin = $4;
1324 while (plugin != NULL) {
1325 // `identifier' and `filename' are reused. Various checks and
1326 // validations must be done in the logger itself (e.g. looking for
1327 // duplicate options).
1328 TTCN_Logger::register_plugin(comp, plugin->identifier, plugin->filename);
1329 logging_plugin_t *tmp = plugin;
1333 $$.logparam.log_param_selection = LP_UNKNOWN;
1335 | ComponentId '.' LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1337 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1338 logging_plugin_t *plugin = $6;
1339 while (plugin != NULL) {
1340 TTCN_Logger::register_plugin($1, plugin->identifier, plugin->filename);
1341 logging_plugin_t *tmp = plugin;
1345 // Component names shall be duplicated in `register_plugin()'.
1346 if ($1.id_selector == COMPONENT_ID_NAME)
1348 $$.logparam.log_param_selection = LP_UNKNOWN;
1357 | LoggerPluginList ',' LoggerPlugin
1367 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1368 $$->identifier = $1;
1369 $$->filename = NULL;
1372 | Identifier AssignmentChar StringValue
1374 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1375 $$->identifier = $1;
1382 '*' { $$ = mcopystr("*"); }
1383 | Identifier { $$ = $1; }
1387 FileMask AssignmentChar LoggingBitmask
1389 $$.log_param_selection = LP_FILEMASK;
1390 $$.logoptions_val = $3;
1392 | ConsoleMask AssignmentChar LoggingBitmask
1394 $$.log_param_selection = LP_CONSOLEMASK;
1395 $$.logoptions_val = $3;
1397 | LogFileSize AssignmentChar Number
1399 $$.log_param_selection = LP_LOGFILESIZE;
1400 $$.int_val = (int)$3->get_val();
1403 | EmergencyLogging AssignmentChar Number
1405 $$.log_param_selection = LP_EMERGENCY;
1406 $$.int_val = (int)$3->get_val();
1409 | EmergencyLoggingBehaviour AssignmentChar EmergencyLoggingBehaviourValue
1411 $$.log_param_selection = LP_EMERGENCYBEHAVIOR;
1412 $$.emergency_logging_behaviour_value = $3;
1414 | EmergencyLoggingMask AssignmentChar LoggingBitmask
1416 $$.log_param_selection = LP_EMERGENCYMASK;
1417 $$.logoptions_val = $3;
1419 | EmergencyLoggingForFailVerdict AssignmentChar YesNoOrBoolean
1421 $$.log_param_selection = LP_EMERGENCYFORFAIL;
1424 | LogFileNumber AssignmentChar Number
1426 $$.log_param_selection = LP_LOGFILENUMBER;
1427 $$.int_val = (int)$3->get_val();
1430 | DiskFullAction AssignmentChar DiskFullActionValue
1432 $$.log_param_selection = LP_DISKFULLACTION;
1433 $$.disk_full_action_value = $3;
1435 | LogFile AssignmentChar LogFileName
1437 $$.log_param_selection = LP_LOGFILE;
1440 | TimestampFormat AssignmentChar TimestampValue
1442 $$.log_param_selection = LP_TIMESTAMPFORMAT;
1443 $$.timestamp_value = $3;
1445 | ConsoleTimestampFormat AssignmentChar TimestampValue
1447 $$.log_param_selection = LP_UNKNOWN;
1449 | SourceInfoFormat AssignmentChar SourceInfoSetting
1451 $$.log_param_selection = LP_SOURCEINFOFORMAT;
1452 $$.source_info_value = $3;
1454 | AppendFile AssignmentChar YesNoOrBoolean
1456 $$.log_param_selection = LP_APPENDFILE;
1459 | LogEventTypes AssignmentChar LogEventTypesValue
1461 $$.log_param_selection = LP_LOGEVENTTYPES;
1462 $$.log_event_types_value = $3;
1464 | LogEntityName AssignmentChar YesNoOrBoolean
1466 $$.log_param_selection = LP_LOGENTITYNAME;
1469 | MatchingHints AssignmentChar VerbosityValue
1471 $$.log_param_selection = LP_MATCHINGHINTS;
1472 $$.matching_verbosity_value = $3;
1474 | Identifier AssignmentChar StringValue
1476 $$.log_param_selection = LP_PLUGIN_SPECIFIC;
1483 Compact { $$ = TTCN_Logger::VERBOSITY_COMPACT; }
1484 | Detailed { $$ = TTCN_Logger::VERBOSITY_FULL; }
1487 DiskFullActionValue:
1488 Error { $$.type = TTCN_Logger::DISKFULL_ERROR; }
1489 | Stop { $$.type = TTCN_Logger::DISKFULL_STOP; }
1492 $$.type = TTCN_Logger::DISKFULL_RETRY;
1493 $$.retry_interval = 30; /* default retry interval */
1495 | Retry '(' Number ')'
1497 $$.type = TTCN_Logger::DISKFULL_RETRY;
1498 $$.retry_interval = (size_t)$3->get_val();
1501 | Delete { $$.type = TTCN_Logger::DISKFULL_DELETE; }
1505 StringValue { $$ = $1; }
1508 LoggingBitOrCollection:
1514 | LoggingBitCollection
1519 case TTCN_Logger::ACTION_UNQUALIFIED:
1520 $$.add_sev(TTCN_Logger::ACTION_UNQUALIFIED);
1522 case TTCN_Logger::DEFAULTOP_UNQUALIFIED:
1523 $$.add_sev(TTCN_Logger::DEFAULTOP_ACTIVATE);
1524 $$.add_sev(TTCN_Logger::DEFAULTOP_DEACTIVATE);
1525 $$.add_sev(TTCN_Logger::DEFAULTOP_EXIT);
1526 $$.add_sev(TTCN_Logger::DEFAULTOP_UNQUALIFIED);
1528 case TTCN_Logger::ERROR_UNQUALIFIED:
1529 $$.add_sev(TTCN_Logger::ERROR_UNQUALIFIED);
1531 case TTCN_Logger::EXECUTOR_UNQUALIFIED:
1532 $$.add_sev(TTCN_Logger::EXECUTOR_RUNTIME);
1533 $$.add_sev(TTCN_Logger::EXECUTOR_CONFIGDATA);
1534 $$.add_sev(TTCN_Logger::EXECUTOR_EXTCOMMAND);
1535 $$.add_sev(TTCN_Logger::EXECUTOR_COMPONENT);
1536 $$.add_sev(TTCN_Logger::EXECUTOR_LOGOPTIONS);
1537 $$.add_sev(TTCN_Logger::EXECUTOR_UNQUALIFIED);
1539 case TTCN_Logger::FUNCTION_UNQUALIFIED:
1540 $$.add_sev(TTCN_Logger::FUNCTION_RND);
1541 $$.add_sev(TTCN_Logger::FUNCTION_UNQUALIFIED);
1543 case TTCN_Logger::PARALLEL_UNQUALIFIED:
1544 $$.add_sev(TTCN_Logger::PARALLEL_PTC);
1545 $$.add_sev(TTCN_Logger::PARALLEL_PORTCONN);
1546 $$.add_sev(TTCN_Logger::PARALLEL_PORTMAP);
1547 $$.add_sev(TTCN_Logger::PARALLEL_UNQUALIFIED);
1549 case TTCN_Logger::PORTEVENT_UNQUALIFIED:
1550 $$.add_sev(TTCN_Logger::PORTEVENT_PQUEUE);
1551 $$.add_sev(TTCN_Logger::PORTEVENT_MQUEUE);
1552 $$.add_sev(TTCN_Logger::PORTEVENT_STATE);
1553 $$.add_sev(TTCN_Logger::PORTEVENT_PMIN);
1554 $$.add_sev(TTCN_Logger::PORTEVENT_PMOUT);
1555 $$.add_sev(TTCN_Logger::PORTEVENT_PCIN);
1556 $$.add_sev(TTCN_Logger::PORTEVENT_PCOUT);
1557 $$.add_sev(TTCN_Logger::PORTEVENT_MMRECV);
1558 $$.add_sev(TTCN_Logger::PORTEVENT_MMSEND);
1559 $$.add_sev(TTCN_Logger::PORTEVENT_MCRECV);
1560 $$.add_sev(TTCN_Logger::PORTEVENT_MCSEND);
1561 $$.add_sev(TTCN_Logger::PORTEVENT_DUALRECV);
1562 $$.add_sev(TTCN_Logger::PORTEVENT_DUALSEND);
1563 $$.add_sev(TTCN_Logger::PORTEVENT_UNQUALIFIED);
1565 case TTCN_Logger::TESTCASE_UNQUALIFIED:
1566 $$.add_sev(TTCN_Logger::TESTCASE_START);
1567 $$.add_sev(TTCN_Logger::TESTCASE_FINISH);
1568 $$.add_sev(TTCN_Logger::TESTCASE_UNQUALIFIED);
1570 case TTCN_Logger::TIMEROP_UNQUALIFIED:
1571 $$.add_sev(TTCN_Logger::TIMEROP_READ);
1572 $$.add_sev(TTCN_Logger::TIMEROP_START);
1573 $$.add_sev(TTCN_Logger::TIMEROP_GUARD);
1574 $$.add_sev(TTCN_Logger::TIMEROP_STOP);
1575 $$.add_sev(TTCN_Logger::TIMEROP_TIMEOUT);
1576 $$.add_sev(TTCN_Logger::TIMEROP_UNQUALIFIED);
1578 case TTCN_Logger::USER_UNQUALIFIED:
1579 $$.add_sev(TTCN_Logger::USER_UNQUALIFIED);
1581 case TTCN_Logger::STATISTICS_UNQUALIFIED:
1582 $$.add_sev(TTCN_Logger::STATISTICS_VERDICT);
1583 $$.add_sev(TTCN_Logger::STATISTICS_UNQUALIFIED);
1585 case TTCN_Logger::VERDICTOP_UNQUALIFIED:
1586 $$.add_sev(TTCN_Logger::VERDICTOP_GETVERDICT);
1587 $$.add_sev(TTCN_Logger::VERDICTOP_SETVERDICT);
1588 $$.add_sev(TTCN_Logger::VERDICTOP_FINAL);
1589 $$.add_sev(TTCN_Logger::VERDICTOP_UNQUALIFIED);
1591 case TTCN_Logger::WARNING_UNQUALIFIED:
1592 $$.add_sev(TTCN_Logger::WARNING_UNQUALIFIED);
1594 case TTCN_Logger::MATCHING_UNQUALIFIED:
1595 $$.add_sev(TTCN_Logger::MATCHING_DONE);
1596 $$.add_sev(TTCN_Logger::MATCHING_TIMEOUT);
1597 $$.add_sev(TTCN_Logger::MATCHING_PCSUCCESS);
1598 $$.add_sev(TTCN_Logger::MATCHING_PCUNSUCC);
1599 $$.add_sev(TTCN_Logger::MATCHING_PMSUCCESS);
1600 $$.add_sev(TTCN_Logger::MATCHING_PMUNSUCC);
1601 $$.add_sev(TTCN_Logger::MATCHING_MCSUCCESS);
1602 $$.add_sev(TTCN_Logger::MATCHING_MCUNSUCC);
1603 $$.add_sev(TTCN_Logger::MATCHING_MMSUCCESS);
1604 $$.add_sev(TTCN_Logger::MATCHING_MMUNSUCC);
1605 $$.add_sev(TTCN_Logger::MATCHING_PROBLEM);
1606 $$.add_sev(TTCN_Logger::MATCHING_UNQUALIFIED);
1608 case TTCN_Logger::DEBUG_UNQUALIFIED:
1609 $$.add_sev(TTCN_Logger::DEBUG_ENCDEC);
1610 $$.add_sev(TTCN_Logger::DEBUG_TESTPORT);
1611 $$.add_sev(TTCN_Logger::DEBUG_USER);
1612 $$.add_sev(TTCN_Logger::DEBUG_FRAMEWORK);
1613 $$.add_sev(TTCN_Logger::DEBUG_UNQUALIFIED);
1615 case TTCN_Logger::LOG_ALL_IMPORTANT:
1616 $$ = Logging_Bits::log_all;
1619 /* The lexer sent something the parser doesn't understand!
1620 Parser needs to be updated.
1622 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
1623 "Internal error: unknown logbit from lexer.");
1630 LoggingBitOrCollection
1634 | LoggingBitmask '|' LoggingBitOrCollection
1642 SourceInfoValue { $$ = $1; }
1645 $$ = $1 ? TTCN_Logger::SINFO_SINGLE : TTCN_Logger::SINFO_NONE;
1651 | BooleanValue { $$ = $1; }
1655 YesNoOrBoolean { $$ = $1 ? TTCN_Logger::LOGEVENTTYPES_YES :
1656 TTCN_Logger::LOGEVENTTYPES_NO; }
1657 | SubCategories { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1658 | Detailed { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1661 /*********************** [PROFILER] ********************************/
1664 ProfilerKeyword ProfilerSettings
1669 | ProfilerSettings ProfilerSetting optSemiColon
1673 DisableProfilerSetting
1674 | DisableCoverageSetting
1675 | DatabaseFileSetting
1676 | AggregateDataSetting
1677 | StatisticsFileSetting
1678 | DisableStatisticsSetting
1679 | StatisticsFilterSetting
1680 | StartAutomaticallySetting
1681 | NetLineTimesSetting
1682 | NetFunctionTimesSetting
1685 DisableProfilerSetting:
1686 DisableProfilerKeyword AssignmentChar BooleanValue {
1687 ttcn3_prof.set_disable_profiler($3);
1691 DisableCoverageSetting:
1692 DisableCoverageKeyword AssignmentChar BooleanValue {
1693 ttcn3_prof.set_disable_coverage($3);
1697 DatabaseFileSetting:
1698 DatabaseFileKeyword AssignmentChar StringValue {
1699 ttcn3_prof.set_database_filename($3);
1703 AggregateDataSetting:
1704 AggregateDataKeyword AssignmentChar BooleanValue {
1705 ttcn3_prof.set_aggregate_data($3);
1709 StatisticsFileSetting:
1710 StatisticsFileKeyword AssignmentChar StringValue {
1711 ttcn3_prof.set_stats_filename($3);
1715 DisableStatisticsSetting:
1716 DisableStatisticsKeyword AssignmentChar BooleanValue {
1717 ttcn3_prof.set_disable_stats($3);
1721 StatisticsFilterSetting:
1722 StatisticsFilterKeyword AssignmentChar ProfilerStatsFlags {
1723 ttcn3_prof.reset_stats_flags();
1724 ttcn3_prof.add_stats_flags($3);
1726 | StatisticsFilterKeyword ConcatChar ProfilerStatsFlags {
1727 ttcn3_prof.add_stats_flags($3);
1732 ProfilerStatsFlag { $$ = $1; }
1733 | ProfilerStatsFlag '&' ProfilerStatsFlags { $$ = $1 | $3; }
1734 | ProfilerStatsFlag '|' ProfilerStatsFlags { $$ = $1 | $3; }
1737 StartAutomaticallySetting:
1738 StartAutomaticallyKeyword AssignmentChar BooleanValue {
1748 NetLineTimesSetting:
1749 NetLineTimesKeyword AssignmentChar BooleanValue {
1750 TTCN3_Stack_Depth::set_net_line_times($3);
1754 NetFunctionTimesSetting:
1755 NetFunctionTimesKeyword AssignmentChar BooleanValue {
1756 TTCN3_Stack_Depth::set_net_func_times($3);
1761 /**************** [TESTPORT_PARAMETERS] ****************************/
1763 TestportParametersSection:
1764 TestportParametersKeyword TestportParameterList
1767 TestportParameterList:
1769 | TestportParameterList TestportParameter optSemiColon
1773 ComponentId '.' TestportName '.' TestportParameterName AssignmentChar
1774 TestportParameterValue
1776 PORT::add_parameter($1, $3, $5, $7);
1777 if ($1.id_selector == COMPONENT_ID_NAME) Free($1.id_name);
1787 $$.id_selector = COMPONENT_ID_NAME;
1792 $$.id_selector = COMPONENT_ID_NAME;
1793 $$.id_name = $1.chars_ptr;
1797 $$.id_selector = COMPONENT_ID_COMPREF;
1798 $$.id_compref = (component)$1->get_val();
1803 $$.id_selector = COMPONENT_ID_COMPREF;
1804 $$.id_compref = MTC_COMPREF;
1808 $$.id_selector = COMPONENT_ID_ALL;
1813 $$.id_selector = COMPONENT_ID_SYSTEM;
1819 Identifier { $$ = $1; }
1820 | Identifier ArrayRef
1822 $$ = mputstr($1, $2);
1825 | '*' { $$ = NULL; }
1829 '[' IntegerValue ']'
1831 char *s = $2->as_string();
1833 $$ = mputc ($$, '[');
1834 $$ = mputstr($$, s);
1835 $$ = mputc ($$, ']');
1839 | ArrayRef '[' IntegerValue ']'
1841 char *s = $3->as_string();
1842 $$ = mputc ($1, '[');
1843 $$ = mputstr($$, s);
1844 $$ = mputc ($$, ']');
1850 TestportParameterName:
1851 Identifier { $$ = $1; }
1854 TestportParameterValue:
1855 StringValue { $$ = $1; }
1858 /****************** [EXECUTE] section *************/
1861 ExecuteKeyword ExecuteList
1863 if (!TTCN_Runtime::is_single()) config_process_error("Internal error: "
1864 "the Main Controller must not send section [EXECUTE] of the "
1865 "configuration file.");
1871 | ExecuteList ExecuteItem optSemiColon
1873 if (TTCN_Runtime::is_single()) {
1874 execute_list = (execute_list_item *)Realloc(
1875 execute_list, (execute_list_len + 1) *
1876 sizeof(*execute_list));
1877 execute_list[execute_list_len++] = $2;
1879 Free($2.module_name);
1880 Free($2.testcase_name);
1888 $$.module_name = $1;
1889 $$.testcase_name = NULL;
1891 | Identifier '.' ControlKeyword
1893 $$.module_name = $1;
1894 $$.testcase_name = NULL;
1896 | Identifier '.' Identifier
1898 $$.module_name = $1;
1899 $$.testcase_name = $3;
1901 | Identifier '.' '*'
1903 $$.module_name = $1;
1904 $$.testcase_name = mcopystr("*");
1908 /****************** [EXTERNAL_COMMANDS] section **********************/
1910 ExternalCommandsSection:
1911 ExternalCommandsKeyword ExternalCommandList
1914 ExternalCommandList:
1916 | ExternalCommandList ExternalCommand optSemiColon
1920 BeginControlPart AssignmentChar Command
1922 check_duplicate_option("EXTERNAL_COMMANDS", "BeginControlPart",
1923 begin_controlpart_command_set);
1925 TTCN_Runtime::set_begin_controlpart_command($3);
1929 | EndControlPart AssignmentChar Command
1931 check_duplicate_option("EXTERNAL_COMMANDS", "EndControlPart",
1932 end_controlpart_command_set);
1934 TTCN_Runtime::set_end_controlpart_command($3);
1938 | BeginTestCase AssignmentChar Command
1940 check_duplicate_option("EXTERNAL_COMMANDS", "BeginTestCase",
1941 begin_testcase_command_set);
1943 TTCN_Runtime::set_begin_testcase_command($3);
1947 | EndTestCase AssignmentChar Command
1949 check_duplicate_option("EXTERNAL_COMMANDS", "EndTestCase",
1950 end_testcase_command_set);
1952 TTCN_Runtime::set_end_testcase_command($3);
1959 StringValue { $$ = $1; }
1962 /***************** [GROUPS] section *******************/
1965 GroupsKeyword GroupList
1967 check_ignored_section("GROUPS");
1973 | GroupList Group optSemiColon
1977 GroupName AssignmentChar GroupMembers
1981 Identifier { Free($1); }
1991 | seqGroupMember ',' HostName
1996 | Identifier { Free($1); }
1999 /******************** [COMPONENTS] section *******************/
2001 ComponentsKeyword ComponentList
2003 check_ignored_section("COMPONENTS");
2009 | ComponentList ComponentItem optSemiColon
2013 ComponentName AssignmentChar ComponentLocation
2017 Identifier { Free($1); }
2022 Identifier { Free($1); }
2026 /****************** [MAIN_CONTROLLER] section *********************/
2027 MainControllerSection:
2028 MainControllerKeyword MCParameterList
2030 check_ignored_section("MAIN_CONTROLLER");
2036 | MCParameterList MCParameter optSemiColon
2040 LocalAddress AssignmentChar HostName { }
2041 | TCPPort AssignmentChar IntegerValue { delete $3; }
2042 | KillTimer AssignmentChar KillTimerValue { }
2043 | NumHCs AssignmentChar IntegerValue { delete $3; }
2044 | UnixSocketEnabled AssignmentChar YesToken {}
2045 | UnixSocketEnabled AssignmentChar NoToken {}
2046 | UnixSocketEnabled AssignmentChar HostName {}
2051 | IntegerValue { delete $1; }
2054 /****************** [INCLUDE] section *********************/
2056 IncludeKeyword IncludeFiles
2058 if(!TTCN_Runtime::is_single())
2059 config_process_error
2060 ("Internal error: the Main Controller must not send section [INCLUDE]"
2061 " of the configuration file.");
2067 | IncludeFiles IncludeFile
2071 Cstring { Free($1.chars_ptr); }
2074 /****************** [DEFINE] section *********************/
2078 if(!TTCN_Runtime::is_single())
2079 config_process_error
2080 ("Internal error: the Main Controller must not send section [DEFINE]"
2081 " of the configuration file.");
2085 /*********************************************************/
2090 $$ = Module_Param::OT_ASSIGN;
2095 $$ = Module_Param::OT_CONCAT;
2106 static void reset_configuration_options()
2108 /* Section [MODULE_PARAMETERS */
2109 /** \todo reset module parameters to their default values */
2110 /* Section [LOGGING] */
2111 TTCN_Logger::close_file();
2112 TTCN_Logger::reset_configuration();
2113 file_name_set = FALSE;
2114 file_mask_set = TRUE;
2115 console_mask_set = TRUE;
2116 timestamp_format_set = FALSE;
2117 source_info_format_set = FALSE;
2118 append_file_set = FALSE;
2119 log_event_types_set = FALSE;
2120 log_entity_name_set = FALSE;
2121 /* Section [TESTPORT_PARAMETERS] */
2122 PORT::clear_parameters();
2123 /* Section [EXTERNAL_COMMANDS] */
2125 TTCN_Runtime::clear_external_commands();
2127 begin_controlpart_command_set = FALSE;
2128 end_controlpart_command_set = FALSE;
2129 begin_testcase_command_set = FALSE;
2130 end_testcase_command_set = FALSE;
2133 Module_Param* process_config_string2ttcn(const char* mp_str, bool is_component)
2135 if (parsed_module_param!=NULL || parsing_error_messages!=NULL) TTCN_error("Internal error: previously parsed ttcn string was not cleared.");
2136 // add the hidden keyword
2137 std::string mp_string = (is_component) ? std::string("$#&&&(#TTCNSTRINGPARSING_COMPONENT$#&&^#% ") + mp_str
2138 : std::string("$#&&&(#TTCNSTRINGPARSING$#&&^#% ") + mp_str;
2139 struct yy_buffer_state *flex_buffer = config_process__scan_bytes(mp_string.c_str(), (int)mp_string.size());
2140 if (flex_buffer == NULL) TTCN_error("Internal error: flex buffer creation failed.");
2141 reset_config_process_lex(NULL);
2144 Ttcn_String_Parsing ttcn_string_parsing;
2145 if (config_process_parse()) error_flag = TRUE;
2146 } catch (const TC_Error& TC_error) {
2147 if (parsed_module_param!=NULL) { delete parsed_module_param; parsed_module_param = NULL; }
2150 config_process_close();
2151 config_process_lex_destroy();
2153 if (error_flag || parsing_error_messages!=NULL) {
2154 delete parsed_module_param;
2155 parsed_module_param = NULL;
2156 char* pem = parsing_error_messages!=NULL ? parsing_error_messages : mcopystr("Unknown parsing error");
2157 parsing_error_messages = NULL;
2158 TTCN_error_begin("%s", pem);
2163 if (parsed_module_param==NULL) TTCN_error("Internal error: could not parse ttcn string.");
2164 Module_Param* ret_val = parsed_module_param;
2165 parsed_module_param = NULL;
2170 boolean process_config_string(const char *config_string, int string_len)
2174 struct yy_buffer_state *flex_buffer =
2175 config_process__scan_bytes(config_string, string_len);
2176 if (flex_buffer == NULL) {
2177 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
2178 "Internal error: flex buffer creation failed.");
2183 reset_configuration_options();
2184 reset_config_process_lex(NULL);
2186 if (config_process_parse()) error_flag = TRUE;
2188 } catch (const TC_Error& TC_error) {
2192 config_process_close();
2193 config_process_lex_destroy();
2199 boolean process_config_file(const char *file_name)
2202 string_chain_t *filenames=NULL;
2204 reset_configuration_options();
2206 if(preproc_parse_file(file_name, &filenames, &config_defines))
2210 char *fn=string_chain_cut(&filenames);
2211 reset_config_process_lex(fn);
2212 /* The lexer can modify config_process_in
2213 * when it's input buffer is changed */
2214 config_process_in = fopen(fn, "r");
2215 FILE* tmp_cfg = config_process_in;
2216 if (config_process_in != NULL) {
2218 if(config_process_parse()) error_flag=TRUE;
2219 } catch (const TC_Error& TC_error) {
2223 config_process_close();
2224 config_process_lex_destroy();
2226 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2227 TTCN_Logger::log_event("Cannot open configuration file: %s", fn);
2228 TTCN_Logger::OS_error();
2229 TTCN_Logger::end_event();
2232 /* During parsing flex or libc may use some system calls (e.g. ioctl)
2233 * that fail with an error status. Such error codes shall be ignored in
2234 * future error messages. */
2240 string_map_free(config_defines);
2241 config_defines = NULL;
2246 void config_process_error_f(const char *error_str, ...)
2248 if (Ttcn_String_Parsing::happening()) {
2250 va_start(p_var, error_str);
2251 char* error_msg_str = mprintf_va_list(error_str, p_var);
2253 if (parsing_error_messages!=NULL) parsing_error_messages = mputc(parsing_error_messages, '\n');
2254 parsing_error_messages = mputprintf(parsing_error_messages,
2255 "Parse error in line %d, at or before token `%s': %s", config_process_get_current_line(), config_process_text, error_msg_str);
2256 Free(error_msg_str);
2260 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2261 if (!get_cfg_process_current_file().empty()) {
2262 TTCN_Logger::log_event("Parse error in configuration file `%s': in line %d, "
2263 "at or before token `%s': ",
2264 get_cfg_process_current_file().c_str(), config_process_get_current_line(),
2268 TTCN_Logger::log_event("Parse error while reading configuration "
2269 "information: in line %d, at or before token `%s': ",
2270 config_process_get_current_line(), config_process_text);
2273 va_start(pvar, error_str);
2274 TTCN_Logger::log_event_va_list(error_str, pvar);
2276 TTCN_Logger::end_event();
2280 void config_process_error(const char *error_str)
2282 config_process_error_f("%s", error_str);
2285 void config_preproc_error(const char *error_str, ...)
2287 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2288 TTCN_Logger::log_event("Parse error while pre-processing configuration"
2289 " file `%s': in line %d: ",
2290 get_cfg_preproc_current_file().c_str(),
2291 config_preproc_yylineno);
2293 va_start(pvar, error_str);
2294 TTCN_Logger::log_event_va_list(error_str, pvar);
2296 TTCN_Logger::end_event();
2300 void path_error(const char *fmt, ...)
2303 fprintf(stderr, "File error: ");
2304 va_start(parameters, fmt);
2305 vfprintf(stderr, fmt, parameters);
2307 fprintf(stderr, "\n");
2310 static void check_duplicate_option(const char *section_name,
2311 const char *option_name, boolean& option_flag)
2314 TTCN_warning("Option `%s' was given more than once in section [%s] of the "
2315 "configuration file.", option_name, section_name);
2316 } else option_flag = TRUE;
2319 static void check_ignored_section(const char *section_name)
2321 if (TTCN_Runtime::is_single()) TTCN_warning("Section [%s] of "
2322 "configuration file is ignored in single mode.", section_name);
2323 else config_process_error_f("Internal error: the Main Controller must not "
2324 "send section [%s] of the configuration file.", section_name);
2327 static void set_param(Module_Param& param)
2330 Module_List::set_param(param);
2332 catch (const TC_Error& TC_error) {
2337 unsigned char char_to_hexdigit(char c)
2339 if (c >= '0' && c <= '9') return c - '0';
2340 else if (c >= 'A' && c <= 'F') return c - 'A' + 10;
2341 else if (c >= 'a' && c <= 'f') return c - 'a' + 10;
2343 config_process_error_f("char_to_hexdigit(): invalid argument: %c", c);
2344 return 0; // to avoid warning