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
20 * Szabo, Janos Zoltan – initial implementation
22 * Zalanyi, Balazs Andor
24 ******************************************************************************/
34 #include <openssl/bn.h>
36 #include "../common/config_preproc.h"
38 #include "Param_Types.hh"
43 #include "Verdicttype.hh"
44 #include "Bitstring.hh"
45 #include "Hexstring.hh"
46 #include "Octetstring.hh"
47 #include "Charstring.hh"
48 #include "Universal_charstring.hh"
50 #include "Module_list.hh"
54 #include "LoggingBits.hh"
55 #include "LoggingParam.hh"
57 #include "Profiler.hh"
59 #define YYERROR_VERBOSE
61 #include "config_process.lex.hh"
63 extern void reset_config_process_lex(const char* fname);
64 extern void config_process_close();
65 extern int config_process_get_current_line();
66 extern std::string get_cfg_process_current_file();
68 static int config_process_parse();
69 static void check_duplicate_option(const char *section_name,
70 const char *option_name, boolean& option_flag);
71 static void check_ignored_section(const char *section_name);
72 static void set_param(Module_Param& module_param);
73 static unsigned char char_to_hexdigit(char c);
75 static boolean error_flag = FALSE;
77 static Module_Param* parsed_module_param = NULL;
78 static char * parsing_error_messages = NULL;
81 For detecting duplicate entries in the config file. Start out as FALSE,
82 set to TRUE bycheck_duplicate_option().
83 Exception: duplication of parameters that can be component specific is checked
84 by set_xxx(), these start out as TRUE.
86 static boolean file_name_set = FALSE,
88 console_mask_set = TRUE,
89 timestamp_format_set = FALSE,
90 source_info_format_set = FALSE,
91 append_file_set = FALSE,
92 log_event_types_set = FALSE,
93 log_entity_name_set = FALSE,
94 begin_controlpart_command_set = FALSE,
95 end_controlpart_command_set = FALSE,
96 begin_testcase_command_set = FALSE,
97 end_testcase_command_set = FALSE,
98 log_file_size_set = TRUE,
99 log_file_number_set = TRUE,
100 log_disk_full_action_set = TRUE,
101 matching_verbosity_set = FALSE,
102 logger_plugins_set = FALSE,
103 plugin_specific_set = FALSE;
105 int execute_list_len = 0;
106 execute_list_item *execute_list = NULL;
108 string_map_t *config_defines;
116 unsigned int uint_val;
119 param_objid_t objid_val;
120 verdicttype verdict_val;
121 param_bitstring_t bitstring_val;
122 param_hexstring_t hexstring_val;
123 param_charstring_t charstring_val;
124 param_octetstring_t octetstring_val;
125 universal_char universal_char_val;
126 param_universal_charstring_t universal_charstring_val;
127 Module_Param::operation_type_t param_optype_val;
128 Vector<Module_Param*>* module_param_list;
129 Module_Param* module_param_val;
130 Module_Param_Length_Restriction* module_param_length_restriction;
131 Vector<char*>* name_vector;
132 component_id_t comp_id;
133 execute_list_item execute_item_val;
134 TTCN_Logger::emergency_logging_behaviour_t emergency_logging_behaviour_value;
135 TTCN_Logger::timestamp_format_t timestamp_value;
136 TTCN_Logger::source_info_format_t source_info_value;
137 TTCN_Logger::log_event_types_t log_event_types_value;
138 TTCN_Logger::disk_full_action_t disk_full_action_value;
139 TTCN_Logger::matching_verbosity_t matching_verbosity_value;
140 TTCN_Logger::Severity logseverity_val;
141 Logging_Bits logoptions_val;
143 logging_plugin_t *logging_plugins;
144 logging_param_t logging_params;
145 logging_setting_t logging_param_line;
148 %token ModuleParametersKeyword
149 %token LoggingKeyword
150 %token ProfilerKeyword
151 %token TestportParametersKeyword
152 %token ExecuteKeyword
153 %token ExternalCommandsKeyword
155 %token ComponentsKeyword
156 %token MainControllerKeyword
157 %token IncludeKeyword
162 %token ObjIdKeyword "objid"
163 %token CharKeyword "char"
164 %token ControlKeyword "control"
165 %token MTCKeyword "mtc"
166 %token SystemKeyword "system"
167 %token NULLKeyword "NULL"
168 %token nullKeyword "null"
169 %token OmitKeyword "omit"
170 %token ComplementKeyword "complement"
172 %token SupersetKeyword "superset"
173 %token SubsetKeyword "subset"
174 %token PatternKeyword "pattern"
175 %token PermutationKeyword "permutation"
176 %token LengthKeyword "length"
177 %token IfpresentKeyword "ifpresent"
178 %token InfinityKeyword "infinity"
179 %token AssignmentChar ":= or ="
180 %token ConcatChar "&="
181 %token LogFile "LogFile or FileName"
182 %token EmergencyLogging
183 %token EmergencyLoggingBehaviour
184 %token EmergencyLoggingMask
185 %token EmergencyLoggingForFailVerdict
190 %token TimestampFormat
191 %token ConsoleTimestampFormat
192 %token SourceInfoFormat "LogSourceInfo or SourceInfoFormat"
196 %token BeginControlPart
197 %token EndControlPart
200 %token <str_val> Identifier
201 %token <str_val> ASN1LowerIdentifier "ASN.1 identifier beginning with a lowercase letter"
202 %token <int_val> Number MPNumber "integer value"
203 %token <float_val> Float MPFloat "float value"
204 %token <bool_val> BooleanValue "true or false"
205 %token <verdict_val> VerdictValue
206 %token <bitstring_val> Bstring "bit string value"
207 %token <hexstring_val> Hstring "hex string value"
208 %token <octetstring_val> Ostring "octet string value"
209 %token <str_val> BstringMatch "bit string template"
210 %token <str_val> HstringMatch "hex string template"
211 %token <str_val> OstringMatch "octet string template"
212 %token <charstring_val> Cstring MPCstring "charstring value"
213 %token DNSName "hostname"
215 %token <logseverity_val> LoggingBit
216 /* a collection of bits */
217 %token <logseverity_val> LoggingBitCollection
219 %token <emergency_logging_behaviour_value> EmergencyLoggingBehaviourValue "BufferAll or BufferMasked"
220 %token <timestamp_value> TimestampValue "Time, Datetime or Seconds"
221 %token <source_info_value> SourceInfoValue "None, Single or Stack"
222 %token <bool_val> YesNo "yes or no"
227 %token UnixSocketEnabled
228 %token YesToken "yes"
232 %token DiskFullAction
239 %token TtcnStringParsingKeyword
240 %token DisableProfilerKeyword "DisableProfiler"
241 %token DisableCoverageKeyword "DisableCoverage"
242 %token DatabaseFileKeyword "DatabaseFile"
243 %token AggregateDataKeyword "AggregateData"
244 %token StatisticsFileKeyword "StatisticsFile"
245 %token DisableStatisticsKeyword "DisableStatistics"
246 %token StatisticsFilterKeyword "StatisticsFilter"
247 %token StartAutomaticallyKeyword "StartAutomatically"
248 %token NetLineTimesKeyword "NetLineTimes"
249 %token NetFunctionTimesKeyword "NetFunctionTimes"
250 %token <uint_val> ProfilerStatsFlag "profiler statistics filter"
252 %type <int_val> IntegerValue
253 %type <float_val> FloatValue
254 %type <objid_val> ObjIdValue ObjIdComponentList
255 %type <int_val> ObjIdComponent NumberForm NameAndNumberForm
257 %type <universal_charstring_val> UniversalCharstringValue UniversalCharstringFragment
258 %type <universal_char_val> Quadruple
260 %type <str_val> LoggerPluginId
261 %type <logging_plugins> LoggerPlugin LoggerPluginList
262 %type <logging_params> LoggingParam
263 %type <logging_param_line> LoggingParamLines
264 %type <str_val> LogFileName StringValue
265 /* a collection of bits */
266 %type <logoptions_val> LoggingBitmask
267 %type <logoptions_val> LoggingBitOrCollection
268 %type <source_info_value> SourceInfoSetting
269 %type <bool_val> YesNoOrBoolean
270 %type <log_event_types_value> LogEventTypesValue
271 %type <disk_full_action_value> DiskFullActionValue
272 %type <str_val> Command
273 %type <matching_verbosity_value> VerbosityValue
274 %type <comp_id> ComponentId
275 %type <str_val> TestportName ArrayRef TestportParameterName
276 TestportParameterValue
278 %type <execute_item_val> ExecuteItem
280 %type <bitstring_val> BitstringValue
281 %type <hexstring_val> HexstringValue
282 %type <octetstring_val> OctetstringValue
284 %type <name_vector> ParameterName ParameterNameSegment
285 %type <param_optype_val> ParamOpType
286 %type <str_val> FieldName
287 %type <module_param_val> ParameterValue SimpleParameterValue ParameterValueOrNotUsedSymbol
288 FieldValue ArrayItem IndexItem IndexItemList FieldValueList ArrayItemList CompoundValue IntegerRange FloatRange StringRange
289 ParameterExpression ParameterReference
290 %type <module_param_list> TemplateItemList
291 %type <module_param_length_restriction> LengthMatch
292 %type <str_val> PatternChunk
293 %type <int_native> IndexItemIndex LengthBound
294 %type <uint_val> ProfilerStatsFlags
296 %destructor { Free($$); }
305 TestportParameterName
306 TestportParameterValue
312 %destructor { Free($$.components_ptr); }
316 %destructor { Free($$.bits_ptr); }
320 %destructor { Free($$.nibbles_ptr); }
324 %destructor { Free($$.octets_ptr); }
328 %destructor { Free($$.chars_ptr); }
332 %destructor { Free($$.uchars_ptr); }
333 UniversalCharstringFragment
334 UniversalCharstringValue
336 %destructor { if ($$.id_selector == COMPONENT_ID_NAME) Free($$.id_name); }
339 %destructor { Free($$.module_name); Free($$.testcase_name); }
342 %destructor { delete $$; }
351 ParameterValueOrNotUsedSymbol
365 %destructor { delete $$; }
368 %destructor { for(size_t i=0; i<$$->size(); i++) { delete $$->at(i); } delete $$; }
371 %destructor { for(size_t i=0; i<$$->size(); i++) { Free($$->at(i)); } delete $$; }
375 %left '&' /* to avoid shift/reduce conflicts */
384 When seeing a '*' token after a module parameter expression the parser cannot
385 decide whether the token is a multiplication operator (shift) or it refers to
386 all modules in the next module parameter (reduce).
393 if (Ttcn_String_Parsing::happening()) {
394 config_process_error("Config file cannot be parsed as ttcn string");
397 | TtcnStringParsingKeyword ParameterValue
399 parsed_module_param = $2;
409 ModuleParametersSection
412 | TestportParametersSection
414 | ExternalCommandsSection
417 | MainControllerSection
422 ModuleParametersSection:
423 ModuleParametersKeyword ModuleParameters
428 | ModuleParameters ModuleParameter optSemiColon
432 ParameterName ParamOpType ParameterValue
434 Module_Param* mp = $3;
435 mp->set_id(new Module_Param_Name(*$1));
436 mp->set_operation_type($2);
444 ParameterNameSegment { $$ = $1; }
445 | '*' '.' ParameterNameSegment { $$ = $3; }
448 ParameterNameSegment:
449 ParameterNameSegment '.' Identifier
454 | ParameterNameSegment IndexItemIndex
457 $$->push_back(mprintf("%d", $2));
461 $$ = new Vector<char*>();
471 | ParameterExpression LengthMatch
474 $$->set_length_restriction($2);
476 | ParameterExpression IfpresentKeyword
481 | ParameterExpression LengthMatch IfpresentKeyword
484 $$->set_length_restriction($2);
490 LengthKeyword '(' LengthBound ')'
492 $$ = new Module_Param_Length_Restriction();
493 $$->set_single((size_t)$3);
495 | LengthKeyword '(' LengthBound DotDot LengthBound ')'
498 config_process_error("invalid length restriction: lower bound > upper bound");
500 $$ = new Module_Param_Length_Restriction();
501 $$->set_min((size_t)$3);
502 $$->set_max((size_t)$5);
504 | LengthKeyword '(' LengthBound DotDot InfinityKeyword ')'
506 $$ = new Module_Param_Length_Restriction();
507 $$->set_min((size_t)$3);
514 $1->set_id(new Module_Param_CustomName(mcopystr("length bound")));
517 if (!tmp.get_val().is_native()) {
518 config_process_error("bignum length restriction bound.");
520 } else if (tmp.get_val().is_negative()) {
521 config_process_error("negative length restriction bound.");
530 // one global rule for expressions in module parameters
531 // the expression's result will be calculated by set_param()
533 SimpleParameterValue { $$ = $1; }
534 | ParameterReference { $$ = $1; }
535 | '(' ParameterExpression ')' { $$ = $2; }
536 | '+' ParameterExpression %prec UnarySign { $$ = $2; }
537 | '-' ParameterExpression %prec UnarySign { $$ = new Module_Param_Expression($2); }
538 | ParameterExpression '+' ParameterExpression
540 $$ = new Module_Param_Expression(Module_Param::EXPR_ADD, $1, $3);
542 | ParameterExpression '-' ParameterExpression
544 $$ = new Module_Param_Expression(Module_Param::EXPR_SUBTRACT, $1, $3);
546 | ParameterExpression '*' ParameterExpression
548 $$ = new Module_Param_Expression(Module_Param::EXPR_MULTIPLY, $1, $3);
550 | ParameterExpression '/' ParameterExpression
552 $$ = new Module_Param_Expression(Module_Param::EXPR_DIVIDE, $1, $3);
554 | ParameterExpression '&' ParameterExpression
556 $$ = new Module_Param_Expression(Module_Param::EXPR_CONCATENATE, $1, $3);
561 // enumerated values are also treated as references by the parser,
562 // these will be sorted out later during set_param()
565 $$ = new Module_Param_Reference(new Module_Param_Name(*$1));
569 SimpleParameterValue:
572 $$ = new Module_Param_Integer($1);
576 $$ = new Module_Param_Float($1);
580 $$ = new Module_Param_Boolean($1);
584 $$ = new Module_Param_Objid($1.n_components, $1.components_ptr);
588 $$ = new Module_Param_Verdict($1);
592 $$ = new Module_Param_Bitstring($1.n_bits, $1.bits_ptr);
596 $$ = new Module_Param_Hexstring($1.n_nibbles, $1.nibbles_ptr);
600 $$ = new Module_Param_Octetstring($1.n_octets, $1.octets_ptr);
604 $$ = new Module_Param_Charstring($1.n_chars, $1.chars_ptr);
606 | UniversalCharstringValue
608 $$ = new Module_Param_Universal_Charstring($1.n_uchars, $1.uchars_ptr);
612 $$ = new Module_Param_Omit();
616 $$ = new Module_Param_Asn_Null();
620 $$ = new Module_Param_Ttcn_Null();
624 $$ = new Module_Param_Ttcn_mtc();
628 $$ = new Module_Param_Ttcn_system();
632 $$ = new Module_Param_Any();
636 $$ = new Module_Param_AnyOrNone();
650 | PatternKeyword PatternChunk
652 $$ = new Module_Param_Pattern($2);
657 int n_chars = (int)mstrlen($1);
658 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
659 for (int i=0; i<n_chars; i++) {
675 config_process_error_f("Invalid char (%c) in bitstring template", $1[i]);
679 $$ = new Module_Param_Bitstring_Template(n_chars, chars_ptr);
683 int n_chars = (int)mstrlen($1);
684 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
685 for (int i=0; i<n_chars; i++) {
686 if ($1[i]=='?') chars_ptr[i] = 16;
687 else if ($1[i]=='*') chars_ptr[i] = 17;
688 else chars_ptr[i] = char_to_hexdigit($1[i]);
691 $$ = new Module_Param_Hexstring_Template(n_chars, chars_ptr);
695 Vector<unsigned short> octet_vec;
696 int str_len = (int)mstrlen($1);
697 for (int i=0; i<str_len; i++) {
699 if ($1[i]=='?') num = 256;
700 else if ($1[i]=='*') num = 257;
703 num = 16 * char_to_hexdigit($1[i]);
705 if (i>=str_len) config_process_error("Unexpected end of octetstring pattern");
707 num += char_to_hexdigit($1[i]);
709 octet_vec.push_back(num);
712 int n_chars = (int)octet_vec.size();
713 unsigned short* chars_ptr = (unsigned short*)Malloc(n_chars*sizeof(unsigned short));
714 for (int i=0; i<n_chars; i++) chars_ptr[i] = octet_vec[i];
715 $$ = new Module_Param_Octetstring_Template(n_chars, chars_ptr);
726 $$ = mcopystr($1.chars_ptr);
731 $$ = mprintf("\\q{%d,%d,%d,%d}", $1.uc_group, $1.uc_plane, $1.uc_row, $1.uc_cell);
736 '(' '-' InfinityKeyword DotDot MPNumber ')'
738 $$ = new Module_Param_IntRange(NULL, $5);
740 | '(' MPNumber DotDot MPNumber ')'
742 $$ = new Module_Param_IntRange($2, $4);
744 | '(' MPNumber DotDot InfinityKeyword ')'
746 $$ = new Module_Param_IntRange($2, NULL);
751 '(' '-' InfinityKeyword DotDot MPFloat ')'
753 $$ = new Module_Param_FloatRange(0.0, false, $5, true);
755 | '(' MPFloat DotDot MPFloat ')'
757 $$ = new Module_Param_FloatRange($2, true, $4, true);
759 | '(' MPFloat DotDot InfinityKeyword ')'
761 $$ = new Module_Param_FloatRange($2, true, 0.0, false);
766 '(' UniversalCharstringFragment DotDot UniversalCharstringFragment ')'
768 universal_char lower; lower.uc_group=lower.uc_plane=lower.uc_row=lower.uc_cell=0;
769 universal_char upper; upper.uc_group=upper.uc_plane=upper.uc_row=upper.uc_cell=0;
770 if ($2.n_uchars!=1) {
771 config_process_error("Lower bound of char range must be 1 character only");
772 } else if ($4.n_uchars!=1) {
773 config_process_error("Upper bound of char range must be 1 character only");
775 lower = *($2.uchars_ptr);
776 upper = *($4.uchars_ptr);
778 config_process_error("Lower bound is larger than upper bound in the char range");
784 $$ = new Module_Param_StringRange(lower, upper);
788 // integers outside of the [MODULE_PARAMETERS] section
791 | '(' IntegerValue ')' { $$ = $2; }
792 | '+' IntegerValue %prec UnarySign { $$ = $2; }
793 | '-' IntegerValue %prec UnarySign
797 $$ = new int_val_t((-op1).get_val());
800 | IntegerValue '+' IntegerValue
805 $$ = new int_val_t((op1 + op2).get_val());
809 | IntegerValue '-' IntegerValue
814 $$ = new int_val_t((op1 - op2).get_val());
818 | IntegerValue '*' IntegerValue
823 $$ = new int_val_t((op1 * op2).get_val());
827 | IntegerValue '/' IntegerValue
830 config_process_error("Integer division by zero.");
831 $$ = new int_val_t((RInt)0);
838 $$ = new int_val_t((op1 / op2).get_val());
845 // floats outside of the [MODULE_PARAMETERS] section
848 | '(' FloatValue ')' { $$ = $2; }
849 | '+' FloatValue %prec UnarySign { $$ = $2; }
850 | '-' FloatValue %prec UnarySign { $$ = -$2; }
851 | FloatValue '+' FloatValue { $$ = $1 + $3; }
852 | FloatValue '-' FloatValue { $$ = $1 - $3; }
853 | FloatValue '*' FloatValue { $$ = $1 * $3; }
854 | FloatValue '/' FloatValue
857 config_process_error("Floating point division by zero.");
864 ObjIdKeyword '{' ObjIdComponentList '}' { $$ = $3; }
871 $$.components_ptr = (int *)Malloc(sizeof(int));
872 $$.components_ptr[0] = $1->get_val();
875 | ObjIdComponentList ObjIdComponent
877 $$.n_components = $1.n_components + 1;
878 $$.components_ptr = (int *)Realloc($1.components_ptr,
879 $$.n_components * sizeof(int));
880 $$.components_ptr[$$.n_components - 1] = $2->get_val();
886 NumberForm { $$ = $1; }
887 | NameAndNumberForm { $$ = $1; }
891 MPNumber { $$ = $1; }
895 Identifier '(' MPNumber ')'
914 UniversalCharstringValue:
918 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
919 $$.uchars_ptr[0] = $1;
923 UniversalCharstringFragment:
926 $$.n_uchars = $1.n_chars;
927 $$.uchars_ptr = (universal_char*)
928 Malloc($$.n_uchars * sizeof(universal_char));
929 for (int i = 0; i < $1.n_chars; i++) {
930 $$.uchars_ptr[i].uc_group = 0;
931 $$.uchars_ptr[i].uc_plane = 0;
932 $$.uchars_ptr[i].uc_row = 0;
933 $$.uchars_ptr[i].uc_cell = $1.chars_ptr[i];
940 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
941 $$.uchars_ptr[0] = $1;
946 CharKeyword '(' ParameterExpression ',' ParameterExpression ','
947 ParameterExpression ',' ParameterExpression ')'
949 $3->set_id(new Module_Param_CustomName(mcopystr("quadruple group")));
950 $5->set_id(new Module_Param_CustomName(mcopystr("quadruple plane")));
951 $7->set_id(new Module_Param_CustomName(mcopystr("quadruple row")));
952 $9->set_id(new Module_Param_CustomName(mcopystr("quadruple cell")));
958 if (g < 0 || g > 127) {
959 char *s = g.get_val().as_string();
960 config_process_error_f("The first number of quadruple (group) must be "
961 "within the range 0 .. 127 instead of %s.", s);
963 $$.uc_group = g < 0 ? 0 : 127;
967 if (p < 0 || p > 255) {
968 char *s = p.get_val().as_string();
969 config_process_error_f("The second number of quadruple (plane) must be "
970 "within the range 0 .. 255 instead of %s.", s);
972 $$.uc_plane = p < 0 ? 0 : 255;
976 if (r < 0 || r > 255) {
977 char *s = r.get_val().as_string();
978 config_process_error_f("The third number of quadruple (row) must be "
979 "within the range 0 .. 255 instead of %s.", s);
981 $$.uc_row = r < 0 ? 0 : 255;
985 if (c < 0 || c > 255) {
986 char *s = c.get_val().as_string();
987 config_process_error_f("The fourth number of quadruple (cell) must be "
988 "within the range 0 .. 255 instead of %s.", s);
990 $$.uc_cell = c < 0 ? 0 : 255;
1001 // character strings outside of the [MODULE_PARAMETERS] section
1005 $$ = mcopystr($1.chars_ptr);
1008 | StringValue '&' Cstring
1010 $$ = mputstr($1, $3.chars_ptr);
1018 $$ = new Module_Param_Value_List();
1020 | '{' FieldValueList '}'
1024 | '{' ArrayItemList '}'
1028 | '{' IndexItemList '}'
1032 | '(' ParameterValue ',' TemplateItemList ')' /* at least 2 elements to avoid shift/reduce conflicts with the ParameterExpression rule */
1034 $$ = new Module_Param_List_Template();
1035 $2->set_id(new Module_Param_Index($$->get_size(),false));
1037 $$->add_list_with_implicit_ids($4);
1040 | ComplementKeyword '(' TemplateItemList ')'
1042 $$ = new Module_Param_ComplementList_Template();
1043 $$->add_list_with_implicit_ids($3);
1046 | SupersetKeyword '(' TemplateItemList ')'
1048 $$ = new Module_Param_Superset_Template();
1049 $$->add_list_with_implicit_ids($3);
1052 | SubsetKeyword '(' TemplateItemList ')'
1054 $$ = new Module_Param_Subset_Template();
1055 $$->add_list_with_implicit_ids($3);
1060 ParameterValueOrNotUsedSymbol:
1067 $$ = new Module_Param_NotUsed();
1074 $$ = new Vector<Module_Param*>();
1077 | TemplateItemList ',' ParameterValue
1087 $$ = new Module_Param_Assignment_List();
1090 | FieldValueList ',' FieldValue
1098 FieldName AssignmentChar ParameterValueOrNotUsedSymbol
1101 $$->set_id(new Module_Param_FieldName($1));
1110 | ASN1LowerIdentifier
1119 $$ = new Module_Param_Value_List();
1120 $1->set_id(new Module_Param_Index($$->get_size(),false));
1123 | ArrayItemList ',' ArrayItem
1126 $3->set_id(new Module_Param_Index($$->get_size(),false));
1132 ParameterValueOrNotUsedSymbol
1136 | PermutationKeyword '(' TemplateItemList ')'
1138 $$ = new Module_Param_Permutation_Template();
1139 $$->add_list_with_implicit_ids($3);
1147 $$ = new Module_Param_Indexed_List();
1150 | IndexItemList ',' IndexItem
1158 IndexItemIndex AssignmentChar ParameterValue
1161 $$->set_id(new Module_Param_Index((size_t)$1,true));
1166 '[' ParameterExpression ']'
1168 $2->set_id(new Module_Param_CustomName(mcopystr("array index")));
1171 if (!tmp.get_val().is_native()) {
1172 config_process_error("bignum index."); // todo
1174 if (tmp.get_val().is_negative()) {
1175 config_process_error("negative index."); // todo
1182 /*************** [LOGGING] section *********************************/
1185 LoggingKeyword LoggingParamList
1190 | LoggingParamList LoggingParamLines optSemiColon
1192 // Centralized duplication handling for `[LOGGING]'.
1193 if ($2.logparam.log_param_selection != LP_UNKNOWN && TTCN_Logger::add_parameter($2)) {
1194 switch ($2.logparam.log_param_selection) {
1196 check_duplicate_option("LOGGING", "FileMask", file_mask_set);
1198 case LP_CONSOLEMASK:
1199 check_duplicate_option("LOGGING", "ConsoleMask", console_mask_set);
1201 case LP_LOGFILESIZE:
1202 check_duplicate_option("LOGGING", "LogFileSize", log_file_size_set);
1204 case LP_LOGFILENUMBER:
1205 check_duplicate_option("LOGGING", "LogFileNumber", log_file_number_set);
1207 case LP_DISKFULLACTION:
1208 check_duplicate_option("LOGGING", "DiskFullAction", log_disk_full_action_set);
1211 check_duplicate_option("LOGGING", "LogFile", file_name_set);
1213 case LP_TIMESTAMPFORMAT:
1214 check_duplicate_option("LOGGING", "TimeStampFormat", timestamp_format_set);
1216 case LP_SOURCEINFOFORMAT:
1217 check_duplicate_option("LOGGING", "SourceInfoFormat", source_info_format_set);
1220 check_duplicate_option("LOGGING", "AppendFile", append_file_set);
1222 case LP_LOGEVENTTYPES:
1223 check_duplicate_option("LOGGING", "LogEventTypes", log_event_types_set);
1225 case LP_LOGENTITYNAME:
1226 check_duplicate_option("LOGGING", "LogEntityName", log_entity_name_set);
1228 case LP_MATCHINGHINTS:
1229 check_duplicate_option("LOGGING", "MatchingVerbosity", matching_verbosity_set);
1231 case LP_PLUGIN_SPECIFIC:
1232 // It would be an overkill to check for the infinite number of custom parameters...
1233 check_duplicate_option("LOGGING", "PluginSpecific", plugin_specific_set);
1245 $$.component.id_selector = COMPONENT_ID_ALL;
1246 $$.component.id_name = NULL;
1247 $$.plugin_id = NULL;
1250 | ComponentId '.' LoggingParam
1253 $$.plugin_id = NULL;
1256 | ComponentId '.' LoggerPluginId '.' LoggingParam
1262 | LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1264 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1265 component_id_t comp;
1266 comp.id_selector = COMPONENT_ID_ALL;
1267 comp.id_name = NULL;
1268 logging_plugin_t *plugin = $4;
1269 while (plugin != NULL) {
1270 // `identifier' and `filename' are reused. Various checks and
1271 // validations must be done in the logger itself (e.g. looking for
1272 // duplicate options).
1273 TTCN_Logger::register_plugin(comp, plugin->identifier, plugin->filename);
1274 logging_plugin_t *tmp = plugin;
1278 $$.logparam.log_param_selection = LP_UNKNOWN;
1280 | ComponentId '.' LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1282 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1283 logging_plugin_t *plugin = $6;
1284 while (plugin != NULL) {
1285 TTCN_Logger::register_plugin($1, plugin->identifier, plugin->filename);
1286 logging_plugin_t *tmp = plugin;
1290 // Component names shall be duplicated in `register_plugin()'.
1291 if ($1.id_selector == COMPONENT_ID_NAME)
1293 $$.logparam.log_param_selection = LP_UNKNOWN;
1302 | LoggerPluginList ',' LoggerPlugin
1312 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1313 $$->identifier = $1;
1314 $$->filename = NULL;
1317 | Identifier AssignmentChar StringValue
1319 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1320 $$->identifier = $1;
1327 '*' { $$ = mcopystr("*"); }
1328 | Identifier { $$ = $1; }
1332 FileMask AssignmentChar LoggingBitmask
1334 $$.log_param_selection = LP_FILEMASK;
1335 $$.logoptions_val = $3;
1337 | ConsoleMask AssignmentChar LoggingBitmask
1339 $$.log_param_selection = LP_CONSOLEMASK;
1340 $$.logoptions_val = $3;
1342 | LogFileSize AssignmentChar Number
1344 $$.log_param_selection = LP_LOGFILESIZE;
1345 $$.int_val = (int)$3->get_val();
1348 | EmergencyLogging AssignmentChar Number
1350 $$.log_param_selection = LP_EMERGENCY;
1351 $$.int_val = (int)$3->get_val();
1354 | EmergencyLoggingBehaviour AssignmentChar EmergencyLoggingBehaviourValue
1356 $$.log_param_selection = LP_EMERGENCYBEHAVIOR;
1357 $$.emergency_logging_behaviour_value = $3;
1359 | EmergencyLoggingMask AssignmentChar LoggingBitmask
1361 $$.log_param_selection = LP_EMERGENCYMASK;
1362 $$.logoptions_val = $3;
1364 | EmergencyLoggingForFailVerdict AssignmentChar YesNoOrBoolean
1366 $$.log_param_selection = LP_EMERGENCYFORFAIL;
1369 | LogFileNumber AssignmentChar Number
1371 $$.log_param_selection = LP_LOGFILENUMBER;
1372 $$.int_val = (int)$3->get_val();
1375 | DiskFullAction AssignmentChar DiskFullActionValue
1377 $$.log_param_selection = LP_DISKFULLACTION;
1378 $$.disk_full_action_value = $3;
1380 | LogFile AssignmentChar LogFileName
1382 $$.log_param_selection = LP_LOGFILE;
1385 | TimestampFormat AssignmentChar TimestampValue
1387 $$.log_param_selection = LP_TIMESTAMPFORMAT;
1388 $$.timestamp_value = $3;
1390 | ConsoleTimestampFormat AssignmentChar TimestampValue
1392 $$.log_param_selection = LP_UNKNOWN;
1394 | SourceInfoFormat AssignmentChar SourceInfoSetting
1396 $$.log_param_selection = LP_SOURCEINFOFORMAT;
1397 $$.source_info_value = $3;
1399 | AppendFile AssignmentChar YesNoOrBoolean
1401 $$.log_param_selection = LP_APPENDFILE;
1404 | LogEventTypes AssignmentChar LogEventTypesValue
1406 $$.log_param_selection = LP_LOGEVENTTYPES;
1407 $$.log_event_types_value = $3;
1409 | LogEntityName AssignmentChar YesNoOrBoolean
1411 $$.log_param_selection = LP_LOGENTITYNAME;
1414 | MatchingHints AssignmentChar VerbosityValue
1416 $$.log_param_selection = LP_MATCHINGHINTS;
1417 $$.matching_verbosity_value = $3;
1419 | Identifier AssignmentChar StringValue
1421 $$.log_param_selection = LP_PLUGIN_SPECIFIC;
1428 Compact { $$ = TTCN_Logger::VERBOSITY_COMPACT; }
1429 | Detailed { $$ = TTCN_Logger::VERBOSITY_FULL; }
1432 DiskFullActionValue:
1433 Error { $$.type = TTCN_Logger::DISKFULL_ERROR; }
1434 | Stop { $$.type = TTCN_Logger::DISKFULL_STOP; }
1437 $$.type = TTCN_Logger::DISKFULL_RETRY;
1438 $$.retry_interval = 30; /* default retry interval */
1440 | Retry '(' Number ')'
1442 $$.type = TTCN_Logger::DISKFULL_RETRY;
1443 $$.retry_interval = (size_t)$3->get_val();
1446 | Delete { $$.type = TTCN_Logger::DISKFULL_DELETE; }
1450 StringValue { $$ = $1; }
1453 LoggingBitOrCollection:
1459 | LoggingBitCollection
1464 case TTCN_Logger::ACTION_UNQUALIFIED:
1465 $$.add_sev(TTCN_Logger::ACTION_UNQUALIFIED);
1467 case TTCN_Logger::DEFAULTOP_UNQUALIFIED:
1468 $$.add_sev(TTCN_Logger::DEFAULTOP_ACTIVATE);
1469 $$.add_sev(TTCN_Logger::DEFAULTOP_DEACTIVATE);
1470 $$.add_sev(TTCN_Logger::DEFAULTOP_EXIT);
1471 $$.add_sev(TTCN_Logger::DEFAULTOP_UNQUALIFIED);
1473 case TTCN_Logger::ERROR_UNQUALIFIED:
1474 $$.add_sev(TTCN_Logger::ERROR_UNQUALIFIED);
1476 case TTCN_Logger::EXECUTOR_UNQUALIFIED:
1477 $$.add_sev(TTCN_Logger::EXECUTOR_RUNTIME);
1478 $$.add_sev(TTCN_Logger::EXECUTOR_CONFIGDATA);
1479 $$.add_sev(TTCN_Logger::EXECUTOR_EXTCOMMAND);
1480 $$.add_sev(TTCN_Logger::EXECUTOR_COMPONENT);
1481 $$.add_sev(TTCN_Logger::EXECUTOR_LOGOPTIONS);
1482 $$.add_sev(TTCN_Logger::EXECUTOR_UNQUALIFIED);
1484 case TTCN_Logger::FUNCTION_UNQUALIFIED:
1485 $$.add_sev(TTCN_Logger::FUNCTION_RND);
1486 $$.add_sev(TTCN_Logger::FUNCTION_UNQUALIFIED);
1488 case TTCN_Logger::PARALLEL_UNQUALIFIED:
1489 $$.add_sev(TTCN_Logger::PARALLEL_PTC);
1490 $$.add_sev(TTCN_Logger::PARALLEL_PORTCONN);
1491 $$.add_sev(TTCN_Logger::PARALLEL_PORTMAP);
1492 $$.add_sev(TTCN_Logger::PARALLEL_UNQUALIFIED);
1494 case TTCN_Logger::PORTEVENT_UNQUALIFIED:
1495 $$.add_sev(TTCN_Logger::PORTEVENT_PQUEUE);
1496 $$.add_sev(TTCN_Logger::PORTEVENT_MQUEUE);
1497 $$.add_sev(TTCN_Logger::PORTEVENT_STATE);
1498 $$.add_sev(TTCN_Logger::PORTEVENT_PMIN);
1499 $$.add_sev(TTCN_Logger::PORTEVENT_PMOUT);
1500 $$.add_sev(TTCN_Logger::PORTEVENT_PCIN);
1501 $$.add_sev(TTCN_Logger::PORTEVENT_PCOUT);
1502 $$.add_sev(TTCN_Logger::PORTEVENT_MMRECV);
1503 $$.add_sev(TTCN_Logger::PORTEVENT_MMSEND);
1504 $$.add_sev(TTCN_Logger::PORTEVENT_MCRECV);
1505 $$.add_sev(TTCN_Logger::PORTEVENT_MCSEND);
1506 $$.add_sev(TTCN_Logger::PORTEVENT_DUALRECV);
1507 $$.add_sev(TTCN_Logger::PORTEVENT_DUALSEND);
1508 $$.add_sev(TTCN_Logger::PORTEVENT_UNQUALIFIED);
1510 case TTCN_Logger::TESTCASE_UNQUALIFIED:
1511 $$.add_sev(TTCN_Logger::TESTCASE_START);
1512 $$.add_sev(TTCN_Logger::TESTCASE_FINISH);
1513 $$.add_sev(TTCN_Logger::TESTCASE_UNQUALIFIED);
1515 case TTCN_Logger::TIMEROP_UNQUALIFIED:
1516 $$.add_sev(TTCN_Logger::TIMEROP_READ);
1517 $$.add_sev(TTCN_Logger::TIMEROP_START);
1518 $$.add_sev(TTCN_Logger::TIMEROP_GUARD);
1519 $$.add_sev(TTCN_Logger::TIMEROP_STOP);
1520 $$.add_sev(TTCN_Logger::TIMEROP_TIMEOUT);
1521 $$.add_sev(TTCN_Logger::TIMEROP_UNQUALIFIED);
1523 case TTCN_Logger::USER_UNQUALIFIED:
1524 $$.add_sev(TTCN_Logger::USER_UNQUALIFIED);
1526 case TTCN_Logger::STATISTICS_UNQUALIFIED:
1527 $$.add_sev(TTCN_Logger::STATISTICS_VERDICT);
1528 $$.add_sev(TTCN_Logger::STATISTICS_UNQUALIFIED);
1530 case TTCN_Logger::VERDICTOP_UNQUALIFIED:
1531 $$.add_sev(TTCN_Logger::VERDICTOP_GETVERDICT);
1532 $$.add_sev(TTCN_Logger::VERDICTOP_SETVERDICT);
1533 $$.add_sev(TTCN_Logger::VERDICTOP_FINAL);
1534 $$.add_sev(TTCN_Logger::VERDICTOP_UNQUALIFIED);
1536 case TTCN_Logger::WARNING_UNQUALIFIED:
1537 $$.add_sev(TTCN_Logger::WARNING_UNQUALIFIED);
1539 case TTCN_Logger::MATCHING_UNQUALIFIED:
1540 $$.add_sev(TTCN_Logger::MATCHING_DONE);
1541 $$.add_sev(TTCN_Logger::MATCHING_TIMEOUT);
1542 $$.add_sev(TTCN_Logger::MATCHING_PCSUCCESS);
1543 $$.add_sev(TTCN_Logger::MATCHING_PCUNSUCC);
1544 $$.add_sev(TTCN_Logger::MATCHING_PMSUCCESS);
1545 $$.add_sev(TTCN_Logger::MATCHING_PMUNSUCC);
1546 $$.add_sev(TTCN_Logger::MATCHING_MCSUCCESS);
1547 $$.add_sev(TTCN_Logger::MATCHING_MCUNSUCC);
1548 $$.add_sev(TTCN_Logger::MATCHING_MMSUCCESS);
1549 $$.add_sev(TTCN_Logger::MATCHING_MMUNSUCC);
1550 $$.add_sev(TTCN_Logger::MATCHING_PROBLEM);
1551 $$.add_sev(TTCN_Logger::MATCHING_UNQUALIFIED);
1553 case TTCN_Logger::DEBUG_UNQUALIFIED:
1554 $$.add_sev(TTCN_Logger::DEBUG_ENCDEC);
1555 $$.add_sev(TTCN_Logger::DEBUG_TESTPORT);
1556 $$.add_sev(TTCN_Logger::DEBUG_USER);
1557 $$.add_sev(TTCN_Logger::DEBUG_FRAMEWORK);
1558 $$.add_sev(TTCN_Logger::DEBUG_UNQUALIFIED);
1560 case TTCN_Logger::LOG_ALL_IMPORTANT:
1561 $$ = Logging_Bits::log_all;
1564 /* The lexer sent something the parser doesn't understand!
1565 Parser needs to be updated.
1567 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
1568 "Internal error: unknown logbit from lexer.");
1575 LoggingBitOrCollection
1579 | LoggingBitmask '|' LoggingBitOrCollection
1587 SourceInfoValue { $$ = $1; }
1590 $$ = $1 ? TTCN_Logger::SINFO_SINGLE : TTCN_Logger::SINFO_NONE;
1596 | BooleanValue { $$ = $1; }
1600 YesNoOrBoolean { $$ = $1 ? TTCN_Logger::LOGEVENTTYPES_YES :
1601 TTCN_Logger::LOGEVENTTYPES_NO; }
1602 | SubCategories { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1603 | Detailed { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1606 /*********************** [PROFILER] ********************************/
1609 ProfilerKeyword ProfilerSettings
1614 | ProfilerSettings ProfilerSetting optSemiColon
1618 DisableProfilerSetting
1619 | DisableCoverageSetting
1620 | DatabaseFileSetting
1621 | AggregateDataSetting
1622 | StatisticsFileSetting
1623 | DisableStatisticsSetting
1624 | StatisticsFilterSetting
1625 | StartAutomaticallySetting
1626 | NetLineTimesSetting
1627 | NetFunctionTimesSetting
1630 DisableProfilerSetting:
1631 DisableProfilerKeyword AssignmentChar BooleanValue {
1632 ttcn3_prof.set_disable_profiler($3);
1636 DisableCoverageSetting:
1637 DisableCoverageKeyword AssignmentChar BooleanValue {
1638 ttcn3_prof.set_disable_coverage($3);
1642 DatabaseFileSetting:
1643 DatabaseFileKeyword AssignmentChar StringValue {
1644 ttcn3_prof.set_database_filename($3);
1648 AggregateDataSetting:
1649 AggregateDataKeyword AssignmentChar BooleanValue {
1650 ttcn3_prof.set_aggregate_data($3);
1654 StatisticsFileSetting:
1655 StatisticsFileKeyword AssignmentChar StringValue {
1656 ttcn3_prof.set_stats_filename($3);
1660 DisableStatisticsSetting:
1661 DisableStatisticsKeyword AssignmentChar BooleanValue {
1662 ttcn3_prof.set_disable_stats($3);
1666 StatisticsFilterSetting:
1667 StatisticsFilterKeyword AssignmentChar ProfilerStatsFlags {
1668 ttcn3_prof.reset_stats_flags();
1669 ttcn3_prof.add_stats_flags($3);
1671 | StatisticsFilterKeyword ConcatChar ProfilerStatsFlags {
1672 ttcn3_prof.add_stats_flags($3);
1677 ProfilerStatsFlag { $$ = $1; }
1678 | ProfilerStatsFlag '&' ProfilerStatsFlags { $$ = $1 | $3; }
1679 | ProfilerStatsFlag '|' ProfilerStatsFlags { $$ = $1 | $3; }
1682 StartAutomaticallySetting:
1683 StartAutomaticallyKeyword AssignmentChar BooleanValue {
1693 NetLineTimesSetting:
1694 NetLineTimesKeyword AssignmentChar BooleanValue {
1695 TTCN3_Stack_Depth::set_net_line_times($3);
1699 NetFunctionTimesSetting:
1700 NetFunctionTimesKeyword AssignmentChar BooleanValue {
1701 TTCN3_Stack_Depth::set_net_func_times($3);
1706 /**************** [TESTPORT_PARAMETERS] ****************************/
1708 TestportParametersSection:
1709 TestportParametersKeyword TestportParameterList
1712 TestportParameterList:
1714 | TestportParameterList TestportParameter optSemiColon
1718 ComponentId '.' TestportName '.' TestportParameterName AssignmentChar
1719 TestportParameterValue
1721 PORT::add_parameter($1, $3, $5, $7);
1722 if ($1.id_selector == COMPONENT_ID_NAME) Free($1.id_name);
1732 $$.id_selector = COMPONENT_ID_NAME;
1737 $$.id_selector = COMPONENT_ID_NAME;
1738 $$.id_name = $1.chars_ptr;
1742 $$.id_selector = COMPONENT_ID_COMPREF;
1743 $$.id_compref = (component)$1->get_val();
1748 $$.id_selector = COMPONENT_ID_COMPREF;
1749 $$.id_compref = MTC_COMPREF;
1753 $$.id_selector = COMPONENT_ID_ALL;
1758 $$.id_selector = COMPONENT_ID_SYSTEM;
1764 Identifier { $$ = $1; }
1765 | Identifier ArrayRef
1767 $$ = mputstr($1, $2);
1770 | '*' { $$ = NULL; }
1774 '[' IntegerValue ']'
1776 char *s = $2->as_string();
1778 $$ = mputc ($$, '[');
1779 $$ = mputstr($$, s);
1780 $$ = mputc ($$, ']');
1784 | ArrayRef '[' IntegerValue ']'
1786 char *s = $3->as_string();
1787 $$ = mputc ($1, '[');
1788 $$ = mputstr($$, s);
1789 $$ = mputc ($$, ']');
1795 TestportParameterName:
1796 Identifier { $$ = $1; }
1799 TestportParameterValue:
1800 StringValue { $$ = $1; }
1803 /****************** [EXECUTE] section *************/
1806 ExecuteKeyword ExecuteList
1808 if (!TTCN_Runtime::is_single()) config_process_error("Internal error: "
1809 "the Main Controller must not send section [EXECUTE] of the "
1810 "configuration file.");
1816 | ExecuteList ExecuteItem optSemiColon
1818 if (TTCN_Runtime::is_single()) {
1819 execute_list = (execute_list_item *)Realloc(
1820 execute_list, (execute_list_len + 1) *
1821 sizeof(*execute_list));
1822 execute_list[execute_list_len++] = $2;
1824 Free($2.module_name);
1825 Free($2.testcase_name);
1833 $$.module_name = $1;
1834 $$.testcase_name = NULL;
1836 | Identifier '.' ControlKeyword
1838 $$.module_name = $1;
1839 $$.testcase_name = NULL;
1841 | Identifier '.' Identifier
1843 $$.module_name = $1;
1844 $$.testcase_name = $3;
1846 | Identifier '.' '*'
1848 $$.module_name = $1;
1849 $$.testcase_name = mcopystr("*");
1853 /****************** [EXTERNAL_COMMANDS] section **********************/
1855 ExternalCommandsSection:
1856 ExternalCommandsKeyword ExternalCommandList
1859 ExternalCommandList:
1861 | ExternalCommandList ExternalCommand optSemiColon
1865 BeginControlPart AssignmentChar Command
1867 check_duplicate_option("EXTERNAL_COMMANDS", "BeginControlPart",
1868 begin_controlpart_command_set);
1870 TTCN_Runtime::set_begin_controlpart_command($3);
1874 | EndControlPart AssignmentChar Command
1876 check_duplicate_option("EXTERNAL_COMMANDS", "EndControlPart",
1877 end_controlpart_command_set);
1879 TTCN_Runtime::set_end_controlpart_command($3);
1883 | BeginTestCase AssignmentChar Command
1885 check_duplicate_option("EXTERNAL_COMMANDS", "BeginTestCase",
1886 begin_testcase_command_set);
1888 TTCN_Runtime::set_begin_testcase_command($3);
1892 | EndTestCase AssignmentChar Command
1894 check_duplicate_option("EXTERNAL_COMMANDS", "EndTestCase",
1895 end_testcase_command_set);
1897 TTCN_Runtime::set_end_testcase_command($3);
1904 StringValue { $$ = $1; }
1907 /***************** [GROUPS] section *******************/
1910 GroupsKeyword GroupList
1912 check_ignored_section("GROUPS");
1918 | GroupList Group optSemiColon
1922 GroupName AssignmentChar GroupMembers
1926 Identifier { Free($1); }
1936 | seqGroupMember ',' HostName
1941 | Identifier { Free($1); }
1944 /******************** [COMPONENTS] section *******************/
1946 ComponentsKeyword ComponentList
1948 check_ignored_section("COMPONENTS");
1954 | ComponentList ComponentItem optSemiColon
1958 ComponentName AssignmentChar ComponentLocation
1962 Identifier { Free($1); }
1967 Identifier { Free($1); }
1971 /****************** [MAIN_CONTROLLER] section *********************/
1972 MainControllerSection:
1973 MainControllerKeyword MCParameterList
1975 check_ignored_section("MAIN_CONTROLLER");
1981 | MCParameterList MCParameter optSemiColon
1985 LocalAddress AssignmentChar HostName { }
1986 | TCPPort AssignmentChar IntegerValue { delete $3; }
1987 | KillTimer AssignmentChar KillTimerValue { }
1988 | NumHCs AssignmentChar IntegerValue { delete $3; }
1989 | UnixSocketEnabled AssignmentChar YesToken {}
1990 | UnixSocketEnabled AssignmentChar NoToken {}
1991 | UnixSocketEnabled AssignmentChar HostName {}
1996 | IntegerValue { delete $1; }
1999 /****************** [INCLUDE] section *********************/
2001 IncludeKeyword IncludeFiles
2003 if(!TTCN_Runtime::is_single())
2004 config_process_error
2005 ("Internal error: the Main Controller must not send section [INCLUDE]"
2006 " of the configuration file.");
2012 | IncludeFiles IncludeFile
2016 Cstring { Free($1.chars_ptr); }
2019 /****************** [DEFINE] section *********************/
2023 if(!TTCN_Runtime::is_single())
2024 config_process_error
2025 ("Internal error: the Main Controller must not send section [DEFINE]"
2026 " of the configuration file.");
2030 /*********************************************************/
2035 $$ = Module_Param::OT_ASSIGN;
2040 $$ = Module_Param::OT_CONCAT;
2051 static void reset_configuration_options()
2053 /* Section [MODULE_PARAMETERS */
2054 /** \todo reset module parameters to their default values */
2055 /* Section [LOGGING] */
2056 TTCN_Logger::close_file();
2057 TTCN_Logger::reset_configuration();
2058 file_name_set = FALSE;
2059 file_mask_set = TRUE;
2060 console_mask_set = TRUE;
2061 timestamp_format_set = FALSE;
2062 source_info_format_set = FALSE;
2063 append_file_set = FALSE;
2064 log_event_types_set = FALSE;
2065 log_entity_name_set = FALSE;
2066 /* Section [TESTPORT_PARAMETERS] */
2067 PORT::clear_parameters();
2068 /* Section [EXTERNAL_COMMANDS] */
2070 TTCN_Runtime::clear_external_commands();
2072 begin_controlpart_command_set = FALSE;
2073 end_controlpart_command_set = FALSE;
2074 begin_testcase_command_set = FALSE;
2075 end_testcase_command_set = FALSE;
2078 Module_Param* process_config_string2ttcn(const char* mp_str, bool is_component)
2080 if (parsed_module_param!=NULL || parsing_error_messages!=NULL) TTCN_error("Internal error: previously parsed ttcn string was not cleared.");
2081 // add the hidden keyword
2082 std::string mp_string = (is_component) ? std::string("$#&&&(#TTCNSTRINGPARSING_COMPONENT$#&&^#% ") + mp_str
2083 : std::string("$#&&&(#TTCNSTRINGPARSING$#&&^#% ") + mp_str;
2084 struct yy_buffer_state *flex_buffer = config_process__scan_bytes(mp_string.c_str(), (int)mp_string.size());
2085 if (flex_buffer == NULL) TTCN_error("Internal error: flex buffer creation failed.");
2086 reset_config_process_lex(NULL);
2089 Ttcn_String_Parsing ttcn_string_parsing;
2090 if (config_process_parse()) error_flag = TRUE;
2091 } catch (const TC_Error& TC_error) {
2092 if (parsed_module_param!=NULL) { delete parsed_module_param; parsed_module_param = NULL; }
2095 config_process_close();
2096 config_process_lex_destroy();
2098 if (error_flag || parsing_error_messages!=NULL) {
2099 delete parsed_module_param;
2100 parsed_module_param = NULL;
2101 char* pem = parsing_error_messages!=NULL ? parsing_error_messages : mcopystr("Unknown parsing error");
2102 parsing_error_messages = NULL;
2103 TTCN_error_begin("%s", pem);
2108 if (parsed_module_param==NULL) TTCN_error("Internal error: could not parse ttcn string.");
2109 Module_Param* ret_val = parsed_module_param;
2110 parsed_module_param = NULL;
2115 boolean process_config_string(const char *config_string, int string_len)
2119 struct yy_buffer_state *flex_buffer =
2120 config_process__scan_bytes(config_string, string_len);
2121 if (flex_buffer == NULL) {
2122 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
2123 "Internal error: flex buffer creation failed.");
2128 reset_configuration_options();
2129 reset_config_process_lex(NULL);
2130 if (config_process_parse()) error_flag = TRUE;
2132 } catch (const TC_Error& TC_error) {
2136 config_process_close();
2137 config_process_lex_destroy();
2143 boolean process_config_file(const char *file_name)
2146 string_chain_t *filenames=NULL;
2148 reset_configuration_options();
2150 if(preproc_parse_file(file_name, &filenames, &config_defines))
2154 char *fn=string_chain_cut(&filenames);
2155 reset_config_process_lex(fn);
2156 /* The lexer can modify config_process_in
2157 * when it's input buffer is changed */
2158 config_process_in = fopen(fn, "r");
2159 FILE* tmp_cfg = config_process_in;
2160 if (config_process_in != NULL) {
2162 if(config_process_parse()) error_flag=TRUE;
2163 } catch (const TC_Error& TC_error) {
2167 config_process_close();
2168 config_process_lex_destroy();
2170 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2171 TTCN_Logger::log_event("Cannot open configuration file: %s", fn);
2172 TTCN_Logger::OS_error();
2173 TTCN_Logger::end_event();
2176 /* During parsing flex or libc may use some system calls (e.g. ioctl)
2177 * that fail with an error status. Such error codes shall be ignored in
2178 * future error messages. */
2184 string_map_free(config_defines);
2185 config_defines = NULL;
2190 void config_process_error_f(const char *error_str, ...)
2192 if (Ttcn_String_Parsing::happening()) {
2194 va_start(p_var, error_str);
2195 char* error_msg_str = mprintf_va_list(error_str, p_var);
2197 if (parsing_error_messages!=NULL) parsing_error_messages = mputc(parsing_error_messages, '\n');
2198 parsing_error_messages = mputprintf(parsing_error_messages,
2199 "Parse error in line %d, at or before token `%s': %s", config_process_get_current_line(), config_process_text, error_msg_str);
2200 Free(error_msg_str);
2204 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2205 if (!get_cfg_process_current_file().empty()) {
2206 TTCN_Logger::log_event("Parse error in configuration file `%s': in line %d, "
2207 "at or before token `%s': ",
2208 get_cfg_process_current_file().c_str(), config_process_get_current_line(),
2212 TTCN_Logger::log_event("Parse error while reading configuration "
2213 "information: in line %d, at or before token `%s': ",
2214 config_process_get_current_line(), config_process_text);
2217 va_start(pvar, error_str);
2218 TTCN_Logger::log_event_va_list(error_str, pvar);
2220 TTCN_Logger::end_event();
2224 void config_process_error(const char *error_str)
2226 config_process_error_f("%s", error_str);
2229 void config_preproc_error(const char *error_str, ...)
2231 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2232 TTCN_Logger::log_event("Parse error while pre-processing configuration"
2233 " file `%s': in line %d: ",
2234 get_cfg_preproc_current_file().c_str(),
2235 config_preproc_yylineno);
2237 va_start(pvar, error_str);
2238 TTCN_Logger::log_event_va_list(error_str, pvar);
2240 TTCN_Logger::end_event();
2244 void path_error(const char *fmt, ...)
2247 fprintf(stderr, "File error: ");
2248 va_start(parameters, fmt);
2249 vfprintf(stderr, fmt, parameters);
2251 fprintf(stderr, "\n");
2254 static void check_duplicate_option(const char *section_name,
2255 const char *option_name, boolean& option_flag)
2258 TTCN_warning("Option `%s' was given more than once in section [%s] of the "
2259 "configuration file.", option_name, section_name);
2260 } else option_flag = TRUE;
2263 static void check_ignored_section(const char *section_name)
2265 if (TTCN_Runtime::is_single()) TTCN_warning("Section [%s] of "
2266 "configuration file is ignored in single mode.", section_name);
2267 else config_process_error_f("Internal error: the Main Controller must not "
2268 "send section [%s] of the configuration file.", section_name);
2271 static void set_param(Module_Param& param)
2274 Module_List::set_param(param);
2276 catch (const TC_Error& TC_error) {
2281 unsigned char char_to_hexdigit(char c)
2283 if (c >= '0' && c <= '9') return c - '0';
2284 else if (c >= 'A' && c <= 'F') return c - 'A' + 10;
2285 else if (c >= 'a' && c <= 'f') return c - 'a' + 10;
2287 config_process_error_f("char_to_hexdigit(): invalid argument: %c", c);
2288 return 0; // to avoid warning