1 /******************************************************************************
2 * Copyright (c) 2000-2014 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 ******************************************************************************/
17 #include <openssl/bn.h>
19 #include "../common/config_preproc.h"
21 #include "Param_Types.hh"
26 #include "Verdicttype.hh"
27 #include "Bitstring.hh"
28 #include "Hexstring.hh"
29 #include "Octetstring.hh"
30 #include "Charstring.hh"
31 #include "Universal_charstring.hh"
33 #include "Module_list.hh"
37 #include "LoggingBits.hh"
38 #include "LoggingParam.hh"
40 #include "Profiler.hh"
42 #define YYERROR_VERBOSE
44 #include "config_process.lex.hh"
46 extern void reset_config_process_lex(const char* fname);
47 extern void config_process_close();
48 extern int config_process_get_current_line();
49 extern std::string get_cfg_process_current_file();
51 static int config_process_parse();
52 static void check_duplicate_option(const char *section_name,
53 const char *option_name, boolean& option_flag);
54 static void check_ignored_section(const char *section_name);
55 static void set_param(Module_Param& module_param);
56 static unsigned char char_to_hexdigit(char c);
58 static boolean error_flag = FALSE;
60 static Module_Param* parsed_module_param = NULL;
61 static char * parsing_error_messages = NULL;
64 For detecting duplicate entries in the config file. Start out as FALSE,
65 set to TRUE bycheck_duplicate_option().
66 Exception: duplication of parameters that can be component specific is checked
67 by set_xxx(), these start out as TRUE.
69 static boolean file_name_set = FALSE,
71 console_mask_set = TRUE,
72 timestamp_format_set = FALSE,
73 source_info_format_set = FALSE,
74 append_file_set = FALSE,
75 log_event_types_set = FALSE,
76 log_entity_name_set = FALSE,
77 begin_controlpart_command_set = FALSE,
78 end_controlpart_command_set = FALSE,
79 begin_testcase_command_set = FALSE,
80 end_testcase_command_set = FALSE,
81 log_file_size_set = TRUE,
82 log_file_number_set = TRUE,
83 log_disk_full_action_set = TRUE,
84 matching_verbosity_set = FALSE,
85 logger_plugins_set = FALSE,
86 plugin_specific_set = FALSE;
88 int execute_list_len = 0;
89 execute_list_item *execute_list = NULL;
91 string_map_t *config_defines;
99 unsigned int uint_val;
102 param_objid_t objid_val;
103 verdicttype verdict_val;
104 param_bitstring_t bitstring_val;
105 param_hexstring_t hexstring_val;
106 param_charstring_t charstring_val;
107 param_octetstring_t octetstring_val;
108 universal_char universal_char_val;
109 param_universal_charstring_t universal_charstring_val;
110 Module_Param::operation_type_t param_optype_val;
111 Vector<Module_Param*>* module_param_list;
112 Module_Param* module_param_val;
113 Module_Param_Length_Restriction* module_param_length_restriction;
114 Vector<char*>* name_vector;
115 component_id_t comp_id;
116 execute_list_item execute_item_val;
117 TTCN_Logger::emergency_logging_behaviour_t emergency_logging_behaviour_value;
118 TTCN_Logger::timestamp_format_t timestamp_value;
119 TTCN_Logger::source_info_format_t source_info_value;
120 TTCN_Logger::log_event_types_t log_event_types_value;
121 TTCN_Logger::disk_full_action_t disk_full_action_value;
122 TTCN_Logger::matching_verbosity_t matching_verbosity_value;
123 TTCN_Logger::Severity logseverity_val;
124 Logging_Bits logoptions_val;
126 logging_plugin_t *logging_plugins;
127 logging_param_t logging_params;
128 logging_setting_t logging_param_line;
131 %token ModuleParametersKeyword
132 %token LoggingKeyword
133 %token ProfilerKeyword
134 %token TestportParametersKeyword
135 %token ExecuteKeyword
136 %token ExternalCommandsKeyword
138 %token ComponentsKeyword
139 %token MainControllerKeyword
140 %token IncludeKeyword
145 %token ObjIdKeyword "objid"
146 %token CharKeyword "char"
147 %token ControlKeyword "control"
148 %token MTCKeyword "mtc"
149 %token SystemKeyword "system"
150 %token NULLKeyword "NULL"
151 %token nullKeyword "null"
152 %token OmitKeyword "omit"
153 %token ComplementKeyword "complement"
155 %token SupersetKeyword "superset"
156 %token SubsetKeyword "subset"
157 %token PatternKeyword "pattern"
158 %token PermutationKeyword "permutation"
159 %token LengthKeyword "length"
160 %token IfpresentKeyword "ifpresent"
161 %token InfinityKeyword "infinity"
162 %token AssignmentChar ":= or ="
163 %token ConcatChar "&="
164 %token LogFile "LogFile or FileName"
165 %token EmergencyLogging
166 %token EmergencyLoggingBehaviour
167 %token EmergencyLoggingMask
172 %token TimestampFormat
173 %token ConsoleTimestampFormat
174 %token SourceInfoFormat "LogSourceInfo or SourceInfoFormat"
178 %token BeginControlPart
179 %token EndControlPart
182 %token <str_val> Identifier
183 %token <str_val> ASN1LowerIdentifier "ASN.1 identifier beginning with a lowercase letter"
184 %token <int_val> Number
185 %token <float_val> Float
186 %token <bool_val> BooleanValue "true or false"
187 %token <verdict_val> VerdictValue
188 %token <bitstring_val> Bstring "bit string value"
189 %token <hexstring_val> Hstring "hex string value"
190 %token <octetstring_val> Ostring "octet string value"
191 %token <str_val> BstringMatch "bit string template"
192 %token <str_val> HstringMatch "hex string template"
193 %token <str_val> OstringMatch "octet string template"
194 %token <charstring_val> Cstring "charstring value"
195 %token DNSName "hostname"
197 %token <logseverity_val> LoggingBit
198 /* a collection of bits */
199 %token <logseverity_val> LoggingBitCollection
201 %token <emergency_logging_behaviour_value> EmergencyLoggingBehaviourValue "BufferAll or BufferMasked"
202 %token <timestamp_value> TimestampValue "Time, Datetime or Seconds"
203 %token <source_info_value> SourceInfoValue "None, Single or Stack"
204 %token <bool_val> YesNo "yes or no"
209 %token UnixSocketEnabled
210 %token YesToken "yes"
214 %token DiskFullAction
221 %token TtcnStringParsingKeyword
222 %token DisableProfilerKeyword "DisableProfiler"
223 %token DisableCoverageKeyword "DisableCoverage"
224 %token DatabaseFileKeyword "DatabaseFile"
225 %token AggregateDataKeyword "AggregateData"
226 %token StatisticsFileKeyword "StatisticsFile"
227 %token DisableStatisticsKeyword "DisableStatistics"
228 %token StatisticsFilterKeyword "StatisticsFilter"
229 %token StartAutomaticallyKeyword "StartAutomatically"
230 %token NetLineTimesKeyword "NetLineTimes"
231 %token NetFunctionTimesKeyword "NetFunctionTimes"
232 %token <uint_val> ProfilerStatsFlag "profiler statistics filter"
234 %type <int_val> IntegerValue
235 %type <float_val> FloatValue
236 %type <objid_val> ObjIdValue ObjIdComponentList
237 %type <int_val> ObjIdComponent NumberForm NameAndNumberForm
239 %type <universal_charstring_val> UniversalCharstringValue
240 seqUniversalCharstringFragment UniversalCharstringFragment
241 %type <universal_char_val> Quadruple
242 %type <str_val> EnumeratedValue
244 %type <str_val> LoggerPluginId
245 %type <logging_plugins> LoggerPlugin LoggerPluginList
246 %type <logging_params> LoggingParam
247 %type <logging_param_line> LoggingParamLines
248 %type <str_val> LogFileName StringValue
249 /* a collection of bits */
250 %type <logoptions_val> LoggingBitmask
251 %type <logoptions_val> LoggingBitOrCollection
252 %type <source_info_value> SourceInfoSetting
253 %type <bool_val> YesNoOrBoolean
254 %type <log_event_types_value> LogEventTypesValue
255 %type <disk_full_action_value> DiskFullActionValue
256 %type <str_val> Command
257 %type <matching_verbosity_value> VerbosityValue
258 %type <comp_id> ComponentId
259 %type <str_val> TestportName ArrayRef TestportParameterName
260 TestportParameterValue
262 %type <execute_item_val> ExecuteItem
264 %type <bitstring_val> BitstringValue
265 %type <hexstring_val> HexstringValue
266 %type <octetstring_val> OctetstringValue
268 %type <name_vector> ParameterName ParameterNameSegment
269 %type <param_optype_val> ParamOpType
270 %type <str_val> FieldName
271 %type <module_param_val> ParameterValue SimpleParameterValue ParameterValueOrNotUsedSymbol
272 FieldValue ArrayItem IndexItem IndexItemList FieldValueList ArrayItemList CompoundValue IntegerRange FloatRange StringRange
273 %type <module_param_list> TemplateItemList
274 %type <module_param_length_restriction> LengthMatch
275 %type <str_val> PatternChunk PatternChunkList
276 %type <int_native> IndexItemIndex LengthBound
277 %type <uint_val> ProfilerStatsFlags
279 %destructor { Free($$); }
289 TestportParameterName
290 TestportParameterValue
297 %destructor { Free($$.components_ptr); }
301 %destructor { Free($$.bits_ptr); }
305 %destructor { Free($$.nibbles_ptr); }
309 %destructor { Free($$.octets_ptr); }
313 %destructor { Free($$.chars_ptr); }
316 %destructor { Free($$.uchars_ptr); Free($$.quad_positions); }
317 seqUniversalCharstringFragment
318 UniversalCharstringFragment
319 UniversalCharstringValue
321 %destructor { if ($$.id_selector == COMPONENT_ID_NAME) Free($$.id_name); }
324 %destructor { Free($$.module_name); Free($$.testcase_name); }
327 %destructor { delete $$; }
335 ParameterValueOrNotUsedSymbol
347 %destructor { delete $$; }
350 %destructor { for(size_t i=0; i<$$->size(); i++) { delete $$->at(i); } delete $$; }
353 %destructor { for(size_t i=0; i<$$->size(); i++) { Free($$->at(i)); } delete $$; }
364 2 conflicts in two distinct states.
365 When seeing a '*' token after an integer or float value in section
366 [MODULE_PARAMETERS] parser cannot decide whether the token is a multiplication
367 operator (shift) or it refers to all modules in the next module parameter
375 if (Ttcn_String_Parsing::happening()) {
376 config_process_error("Config file cannot be parsed as ttcn string");
379 | TtcnStringParsingKeyword ParameterValue
381 parsed_module_param = $2;
391 ModuleParametersSection
394 | TestportParametersSection
396 | ExternalCommandsSection
399 | MainControllerSection
404 ModuleParametersSection:
405 ModuleParametersKeyword ModuleParameters
410 | ModuleParameters ModuleParameter optSemiColon
414 ParameterName ParamOpType ParameterValue
416 Module_Param* mp = $3;
417 mp->set_id(new Module_Param_Name(*$1));
418 mp->set_operation_type($2);
426 ParameterNameSegment { $$ = $1; }
427 | '*' '.' ParameterNameSegment { $$ = $3; }
430 ParameterNameSegment:
431 ParameterNameSegment '.' Identifier
436 | ParameterNameSegment '[' Number ']'
439 $$->push_back($3->as_string());
444 $$ = new Vector<char*>();
454 | SimpleParameterValue LengthMatch
457 $$->set_length_restriction($2);
459 | SimpleParameterValue IfpresentKeyword
464 | SimpleParameterValue LengthMatch IfpresentKeyword
467 $$->set_length_restriction($2);
473 LengthKeyword '(' LengthBound ')'
475 $$ = new Module_Param_Length_Restriction();
476 $$->set_single((size_t)$3);
478 | LengthKeyword '(' LengthBound DotDot LengthBound ')'
481 config_process_error("invalid length restriction: lower bound > upper bound");
483 $$ = new Module_Param_Length_Restriction();
484 $$->set_min((size_t)$3);
485 $$->set_max((size_t)$5);
487 | LengthKeyword '(' LengthBound DotDot InfinityKeyword ')'
489 $$ = new Module_Param_Length_Restriction();
490 $$->set_min((size_t)$3);
497 if (!$1->is_native()) {
498 config_process_error("bignum length restriction bound.");
500 } else if ($1->is_negative()) {
501 config_process_error("negative length restriction bound.");
510 SimpleParameterValue:
513 $$ = new Module_Param_Integer($1);
517 $$ = new Module_Param_Float($1);
521 $$ = new Module_Param_Boolean($1);
525 $$ = new Module_Param_Objid($1.n_components, $1.components_ptr);
529 $$ = new Module_Param_Verdict($1);
533 $$ = new Module_Param_Bitstring($1.n_bits, $1.bits_ptr);
537 $$ = new Module_Param_Hexstring($1.n_nibbles, $1.nibbles_ptr);
541 $$ = new Module_Param_Octetstring($1.n_octets, $1.octets_ptr);
545 $$ = new Module_Param_Charstring($1.n_chars, $1.chars_ptr);
547 | UniversalCharstringValue
549 $$ = new Module_Param_Universal_Charstring($1.n_uchars, $1.uchars_ptr, $1.n_quads, $1.quad_positions);
553 $$ = new Module_Param_Enumerated($1);
557 $$ = new Module_Param_Omit();
561 $$ = new Module_Param_Asn_Null();
565 $$ = new Module_Param_Ttcn_Null();
569 $$ = new Module_Param_Ttcn_mtc();
573 $$ = new Module_Param_Ttcn_system();
577 $$ = new Module_Param_Any();
581 $$ = new Module_Param_AnyOrNone();
595 | PatternKeyword PatternChunkList
597 $$ = new Module_Param_Pattern($2);
602 int n_chars = (int)mstrlen($1);
603 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
604 for (int i=0; i<n_chars; i++) {
620 config_process_error_f("Invalid char (%c) in bitstring template", $1[i]);
624 $$ = new Module_Param_Bitstring_Template(n_chars, chars_ptr);
628 int n_chars = (int)mstrlen($1);
629 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
630 for (int i=0; i<n_chars; i++) {
631 if ($1[i]=='?') chars_ptr[i] = 16;
632 else if ($1[i]=='*') chars_ptr[i] = 17;
633 else chars_ptr[i] = char_to_hexdigit($1[i]);
636 $$ = new Module_Param_Hexstring_Template(n_chars, chars_ptr);
640 Vector<unsigned short> octet_vec;
641 int str_len = (int)mstrlen($1);
642 for (int i=0; i<str_len; i++) {
644 if ($1[i]=='?') num = 256;
645 else if ($1[i]=='*') num = 257;
648 num = 16 * char_to_hexdigit($1[i]);
650 if (i>=str_len) config_process_error("Unexpected end of octetstring pattern");
652 num += char_to_hexdigit($1[i]);
654 octet_vec.push_back(num);
657 int n_chars = (int)octet_vec.size();
658 unsigned short* chars_ptr = (unsigned short*)Malloc(n_chars*sizeof(unsigned short));
659 for (int i=0; i<n_chars; i++) chars_ptr[i] = octet_vec[i];
660 $$ = new Module_Param_Octetstring_Template(n_chars, chars_ptr);
673 | PatternChunkList '&' PatternChunk
676 $$ = mputstr($$, $3);
684 $$ = mcopystr($1.chars_ptr);
689 $$ = mprintf("\\q{%d,%d,%d,%d}", $1.uc_group, $1.uc_plane, $1.uc_row, $1.uc_cell);
694 '(' '-' InfinityKeyword DotDot IntegerValue ')'
696 $$ = new Module_Param_IntRange(NULL, $5);
698 | '(' IntegerValue DotDot IntegerValue ')'
700 $$ = new Module_Param_IntRange($2, $4);
702 | '(' IntegerValue DotDot InfinityKeyword ')'
704 $$ = new Module_Param_IntRange($2, NULL);
709 '(' '-' InfinityKeyword DotDot FloatValue ')'
711 $$ = new Module_Param_FloatRange(0.0, false, $5, true);
713 | '(' FloatValue DotDot FloatValue ')'
715 $$ = new Module_Param_FloatRange($2, true, $4, true);
717 | '(' FloatValue DotDot InfinityKeyword ')'
719 $$ = new Module_Param_FloatRange($2, true, 0.0, false);
724 '(' UniversalCharstringFragment DotDot UniversalCharstringFragment ')'
726 universal_char lower; lower.uc_group=lower.uc_plane=lower.uc_row=lower.uc_cell=0;
727 universal_char upper; upper.uc_group=upper.uc_plane=upper.uc_row=upper.uc_cell=0;
728 if ($2.n_uchars!=1) {
729 config_process_error("Lower bound of char range must be 1 character only");
730 } else if ($4.n_uchars!=1) {
731 config_process_error("Upper bound of char range must be 1 character only");
733 lower = *($2.uchars_ptr);
734 upper = *($4.uchars_ptr);
736 config_process_error("Lower bound is larger than upper bound in the char range");
742 Free($2.quad_positions);
743 Free($4.quad_positions);
744 $$ = new Module_Param_StringRange(lower, upper);
750 | '(' IntegerValue ')' { $$ = $2; }
751 | '+' IntegerValue %prec UnarySign { $$ = $2; }
752 | '-' IntegerValue %prec UnarySign
756 $$ = new int_val_t((-op1).get_val());
759 | IntegerValue '+' IntegerValue
764 $$ = new int_val_t((op1 + op2).get_val());
768 | IntegerValue '-' IntegerValue
773 $$ = new int_val_t((op1 - op2).get_val());
777 | IntegerValue '*' IntegerValue
782 $$ = new int_val_t((op1 * op2).get_val());
786 | IntegerValue '/' IntegerValue
789 config_process_error("Integer division by zero.");
790 $$ = new int_val_t((RInt)0);
797 $$ = new int_val_t((op1 / op2).get_val());
806 | '(' FloatValue ')' { $$ = $2; }
807 | '+' FloatValue %prec UnarySign { $$ = $2; }
808 | '-' FloatValue %prec UnarySign { $$ = -$2; }
809 | FloatValue '+' FloatValue { $$ = $1 + $3; }
810 | FloatValue '-' FloatValue { $$ = $1 - $3; }
811 | FloatValue '*' FloatValue { $$ = $1 * $3; }
812 | FloatValue '/' FloatValue
815 config_process_error("Floating point division by zero.");
822 ObjIdKeyword '{' ObjIdComponentList '}' { $$ = $3; }
829 $$.components_ptr = (int *)Malloc(sizeof(int));
830 $$.components_ptr[0] = $1->get_val();
833 | ObjIdComponentList ObjIdComponent
835 $$.n_components = $1.n_components + 1;
836 $$.components_ptr = (int *)Realloc($1.components_ptr,
837 $$.n_components * sizeof(int));
838 $$.components_ptr[$$.n_components - 1] = $2->get_val();
844 NumberForm { $$ = $1; }
845 | NameAndNumberForm { $$ = $1; }
853 Identifier '(' Number ')'
865 | BitstringValue ConcatOp Bstring
867 $$.n_bits = $1.n_bits + $3.n_bits;
868 int n_bytes_1 = ($1.n_bits+7)/8;
869 int n_bytes_3 = ($3.n_bits+7)/8;
870 int n_bytes = ($$.n_bits+7)/8;
871 $$.bits_ptr = (unsigned char *)Realloc($1.bits_ptr, n_bytes);
872 int n_rem_1 = $1.n_bits % 8; // remainder bits
874 for (int i=n_bytes_1; i<n_bytes; i++) {
875 unsigned char S3_byte = $3.bits_ptr[i-n_bytes_1];
876 $$.bits_ptr[i-1] |= S3_byte << n_rem_1;
877 $$.bits_ptr[i] = S3_byte >> (8-n_rem_1);
879 if (n_bytes_1+n_bytes_3>n_bytes)
880 $$.bits_ptr[n_bytes-1] |= $3.bits_ptr[n_bytes_3-1] << n_rem_1;
882 memcpy($$.bits_ptr + n_bytes_1, $3.bits_ptr, n_bytes_3);
893 | HexstringValue ConcatOp Hstring
895 $$.n_nibbles = $1.n_nibbles + $3.n_nibbles;
896 int n_bytes = ($$.n_nibbles + 1) / 2;
897 $$.nibbles_ptr = (unsigned char *)Realloc($1.nibbles_ptr, n_bytes);
898 int n_bytes_1 = ($1.n_nibbles + 1) / 2;
899 int n_bytes_3 = ($3.n_nibbles + 1) / 2;
900 if ($1.n_nibbles % 2) {
901 for (int i=n_bytes_1; i<n_bytes; i++) {
902 unsigned char S3_byte = $3.nibbles_ptr[i - n_bytes_1];
903 $$.nibbles_ptr[i - 1] |= S3_byte << 4;
904 $$.nibbles_ptr[i] = S3_byte >> 4;
906 if ($3.n_nibbles % 2)
907 $$.nibbles_ptr[n_bytes - 1] |= $3.nibbles_ptr[n_bytes_3 - 1] << 4;
909 memcpy($$.nibbles_ptr + n_bytes_1, $3.nibbles_ptr, n_bytes_3);
911 Free($3.nibbles_ptr);
920 | OctetstringValue ConcatOp Ostring
922 $$.n_octets = $1.n_octets + $3.n_octets;
923 $$.octets_ptr = (unsigned char *)Realloc($1.octets_ptr, $$.n_octets);
924 memcpy($$.octets_ptr + $1.n_octets, $3.octets_ptr, $3.n_octets);
929 UniversalCharstringValue:
930 Cstring seqUniversalCharstringFragment
932 $$.n_uchars = $1.n_chars + $2.n_uchars;
933 $$.uchars_ptr = (universal_char*)
934 Malloc($$.n_uchars * sizeof(universal_char));
935 for (int i = 0; i < $1.n_chars; i++) {
936 $$.uchars_ptr[i].uc_group = 0;
937 $$.uchars_ptr[i].uc_plane = 0;
938 $$.uchars_ptr[i].uc_row = 0;
939 $$.uchars_ptr[i].uc_cell = $1.chars_ptr[i];
941 memcpy($$.uchars_ptr + $1.n_chars, $2.uchars_ptr,
942 $2.n_uchars * sizeof(universal_char));
943 $$.n_quads = $2.n_quads;
944 $$.quad_positions = (int*)Malloc($$.n_quads * sizeof(int));
945 for (int i = 0; i < $$.n_quads; i++) {
946 $$.quad_positions[i] = $2.quad_positions[i] + $1.n_chars;
950 Free($2.quad_positions);
955 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
956 $$.uchars_ptr[0] = $1;
958 $$.quad_positions = (int*)Malloc(sizeof(int));
959 $$.quad_positions[0] = 0;
961 | Quadruple seqUniversalCharstringFragment
963 $$.n_uchars = $2.n_uchars + 1;
964 $$.uchars_ptr = (universal_char*)
965 Malloc($$.n_uchars * sizeof(universal_char));
966 $$.uchars_ptr[0] = $1;
967 memcpy($$.uchars_ptr + 1, $2.uchars_ptr,
968 $2.n_uchars * sizeof(universal_char));
969 $$.n_quads = $2.n_quads + 1;
970 $$.quad_positions = (int*)Malloc($$.n_quads * sizeof(int));
971 $$.quad_positions[0] = 0;
972 for (int i = 0; i < $2.n_quads; i++) {
973 $$.quad_positions[i + 1] = $2.quad_positions[i] + 1;
976 Free($2.quad_positions);
980 seqUniversalCharstringFragment:
981 ConcatOp UniversalCharstringFragment
985 | seqUniversalCharstringFragment ConcatOp UniversalCharstringFragment
987 $$.n_uchars = $1.n_uchars + $3.n_uchars;
988 $$.uchars_ptr = (universal_char*)
989 Realloc($1.uchars_ptr, $$.n_uchars * sizeof(universal_char));
990 memcpy($$.uchars_ptr + $1.n_uchars, $3.uchars_ptr,
991 $3.n_uchars * sizeof(universal_char));
992 $$.n_quads = $1.n_quads + $3.n_quads;
993 $$.quad_positions = (int*)Realloc($1.quad_positions, $$.n_quads * sizeof(int));
994 for (int i = 0; i < $3.n_quads; i++) {
995 $$.quad_positions[$1.n_quads + i] = $3.quad_positions[i] + $1.n_uchars;
998 Free($3.quad_positions);
1002 UniversalCharstringFragment:
1005 $$.n_uchars = $1.n_chars;
1006 $$.uchars_ptr = (universal_char*)
1007 Malloc($$.n_uchars * sizeof(universal_char));
1008 for (int i = 0; i < $1.n_chars; i++) {
1009 $$.uchars_ptr[i].uc_group = 0;
1010 $$.uchars_ptr[i].uc_plane = 0;
1011 $$.uchars_ptr[i].uc_row = 0;
1012 $$.uchars_ptr[i].uc_cell = $1.chars_ptr[i];
1015 $$.quad_positions = 0;
1021 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
1022 $$.uchars_ptr[0] = $1;
1024 $$.quad_positions = (int*)Malloc(sizeof(int));
1025 $$.quad_positions[0] = 0;
1030 CharKeyword '(' IntegerValue ',' IntegerValue ',' IntegerValue ','
1033 if (*$3 < 0 || *$3 > 127) {
1034 char *s = $3->as_string();
1035 config_process_error_f("The first number of quadruple (group) must be "
1036 "within the range 0 .. 127 instead of %s.", s);
1038 $$.uc_group = *$3 < 0 ? 0 : 127;
1040 $$.uc_group = $3->get_val();
1042 if (*$5 < 0 || *$5 > 255) {
1043 char *s = $5->as_string();
1044 config_process_error_f("The second number of quadruple (plane) must be "
1045 "within the range 0 .. 255 instead of %s.", s);
1047 $$.uc_plane = *$5 < 0 ? 0 : 255;
1049 $$.uc_plane = $5->get_val();
1051 if (*$7 < 0 || *$7 > 255) {
1052 char *s = $7->as_string();
1053 config_process_error_f("The third number of quadruple (row) must be "
1054 "within the range 0 .. 255 instead of %s.", s);
1056 $$.uc_row = *$7 < 0 ? 0 : 255;
1058 $$.uc_row = $7->get_val();
1060 if (*$9 < 0 || *$9 > 255) {
1061 char *s = $9->as_string();
1062 config_process_error_f("The fourth number of quadruple (cell) must be "
1063 "within the range 0 .. 255 instead of %s.", s);
1065 $$.uc_cell = *$9 < 0 ? 0 : 255;
1067 $$.uc_cell = $9->get_val();
1083 $$ = mcopystr($1.chars_ptr);
1086 | StringValue ConcatOp Cstring
1088 $$ = mputstr($1, $3.chars_ptr);
1094 Identifier { $$ = $1; }
1095 | ASN1LowerIdentifier { $$ = $1; }
1101 $$ = new Module_Param_Value_List();
1103 | '{' FieldValueList '}'
1107 | '{' ArrayItemList '}'
1111 | '{' IndexItemList '}'
1115 | '(' ParameterValue ',' TemplateItemList ')' /* at least 2 elements to avoid shift/reduce conflicts with IntegerValue and FloatValue rules */
1117 $$ = new Module_Param_List_Template();
1118 $2->set_id(new Module_Param_Index($$->get_size(),false));
1120 $$->add_list_with_implicit_ids($4);
1123 | ComplementKeyword '(' TemplateItemList ')'
1125 $$ = new Module_Param_ComplementList_Template();
1126 $$->add_list_with_implicit_ids($3);
1129 | SupersetKeyword '(' TemplateItemList ')'
1131 $$ = new Module_Param_Superset_Template();
1132 $$->add_list_with_implicit_ids($3);
1135 | SubsetKeyword '(' TemplateItemList ')'
1137 $$ = new Module_Param_Subset_Template();
1138 $$->add_list_with_implicit_ids($3);
1143 ParameterValueOrNotUsedSymbol:
1150 $$ = new Module_Param_NotUsed();
1157 $$ = new Vector<Module_Param*>();
1160 | TemplateItemList ',' ParameterValue
1170 $$ = new Module_Param_Assignment_List();
1173 | FieldValueList ',' FieldValue
1181 FieldName AssignmentChar ParameterValueOrNotUsedSymbol
1184 $$->set_id(new Module_Param_FieldName($1));
1193 | ASN1LowerIdentifier
1202 $$ = new Module_Param_Value_List();
1203 $1->set_id(new Module_Param_Index($$->get_size(),false));
1206 | ArrayItemList ',' ArrayItem
1209 $3->set_id(new Module_Param_Index($$->get_size(),false));
1215 ParameterValueOrNotUsedSymbol
1219 | PermutationKeyword '(' TemplateItemList ')'
1221 $$ = new Module_Param_Permutation_Template();
1222 $$->add_list_with_implicit_ids($3);
1230 $$ = new Module_Param_Indexed_List();
1233 | IndexItemList ',' IndexItem
1241 IndexItemIndex AssignmentChar ParameterValue
1244 $$->set_id(new Module_Param_Index((size_t)$1,true));
1249 '[' IntegerValue ']'
1251 if (!$2->is_native()) {
1252 config_process_error("bignum index."); // todo
1254 if ($2->is_negative()) {
1255 config_process_error("negative index."); // todo
1262 /*************** [LOGGING] section *********************************/
1265 LoggingKeyword LoggingParamList
1270 | LoggingParamList LoggingParamLines optSemiColon
1272 // Centralized duplication handling for `[LOGGING]'.
1273 if ($2.logparam.log_param_selection != LP_UNKNOWN && TTCN_Logger::add_parameter($2)) {
1274 switch ($2.logparam.log_param_selection) {
1276 check_duplicate_option("LOGGING", "FileMask", file_mask_set);
1278 case LP_CONSOLEMASK:
1279 check_duplicate_option("LOGGING", "ConsoleMask", console_mask_set);
1281 case LP_LOGFILESIZE:
1282 check_duplicate_option("LOGGING", "LogFileSize", log_file_size_set);
1284 case LP_LOGFILENUMBER:
1285 check_duplicate_option("LOGGING", "LogFileNumber", log_file_number_set);
1287 case LP_DISKFULLACTION:
1288 check_duplicate_option("LOGGING", "DiskFullAction", log_disk_full_action_set);
1291 check_duplicate_option("LOGGING", "LogFile", file_name_set);
1293 case LP_TIMESTAMPFORMAT:
1294 check_duplicate_option("LOGGING", "TimeStampFormat", timestamp_format_set);
1296 case LP_SOURCEINFOFORMAT:
1297 check_duplicate_option("LOGGING", "SourceInfoFormat", source_info_format_set);
1300 check_duplicate_option("LOGGING", "AppendFile", append_file_set);
1302 case LP_LOGEVENTTYPES:
1303 check_duplicate_option("LOGGING", "LogEventTypes", log_event_types_set);
1305 case LP_LOGENTITYNAME:
1306 check_duplicate_option("LOGGING", "LogEntityName", log_entity_name_set);
1308 case LP_MATCHINGHINTS:
1309 check_duplicate_option("LOGGING", "MatchingVerbosity", matching_verbosity_set);
1311 case LP_PLUGIN_SPECIFIC:
1312 // It would be an overkill to check for the infinite number of custom parameters...
1313 check_duplicate_option("LOGGING", "PluginSpecific", plugin_specific_set);
1325 $$.component.id_selector = COMPONENT_ID_ALL;
1326 $$.component.id_name = NULL;
1327 $$.plugin_id = NULL;
1330 | ComponentId '.' LoggingParam
1333 $$.plugin_id = NULL;
1336 | ComponentId '.' LoggerPluginId '.' LoggingParam
1342 | LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1344 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1345 component_id_t comp;
1346 comp.id_selector = COMPONENT_ID_ALL;
1347 comp.id_name = NULL;
1348 logging_plugin_t *plugin = $4;
1349 while (plugin != NULL) {
1350 // `identifier' and `filename' are reused. Various checks and
1351 // validations must be done in the logger itself (e.g. looking for
1352 // duplicate options).
1353 TTCN_Logger::register_plugin(comp, plugin->identifier, plugin->filename);
1354 logging_plugin_t *tmp = plugin;
1358 $$.logparam.log_param_selection = LP_UNKNOWN;
1360 | ComponentId '.' LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1362 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1363 logging_plugin_t *plugin = $6;
1364 while (plugin != NULL) {
1365 TTCN_Logger::register_plugin($1, plugin->identifier, plugin->filename);
1366 logging_plugin_t *tmp = plugin;
1370 // Component names shall be duplicated in `register_plugin()'.
1371 if ($1.id_selector == COMPONENT_ID_NAME)
1373 $$.logparam.log_param_selection = LP_UNKNOWN;
1382 | LoggerPluginList ',' LoggerPlugin
1392 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1393 $$->identifier = $1;
1394 $$->filename = NULL;
1397 | Identifier AssignmentChar StringValue
1399 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1400 $$->identifier = $1;
1407 '*' { $$ = mcopystr("*"); }
1408 | Identifier { $$ = $1; }
1412 FileMask AssignmentChar LoggingBitmask
1414 $$.log_param_selection = LP_FILEMASK;
1415 $$.logoptions_val = $3;
1417 | ConsoleMask AssignmentChar LoggingBitmask
1419 $$.log_param_selection = LP_CONSOLEMASK;
1420 $$.logoptions_val = $3;
1422 | LogFileSize AssignmentChar Number
1424 $$.log_param_selection = LP_LOGFILESIZE;
1425 $$.int_val = (int)$3->get_val();
1428 | EmergencyLogging AssignmentChar Number
1430 $$.log_param_selection = LP_EMERGENCY;
1431 $$.int_val = (int)$3->get_val();
1434 | EmergencyLoggingBehaviour AssignmentChar EmergencyLoggingBehaviourValue
1436 $$.log_param_selection = LP_EMERGENCYBEHAVIOR;
1437 $$.emergency_logging_behaviour_value = $3;
1439 | EmergencyLoggingMask AssignmentChar LoggingBitmask
1441 $$.log_param_selection = LP_EMERGENCYMASK;
1442 $$.logoptions_val = $3;
1444 | LogFileNumber AssignmentChar Number
1446 $$.log_param_selection = LP_LOGFILENUMBER;
1447 $$.int_val = (int)$3->get_val();
1450 | DiskFullAction AssignmentChar DiskFullActionValue
1452 $$.log_param_selection = LP_DISKFULLACTION;
1453 $$.disk_full_action_value = $3;
1455 | LogFile AssignmentChar LogFileName
1457 $$.log_param_selection = LP_LOGFILE;
1460 | TimestampFormat AssignmentChar TimestampValue
1462 $$.log_param_selection = LP_TIMESTAMPFORMAT;
1463 $$.timestamp_value = $3;
1465 | ConsoleTimestampFormat AssignmentChar TimestampValue
1467 $$.log_param_selection = LP_UNKNOWN;
1469 | SourceInfoFormat AssignmentChar SourceInfoSetting
1471 $$.log_param_selection = LP_SOURCEINFOFORMAT;
1472 $$.source_info_value = $3;
1474 | AppendFile AssignmentChar YesNoOrBoolean
1476 $$.log_param_selection = LP_APPENDFILE;
1479 | LogEventTypes AssignmentChar LogEventTypesValue
1481 $$.log_param_selection = LP_LOGEVENTTYPES;
1482 $$.log_event_types_value = $3;
1484 | LogEntityName AssignmentChar YesNoOrBoolean
1486 $$.log_param_selection = LP_LOGENTITYNAME;
1489 | MatchingHints AssignmentChar VerbosityValue
1491 $$.log_param_selection = LP_MATCHINGHINTS;
1492 $$.matching_verbosity_value = $3;
1494 | Identifier AssignmentChar StringValue
1496 $$.log_param_selection = LP_PLUGIN_SPECIFIC;
1503 Compact { $$ = TTCN_Logger::VERBOSITY_COMPACT; }
1504 | Detailed { $$ = TTCN_Logger::VERBOSITY_FULL; }
1507 DiskFullActionValue:
1508 Error { $$.type = TTCN_Logger::DISKFULL_ERROR; }
1509 | Stop { $$.type = TTCN_Logger::DISKFULL_STOP; }
1512 $$.type = TTCN_Logger::DISKFULL_RETRY;
1513 $$.retry_interval = 30; /* default retry interval */
1515 | Retry '(' Number ')'
1517 $$.type = TTCN_Logger::DISKFULL_RETRY;
1518 $$.retry_interval = (size_t)$3->get_val();
1521 | Delete { $$.type = TTCN_Logger::DISKFULL_DELETE; }
1525 StringValue { $$ = $1; }
1528 LoggingBitOrCollection:
1534 | LoggingBitCollection
1539 case TTCN_Logger::ACTION_UNQUALIFIED:
1540 $$.add_sev(TTCN_Logger::ACTION_UNQUALIFIED);
1542 case TTCN_Logger::DEFAULTOP_UNQUALIFIED:
1543 $$.add_sev(TTCN_Logger::DEFAULTOP_ACTIVATE);
1544 $$.add_sev(TTCN_Logger::DEFAULTOP_DEACTIVATE);
1545 $$.add_sev(TTCN_Logger::DEFAULTOP_EXIT);
1546 $$.add_sev(TTCN_Logger::DEFAULTOP_UNQUALIFIED);
1548 case TTCN_Logger::ERROR_UNQUALIFIED:
1549 $$.add_sev(TTCN_Logger::ERROR_UNQUALIFIED);
1551 case TTCN_Logger::EXECUTOR_UNQUALIFIED:
1552 $$.add_sev(TTCN_Logger::EXECUTOR_RUNTIME);
1553 $$.add_sev(TTCN_Logger::EXECUTOR_CONFIGDATA);
1554 $$.add_sev(TTCN_Logger::EXECUTOR_EXTCOMMAND);
1555 $$.add_sev(TTCN_Logger::EXECUTOR_COMPONENT);
1556 $$.add_sev(TTCN_Logger::EXECUTOR_LOGOPTIONS);
1557 $$.add_sev(TTCN_Logger::EXECUTOR_UNQUALIFIED);
1559 case TTCN_Logger::FUNCTION_UNQUALIFIED:
1560 $$.add_sev(TTCN_Logger::FUNCTION_RND);
1561 $$.add_sev(TTCN_Logger::FUNCTION_UNQUALIFIED);
1563 case TTCN_Logger::PARALLEL_UNQUALIFIED:
1564 $$.add_sev(TTCN_Logger::PARALLEL_PTC);
1565 $$.add_sev(TTCN_Logger::PARALLEL_PORTCONN);
1566 $$.add_sev(TTCN_Logger::PARALLEL_PORTMAP);
1567 $$.add_sev(TTCN_Logger::PARALLEL_UNQUALIFIED);
1569 case TTCN_Logger::PORTEVENT_UNQUALIFIED:
1570 $$.add_sev(TTCN_Logger::PORTEVENT_PQUEUE);
1571 $$.add_sev(TTCN_Logger::PORTEVENT_MQUEUE);
1572 $$.add_sev(TTCN_Logger::PORTEVENT_STATE);
1573 $$.add_sev(TTCN_Logger::PORTEVENT_PMIN);
1574 $$.add_sev(TTCN_Logger::PORTEVENT_PMOUT);
1575 $$.add_sev(TTCN_Logger::PORTEVENT_PCIN);
1576 $$.add_sev(TTCN_Logger::PORTEVENT_PCOUT);
1577 $$.add_sev(TTCN_Logger::PORTEVENT_MMRECV);
1578 $$.add_sev(TTCN_Logger::PORTEVENT_MMSEND);
1579 $$.add_sev(TTCN_Logger::PORTEVENT_MCRECV);
1580 $$.add_sev(TTCN_Logger::PORTEVENT_MCSEND);
1581 $$.add_sev(TTCN_Logger::PORTEVENT_DUALRECV);
1582 $$.add_sev(TTCN_Logger::PORTEVENT_DUALSEND);
1583 $$.add_sev(TTCN_Logger::PORTEVENT_UNQUALIFIED);
1585 case TTCN_Logger::TESTCASE_UNQUALIFIED:
1586 $$.add_sev(TTCN_Logger::TESTCASE_START);
1587 $$.add_sev(TTCN_Logger::TESTCASE_FINISH);
1588 $$.add_sev(TTCN_Logger::TESTCASE_UNQUALIFIED);
1590 case TTCN_Logger::TIMEROP_UNQUALIFIED:
1591 $$.add_sev(TTCN_Logger::TIMEROP_READ);
1592 $$.add_sev(TTCN_Logger::TIMEROP_START);
1593 $$.add_sev(TTCN_Logger::TIMEROP_GUARD);
1594 $$.add_sev(TTCN_Logger::TIMEROP_STOP);
1595 $$.add_sev(TTCN_Logger::TIMEROP_TIMEOUT);
1596 $$.add_sev(TTCN_Logger::TIMEROP_UNQUALIFIED);
1598 case TTCN_Logger::USER_UNQUALIFIED:
1599 $$.add_sev(TTCN_Logger::USER_UNQUALIFIED);
1601 case TTCN_Logger::STATISTICS_UNQUALIFIED:
1602 $$.add_sev(TTCN_Logger::STATISTICS_VERDICT);
1603 $$.add_sev(TTCN_Logger::STATISTICS_UNQUALIFIED);
1605 case TTCN_Logger::VERDICTOP_UNQUALIFIED:
1606 $$.add_sev(TTCN_Logger::VERDICTOP_GETVERDICT);
1607 $$.add_sev(TTCN_Logger::VERDICTOP_SETVERDICT);
1608 $$.add_sev(TTCN_Logger::VERDICTOP_FINAL);
1609 $$.add_sev(TTCN_Logger::VERDICTOP_UNQUALIFIED);
1611 case TTCN_Logger::WARNING_UNQUALIFIED:
1612 $$.add_sev(TTCN_Logger::WARNING_UNQUALIFIED);
1614 case TTCN_Logger::MATCHING_UNQUALIFIED:
1615 $$.add_sev(TTCN_Logger::MATCHING_DONE);
1616 $$.add_sev(TTCN_Logger::MATCHING_TIMEOUT);
1617 $$.add_sev(TTCN_Logger::MATCHING_PCSUCCESS);
1618 $$.add_sev(TTCN_Logger::MATCHING_PCUNSUCC);
1619 $$.add_sev(TTCN_Logger::MATCHING_PMSUCCESS);
1620 $$.add_sev(TTCN_Logger::MATCHING_PMUNSUCC);
1621 $$.add_sev(TTCN_Logger::MATCHING_MCSUCCESS);
1622 $$.add_sev(TTCN_Logger::MATCHING_MCUNSUCC);
1623 $$.add_sev(TTCN_Logger::MATCHING_MMSUCCESS);
1624 $$.add_sev(TTCN_Logger::MATCHING_MMUNSUCC);
1625 $$.add_sev(TTCN_Logger::MATCHING_PROBLEM);
1626 $$.add_sev(TTCN_Logger::MATCHING_UNQUALIFIED);
1628 case TTCN_Logger::DEBUG_UNQUALIFIED:
1629 $$.add_sev(TTCN_Logger::DEBUG_ENCDEC);
1630 $$.add_sev(TTCN_Logger::DEBUG_TESTPORT);
1631 $$.add_sev(TTCN_Logger::DEBUG_UNQUALIFIED);
1633 case TTCN_Logger::LOG_ALL_IMPORTANT:
1634 $$ = Logging_Bits::log_all;
1637 /* The lexer sent something the parser doesn't understand!
1638 Parser needs to be updated.
1640 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
1641 "Internal error: unknown logbit from lexer.");
1648 LoggingBitOrCollection
1652 | LoggingBitmask '|' LoggingBitOrCollection
1660 SourceInfoValue { $$ = $1; }
1663 $$ = $1 ? TTCN_Logger::SINFO_SINGLE : TTCN_Logger::SINFO_NONE;
1669 | BooleanValue { $$ = $1; }
1673 YesNoOrBoolean { $$ = $1 ? TTCN_Logger::LOGEVENTTYPES_YES :
1674 TTCN_Logger::LOGEVENTTYPES_NO; }
1675 | SubCategories { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1676 | Detailed { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1679 /*********************** [PROFILER] ********************************/
1682 ProfilerKeyword ProfilerSettings
1687 | ProfilerSettings ProfilerSetting optSemiColon
1691 DisableProfilerSetting
1692 | DisableCoverageSetting
1693 | DatabaseFileSetting
1694 | AggregateDataSetting
1695 | StatisticsFileSetting
1696 | DisableStatisticsSetting
1697 | StatisticsFilterSetting
1698 | StartAutomaticallySetting
1699 | NetLineTimesSetting
1700 | NetFunctionTimesSetting
1703 DisableProfilerSetting:
1704 DisableProfilerKeyword AssignmentChar BooleanValue {
1705 ttcn3_prof.set_disable_profiler($3);
1709 DisableCoverageSetting:
1710 DisableCoverageKeyword AssignmentChar BooleanValue {
1711 ttcn3_prof.set_disable_coverage($3);
1715 DatabaseFileSetting:
1716 DatabaseFileKeyword AssignmentChar StringValue {
1717 ttcn3_prof.set_database_filename($3);
1721 AggregateDataSetting:
1722 AggregateDataKeyword AssignmentChar BooleanValue {
1723 ttcn3_prof.set_aggregate_data($3);
1727 StatisticsFileSetting:
1728 StatisticsFileKeyword AssignmentChar StringValue {
1729 ttcn3_prof.set_stats_filename($3);
1733 DisableStatisticsSetting:
1734 DisableStatisticsKeyword AssignmentChar BooleanValue {
1735 ttcn3_prof.set_disable_stats($3);
1739 StatisticsFilterSetting:
1740 StatisticsFilterKeyword AssignmentChar ProfilerStatsFlags {
1741 ttcn3_prof.reset_stats_flags();
1742 ttcn3_prof.add_stats_flags($3);
1744 | StatisticsFilterKeyword ConcatChar ProfilerStatsFlags {
1745 ttcn3_prof.add_stats_flags($3);
1750 ProfilerStatsFlag { $$ = $1; }
1751 | ProfilerStatsFlag '&' ProfilerStatsFlags { $$ = $1 | $3; }
1752 | ProfilerStatsFlag '|' ProfilerStatsFlags { $$ = $1 | $3; }
1755 StartAutomaticallySetting:
1756 StartAutomaticallyKeyword AssignmentChar BooleanValue {
1766 NetLineTimesSetting:
1767 NetLineTimesKeyword AssignmentChar BooleanValue {
1768 TTCN3_Stack_Depth::set_net_line_times($3);
1772 NetFunctionTimesSetting:
1773 NetFunctionTimesKeyword AssignmentChar BooleanValue {
1774 TTCN3_Stack_Depth::set_net_func_times($3);
1779 /**************** [TESTPORT_PARAMETERS] ****************************/
1781 TestportParametersSection:
1782 TestportParametersKeyword TestportParameterList
1785 TestportParameterList:
1787 | TestportParameterList TestportParameter optSemiColon
1791 ComponentId '.' TestportName '.' TestportParameterName AssignmentChar
1792 TestportParameterValue
1794 PORT::add_parameter($1, $3, $5, $7);
1795 if ($1.id_selector == COMPONENT_ID_NAME) Free($1.id_name);
1805 $$.id_selector = COMPONENT_ID_NAME;
1810 $$.id_selector = COMPONENT_ID_NAME;
1811 $$.id_name = $1.chars_ptr;
1815 $$.id_selector = COMPONENT_ID_COMPREF;
1816 $$.id_compref = (component)$1->get_val();
1821 $$.id_selector = COMPONENT_ID_COMPREF;
1822 $$.id_compref = MTC_COMPREF;
1826 $$.id_selector = COMPONENT_ID_ALL;
1831 $$.id_selector = COMPONENT_ID_SYSTEM;
1837 Identifier { $$ = $1; }
1838 | Identifier ArrayRef
1840 $$ = mputstr($1, $2);
1843 | '*' { $$ = NULL; }
1847 '[' IntegerValue ']'
1849 char *s = $2->as_string();
1851 $$ = mputc ($$, '[');
1852 $$ = mputstr($$, s);
1853 $$ = mputc ($$, ']');
1857 | ArrayRef '[' IntegerValue ']'
1859 char *s = $3->as_string();
1860 $$ = mputc ($1, '[');
1861 $$ = mputstr($$, s);
1862 $$ = mputc ($$, ']');
1868 TestportParameterName:
1869 Identifier { $$ = $1; }
1872 TestportParameterValue:
1873 StringValue { $$ = $1; }
1876 /****************** [EXECUTE] section *************/
1879 ExecuteKeyword ExecuteList
1881 if (!TTCN_Runtime::is_single()) config_process_error("Internal error: "
1882 "the Main Controller must not send section [EXECUTE] of the "
1883 "configuration file.");
1889 | ExecuteList ExecuteItem optSemiColon
1891 if (TTCN_Runtime::is_single()) {
1892 execute_list = (execute_list_item *)Realloc(
1893 execute_list, (execute_list_len + 1) *
1894 sizeof(*execute_list));
1895 execute_list[execute_list_len++] = $2;
1897 Free($2.module_name);
1898 Free($2.testcase_name);
1906 $$.module_name = $1;
1907 $$.testcase_name = NULL;
1909 | Identifier '.' ControlKeyword
1911 $$.module_name = $1;
1912 $$.testcase_name = NULL;
1914 | Identifier '.' Identifier
1916 $$.module_name = $1;
1917 $$.testcase_name = $3;
1919 | Identifier '.' '*'
1921 $$.module_name = $1;
1922 $$.testcase_name = mcopystr("*");
1926 /****************** [EXTERNAL_COMMANDS] section **********************/
1928 ExternalCommandsSection:
1929 ExternalCommandsKeyword ExternalCommandList
1932 ExternalCommandList:
1934 | ExternalCommandList ExternalCommand optSemiColon
1938 BeginControlPart AssignmentChar Command
1940 check_duplicate_option("EXTERNAL_COMMANDS", "BeginControlPart",
1941 begin_controlpart_command_set);
1943 TTCN_Runtime::set_begin_controlpart_command($3);
1947 | EndControlPart AssignmentChar Command
1949 check_duplicate_option("EXTERNAL_COMMANDS", "EndControlPart",
1950 end_controlpart_command_set);
1952 TTCN_Runtime::set_end_controlpart_command($3);
1956 | BeginTestCase AssignmentChar Command
1958 check_duplicate_option("EXTERNAL_COMMANDS", "BeginTestCase",
1959 begin_testcase_command_set);
1961 TTCN_Runtime::set_begin_testcase_command($3);
1965 | EndTestCase AssignmentChar Command
1967 check_duplicate_option("EXTERNAL_COMMANDS", "EndTestCase",
1968 end_testcase_command_set);
1970 TTCN_Runtime::set_end_testcase_command($3);
1977 StringValue { $$ = $1; }
1980 /***************** [GROUPS] section *******************/
1983 GroupsKeyword GroupList
1985 check_ignored_section("GROUPS");
1991 | GroupList Group optSemiColon
1995 GroupName AssignmentChar GroupMembers
1999 Identifier { Free($1); }
2009 | seqGroupMember ',' HostName
2014 | Identifier { Free($1); }
2017 /******************** [COMPONENTS] section *******************/
2019 ComponentsKeyword ComponentList
2021 check_ignored_section("COMPONENTS");
2027 | ComponentList ComponentItem optSemiColon
2031 ComponentName AssignmentChar ComponentLocation
2035 Identifier { Free($1); }
2040 Identifier { Free($1); }
2044 /****************** [MAIN_CONTROLLER] section *********************/
2045 MainControllerSection:
2046 MainControllerKeyword MCParameterList
2048 check_ignored_section("MAIN_CONTROLLER");
2054 | MCParameterList MCParameter optSemiColon
2058 LocalAddress AssignmentChar HostName { }
2059 | TCPPort AssignmentChar IntegerValue { delete $3; }
2060 | KillTimer AssignmentChar KillTimerValue { }
2061 | NumHCs AssignmentChar IntegerValue { delete $3; }
2062 | UnixSocketEnabled AssignmentChar YesToken {}
2063 | UnixSocketEnabled AssignmentChar NoToken {}
2064 | UnixSocketEnabled AssignmentChar HostName {}
2069 | IntegerValue { delete $1; }
2072 /****************** [INCLUDE] section *********************/
2074 IncludeKeyword IncludeFiles
2076 if(!TTCN_Runtime::is_single())
2077 config_process_error
2078 ("Internal error: the Main Controller must not send section [INCLUDE]"
2079 " of the configuration file.");
2085 | IncludeFiles IncludeFile
2089 Cstring { Free($1.chars_ptr); }
2092 /****************** [DEFINE] section *********************/
2096 if(!TTCN_Runtime::is_single())
2097 config_process_error
2098 ("Internal error: the Main Controller must not send section [DEFINE]"
2099 " of the configuration file.");
2103 /*********************************************************/
2108 $$ = Module_Param::OT_ASSIGN;
2113 $$ = Module_Param::OT_CONCAT;
2124 static void reset_configuration_options()
2126 /* Section [MODULE_PARAMETERS */
2127 /** \todo reset module parameters to their default values */
2128 /* Section [LOGGING] */
2129 TTCN_Logger::close_file();
2130 TTCN_Logger::reset_configuration();
2131 file_name_set = FALSE;
2132 file_mask_set = TRUE;
2133 console_mask_set = TRUE;
2134 timestamp_format_set = FALSE;
2135 source_info_format_set = FALSE;
2136 append_file_set = FALSE;
2137 log_event_types_set = FALSE;
2138 log_entity_name_set = FALSE;
2139 /* Section [TESTPORT_PARAMETERS] */
2140 PORT::clear_parameters();
2141 /* Section [EXTERNAL_COMMANDS] */
2143 TTCN_Runtime::clear_external_commands();
2145 begin_controlpart_command_set = FALSE;
2146 end_controlpart_command_set = FALSE;
2147 begin_testcase_command_set = FALSE;
2148 end_testcase_command_set = FALSE;
2151 Module_Param* process_config_string2ttcn(const char* mp_str, bool is_component)
2153 if (parsed_module_param!=NULL || parsing_error_messages!=NULL) TTCN_error("Internal error: previously parsed ttcn string was not cleared.");
2154 // add the hidden keyword
2155 std::string mp_string = (is_component) ? std::string("$#&&&(#TTCNSTRINGPARSING_COMPONENT$#&&^#% ") + mp_str
2156 : std::string("$#&&&(#TTCNSTRINGPARSING$#&&^#% ") + mp_str;
2157 struct yy_buffer_state *flex_buffer = config_process__scan_bytes(mp_string.c_str(), (int)mp_string.size());
2158 if (flex_buffer == NULL) TTCN_error("Internal error: flex buffer creation failed.");
2159 reset_config_process_lex(NULL);
2162 Ttcn_String_Parsing ttcn_string_parsing;
2163 if (config_process_parse()) error_flag = TRUE;
2164 } catch (const TC_Error& TC_error) {
2165 if (parsed_module_param!=NULL) { delete parsed_module_param; parsed_module_param = NULL; }
2168 config_process_close();
2169 config_process_lex_destroy();
2171 if (error_flag || parsing_error_messages!=NULL) {
2172 delete parsed_module_param;
2173 parsed_module_param = NULL;
2174 char* pem = parsing_error_messages!=NULL ? parsing_error_messages : mcopystr("Unknown parsing error");
2175 parsing_error_messages = NULL;
2176 TTCN_error_begin("%s", pem);
2181 if (parsed_module_param==NULL) TTCN_error("Internal error: could not parse ttcn string.");
2182 Module_Param* ret_val = parsed_module_param;
2183 parsed_module_param = NULL;
2188 boolean process_config_string(const char *config_string, int string_len)
2192 struct yy_buffer_state *flex_buffer =
2193 config_process__scan_bytes(config_string, string_len);
2194 if (flex_buffer == NULL) {
2195 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
2196 "Internal error: flex buffer creation failed.");
2201 reset_configuration_options();
2202 reset_config_process_lex(NULL);
2203 if (config_process_parse()) error_flag = TRUE;
2205 } catch (const TC_Error& TC_error) {
2209 config_process_close();
2210 config_process_lex_destroy();
2216 boolean process_config_file(const char *file_name)
2219 string_chain_t *filenames=NULL;
2221 reset_configuration_options();
2223 if(preproc_parse_file(file_name, &filenames, &config_defines))
2227 char *fn=string_chain_cut(&filenames);
2228 reset_config_process_lex(fn);
2229 /* The lexer can modify config_process_in
2230 * when it's input buffer is changed */
2231 config_process_in = fopen(fn, "r");
2232 FILE* tmp_cfg = config_process_in;
2233 if (config_process_in != NULL) {
2235 if(config_process_parse()) error_flag=TRUE;
2236 } catch (const TC_Error& TC_error) {
2240 config_process_close();
2241 config_process_lex_destroy();
2243 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2244 TTCN_Logger::log_event("Cannot open configuration file: %s", fn);
2245 TTCN_Logger::OS_error();
2246 TTCN_Logger::end_event();
2249 /* During parsing flex or libc may use some system calls (e.g. ioctl)
2250 * that fail with an error status. Such error codes shall be ignored in
2251 * future error messages. */
2257 string_map_free(config_defines);
2258 config_defines = NULL;
2263 void config_process_error_f(const char *error_str, ...)
2265 if (Ttcn_String_Parsing::happening()) {
2267 va_start(p_var, error_str);
2268 char* error_msg_str = mprintf_va_list(error_str, p_var);
2270 if (parsing_error_messages!=NULL) parsing_error_messages = mputc(parsing_error_messages, '\n');
2271 parsing_error_messages = mputprintf(parsing_error_messages,
2272 "Parse error in line %d, at or before token `%s': %s", config_process_get_current_line(), config_process_text, error_msg_str);
2273 Free(error_msg_str);
2277 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2278 if (!get_cfg_process_current_file().empty()) {
2279 TTCN_Logger::log_event("Parse error in configuration file `%s': in line %d, "
2280 "at or before token `%s': ",
2281 get_cfg_process_current_file().c_str(), config_process_get_current_line(),
2285 TTCN_Logger::log_event("Parse error while reading configuration "
2286 "information: in line %d, at or before token `%s': ",
2287 config_process_get_current_line(), config_process_text);
2290 va_start(pvar, error_str);
2291 TTCN_Logger::log_event_va_list(error_str, pvar);
2293 TTCN_Logger::end_event();
2297 void config_process_error(const char *error_str)
2299 config_process_error_f("%s", error_str);
2302 void config_preproc_error(const char *error_str, ...)
2304 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2305 TTCN_Logger::log_event("Parse error while pre-processing configuration"
2306 " file `%s': in line %d: ",
2307 get_cfg_preproc_current_file().c_str(),
2308 config_preproc_yylineno);
2310 va_start(pvar, error_str);
2311 TTCN_Logger::log_event_va_list(error_str, pvar);
2313 TTCN_Logger::end_event();
2317 void path_error(const char *fmt, ...)
2320 fprintf(stderr, "File error: ");
2321 va_start(parameters, fmt);
2322 vfprintf(stderr, fmt, parameters);
2324 fprintf(stderr, "\n");
2327 static void check_duplicate_option(const char *section_name,
2328 const char *option_name, boolean& option_flag)
2331 TTCN_warning("Option `%s' was given more than once in section [%s] of the "
2332 "configuration file.", option_name, section_name);
2333 } else option_flag = TRUE;
2336 static void check_ignored_section(const char *section_name)
2338 if (TTCN_Runtime::is_single()) TTCN_warning("Section [%s] of "
2339 "configuration file is ignored in single mode.", section_name);
2340 else config_process_error_f("Internal error: the Main Controller must not "
2341 "send section [%s] of the configuration file.", section_name);
2344 static void set_param(Module_Param& param)
2347 Module_List::set_param(param);
2349 catch (const TC_Error& TC_error) {
2354 unsigned char char_to_hexdigit(char c)
2356 if (c >= '0' && c <= '9') return c - '0';
2357 else if (c >= 'A' && c <= 'F') return c - 'A' + 10;
2358 else if (c >= 'a' && c <= 'f') return c - 'a' + 10;
2360 config_process_error_f("char_to_hexdigit(): invalid argument: %c", c);
2361 return 0; // to avoid warning