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"
229 %type <int_val> IntegerValue
230 %type <float_val> FloatValue
231 %type <objid_val> ObjIdValue ObjIdComponentList
232 %type <int_val> ObjIdComponent NumberForm NameAndNumberForm
234 %type <universal_charstring_val> UniversalCharstringValue
235 seqUniversalCharstringFragment UniversalCharstringFragment
236 %type <universal_char_val> Quadruple
237 %type <str_val> EnumeratedValue
239 %type <str_val> LoggerPluginId
240 %type <logging_plugins> LoggerPlugin LoggerPluginList
241 %type <logging_params> LoggingParam
242 %type <logging_param_line> LoggingParamLines
243 %type <str_val> LogFileName StringValue
244 /* a collection of bits */
245 %type <logoptions_val> LoggingBitmask
246 %type <logoptions_val> LoggingBitOrCollection
247 %type <source_info_value> SourceInfoSetting
248 %type <bool_val> YesNoOrBoolean
249 %type <log_event_types_value> LogEventTypesValue
250 %type <disk_full_action_value> DiskFullActionValue
251 %type <str_val> Command
252 %type <matching_verbosity_value> VerbosityValue
253 %type <comp_id> ComponentId
254 %type <str_val> TestportName ArrayRef TestportParameterName
255 TestportParameterValue
257 %type <execute_item_val> ExecuteItem
259 %type <bitstring_val> BitstringValue
260 %type <hexstring_val> HexstringValue
261 %type <octetstring_val> OctetstringValue
263 %type <name_vector> ParameterName ParameterNameSegment
264 %type <param_optype_val> ParamOpType
265 %type <str_val> FieldName
266 %type <module_param_val> ParameterValue SimpleParameterValue ParameterValueOrNotUsedSymbol
267 FieldValue ArrayItem IndexItem IndexItemList FieldValueList ArrayItemList CompoundValue IntegerRange FloatRange StringRange
268 %type <module_param_list> TemplateItemList
269 %type <module_param_length_restriction> LengthMatch
270 %type <str_val> PatternChunk PatternChunkList
271 %type <int_native> IndexItemIndex LengthBound
273 %destructor { Free($$); }
283 TestportParameterName
284 TestportParameterValue
291 %destructor { Free($$.components_ptr); }
295 %destructor { Free($$.bits_ptr); }
299 %destructor { Free($$.nibbles_ptr); }
303 %destructor { Free($$.octets_ptr); }
307 %destructor { Free($$.chars_ptr); }
310 %destructor { Free($$.uchars_ptr); Free($$.quad_positions); }
311 seqUniversalCharstringFragment
312 UniversalCharstringFragment
313 UniversalCharstringValue
315 %destructor { if ($$.id_selector == COMPONENT_ID_NAME) Free($$.id_name); }
318 %destructor { Free($$.module_name); Free($$.testcase_name); }
321 %destructor { delete $$; }
329 ParameterValueOrNotUsedSymbol
341 %destructor { delete $$; }
344 %destructor { for(size_t i=0; i<$$->size(); i++) { delete $$->at(i); } delete $$; }
347 %destructor { for(size_t i=0; i<$$->size(); i++) { Free($$->at(i)); } delete $$; }
358 2 conflicts in two distinct states.
359 When seeing a '*' token after an integer or float value in section
360 [MODULE_PARAMETERS] parser cannot decide whether the token is a multiplication
361 operator (shift) or it refers to all modules in the next module parameter
369 if (Ttcn_String_Parsing::happening()) {
370 config_process_error("Config file cannot be parsed as ttcn string");
373 | TtcnStringParsingKeyword ParameterValue
375 parsed_module_param = $2;
385 ModuleParametersSection
388 | TestportParametersSection
390 | ExternalCommandsSection
393 | MainControllerSection
398 ModuleParametersSection:
399 ModuleParametersKeyword ModuleParameters
404 | ModuleParameters ModuleParameter optSemiColon
408 ParameterName ParamOpType ParameterValue
410 Module_Param* mp = $3;
411 mp->set_id(new Module_Param_Name(*$1));
412 mp->set_operation_type($2);
420 ParameterNameSegment { $$ = $1; }
421 | '*' '.' ParameterNameSegment { $$ = $3; }
424 ParameterNameSegment:
425 ParameterNameSegment '.' Identifier
430 | ParameterNameSegment '[' Number ']'
433 $$->push_back($3->as_string());
438 $$ = new Vector<char*>();
448 | SimpleParameterValue LengthMatch
451 $$->set_length_restriction($2);
453 | SimpleParameterValue IfpresentKeyword
458 | SimpleParameterValue LengthMatch IfpresentKeyword
461 $$->set_length_restriction($2);
467 LengthKeyword '(' LengthBound ')'
469 $$ = new Module_Param_Length_Restriction();
470 $$->set_single((size_t)$3);
472 | LengthKeyword '(' LengthBound DotDot LengthBound ')'
475 config_process_error("invalid length restriction: lower bound > upper bound");
477 $$ = new Module_Param_Length_Restriction();
478 $$->set_min((size_t)$3);
479 $$->set_max((size_t)$5);
481 | LengthKeyword '(' LengthBound DotDot InfinityKeyword ')'
483 $$ = new Module_Param_Length_Restriction();
484 $$->set_min((size_t)$3);
491 if (!$1->is_native()) {
492 config_process_error("bignum length restriction bound.");
494 } else if ($1->is_negative()) {
495 config_process_error("negative length restriction bound.");
504 SimpleParameterValue:
507 $$ = new Module_Param_Integer($1);
511 $$ = new Module_Param_Float($1);
515 $$ = new Module_Param_Boolean($1);
519 $$ = new Module_Param_Objid($1.n_components, $1.components_ptr);
523 $$ = new Module_Param_Verdict($1);
527 $$ = new Module_Param_Bitstring($1.n_bits, $1.bits_ptr);
531 $$ = new Module_Param_Hexstring($1.n_nibbles, $1.nibbles_ptr);
535 $$ = new Module_Param_Octetstring($1.n_octets, $1.octets_ptr);
539 $$ = new Module_Param_Charstring($1.n_chars, $1.chars_ptr);
541 | UniversalCharstringValue
543 $$ = new Module_Param_Universal_Charstring($1.n_uchars, $1.uchars_ptr, $1.n_quads, $1.quad_positions);
547 $$ = new Module_Param_Enumerated($1);
551 $$ = new Module_Param_Omit();
555 $$ = new Module_Param_Asn_Null();
559 $$ = new Module_Param_Ttcn_Null();
563 $$ = new Module_Param_Ttcn_mtc();
567 $$ = new Module_Param_Ttcn_system();
571 $$ = new Module_Param_Any();
575 $$ = new Module_Param_AnyOrNone();
589 | PatternKeyword PatternChunkList
591 $$ = new Module_Param_Pattern($2);
596 int n_chars = (int)mstrlen($1);
597 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
598 for (int i=0; i<n_chars; i++) {
614 config_process_error_f("Invalid char (%c) in bitstring template", $1[i]);
618 $$ = new Module_Param_Bitstring_Template(n_chars, chars_ptr);
622 int n_chars = (int)mstrlen($1);
623 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
624 for (int i=0; i<n_chars; i++) {
625 if ($1[i]=='?') chars_ptr[i] = 16;
626 else if ($1[i]=='*') chars_ptr[i] = 17;
627 else chars_ptr[i] = char_to_hexdigit($1[i]);
630 $$ = new Module_Param_Hexstring_Template(n_chars, chars_ptr);
634 Vector<unsigned short> octet_vec;
635 int str_len = (int)mstrlen($1);
636 for (int i=0; i<str_len; i++) {
638 if ($1[i]=='?') num = 256;
639 else if ($1[i]=='*') num = 257;
642 num = 16 * char_to_hexdigit($1[i]);
644 if (i>=str_len) config_process_error("Unexpected end of octetstring pattern");
646 num += char_to_hexdigit($1[i]);
648 octet_vec.push_back(num);
651 int n_chars = (int)octet_vec.size();
652 unsigned short* chars_ptr = (unsigned short*)Malloc(n_chars*sizeof(unsigned short));
653 for (int i=0; i<n_chars; i++) chars_ptr[i] = octet_vec[i];
654 $$ = new Module_Param_Octetstring_Template(n_chars, chars_ptr);
667 | PatternChunkList '&' PatternChunk
670 $$ = mputstr($$, $3);
678 $$ = mcopystr($1.chars_ptr);
683 $$ = mprintf("\\q{%d,%d,%d,%d}", $1.uc_group, $1.uc_plane, $1.uc_row, $1.uc_cell);
688 '(' '-' InfinityKeyword DotDot IntegerValue ')'
690 $$ = new Module_Param_IntRange(NULL, $5);
692 | '(' IntegerValue DotDot IntegerValue ')'
694 $$ = new Module_Param_IntRange($2, $4);
696 | '(' IntegerValue DotDot InfinityKeyword ')'
698 $$ = new Module_Param_IntRange($2, NULL);
703 '(' '-' InfinityKeyword DotDot FloatValue ')'
705 $$ = new Module_Param_FloatRange(0.0, false, $5, true);
707 | '(' FloatValue DotDot FloatValue ')'
709 $$ = new Module_Param_FloatRange($2, true, $4, true);
711 | '(' FloatValue DotDot InfinityKeyword ')'
713 $$ = new Module_Param_FloatRange($2, true, 0.0, false);
718 '(' UniversalCharstringFragment DotDot UniversalCharstringFragment ')'
720 universal_char lower; lower.uc_group=lower.uc_plane=lower.uc_row=lower.uc_cell=0;
721 universal_char upper; upper.uc_group=upper.uc_plane=upper.uc_row=upper.uc_cell=0;
722 if ($2.n_uchars!=1) {
723 config_process_error("Lower bound of char range must be 1 character only");
724 } else if ($4.n_uchars!=1) {
725 config_process_error("Upper bound of char range must be 1 character only");
727 lower = *($2.uchars_ptr);
728 upper = *($4.uchars_ptr);
730 config_process_error("Lower bound is larger than upper bound in the char range");
736 Free($2.quad_positions);
737 Free($4.quad_positions);
738 $$ = new Module_Param_StringRange(lower, upper);
744 | '(' IntegerValue ')' { $$ = $2; }
745 | '+' IntegerValue %prec UnarySign { $$ = $2; }
746 | '-' IntegerValue %prec UnarySign
750 $$ = new int_val_t((-op1).get_val());
753 | IntegerValue '+' IntegerValue
758 $$ = new int_val_t((op1 + op2).get_val());
762 | IntegerValue '-' IntegerValue
767 $$ = new int_val_t((op1 - op2).get_val());
771 | IntegerValue '*' IntegerValue
776 $$ = new int_val_t((op1 * op2).get_val());
780 | IntegerValue '/' IntegerValue
783 config_process_error("Integer division by zero.");
784 $$ = new int_val_t((RInt)0);
791 $$ = new int_val_t((op1 / op2).get_val());
800 | '(' FloatValue ')' { $$ = $2; }
801 | '+' FloatValue %prec UnarySign { $$ = $2; }
802 | '-' FloatValue %prec UnarySign { $$ = -$2; }
803 | FloatValue '+' FloatValue { $$ = $1 + $3; }
804 | FloatValue '-' FloatValue { $$ = $1 - $3; }
805 | FloatValue '*' FloatValue { $$ = $1 * $3; }
806 | FloatValue '/' FloatValue
809 config_process_error("Floating point division by zero.");
816 ObjIdKeyword '{' ObjIdComponentList '}' { $$ = $3; }
823 $$.components_ptr = (int *)Malloc(sizeof(int));
824 $$.components_ptr[0] = $1->get_val();
827 | ObjIdComponentList ObjIdComponent
829 $$.n_components = $1.n_components + 1;
830 $$.components_ptr = (int *)Realloc($1.components_ptr,
831 $$.n_components * sizeof(int));
832 $$.components_ptr[$$.n_components - 1] = $2->get_val();
838 NumberForm { $$ = $1; }
839 | NameAndNumberForm { $$ = $1; }
847 Identifier '(' Number ')'
859 | BitstringValue ConcatOp Bstring
861 $$.n_bits = $1.n_bits + $3.n_bits;
862 int n_bytes_1 = ($1.n_bits+7)/8;
863 int n_bytes_3 = ($3.n_bits+7)/8;
864 int n_bytes = ($$.n_bits+7)/8;
865 $$.bits_ptr = (unsigned char *)Realloc($1.bits_ptr, n_bytes);
866 int n_rem_1 = $1.n_bits % 8; // remainder bits
868 for (int i=n_bytes_1; i<n_bytes; i++) {
869 unsigned char S3_byte = $3.bits_ptr[i-n_bytes_1];
870 $$.bits_ptr[i-1] |= S3_byte << n_rem_1;
871 $$.bits_ptr[i] = S3_byte >> (8-n_rem_1);
873 if (n_bytes_1+n_bytes_3>n_bytes)
874 $$.bits_ptr[n_bytes-1] |= $3.bits_ptr[n_bytes_3-1] << n_rem_1;
876 memcpy($$.bits_ptr + n_bytes_1, $3.bits_ptr, n_bytes_3);
887 | HexstringValue ConcatOp Hstring
889 $$.n_nibbles = $1.n_nibbles + $3.n_nibbles;
890 int n_bytes = ($$.n_nibbles + 1) / 2;
891 $$.nibbles_ptr = (unsigned char *)Realloc($1.nibbles_ptr, n_bytes);
892 int n_bytes_1 = ($1.n_nibbles + 1) / 2;
893 int n_bytes_3 = ($3.n_nibbles + 1) / 2;
894 if ($1.n_nibbles % 2) {
895 for (int i=n_bytes_1; i<n_bytes; i++) {
896 unsigned char S3_byte = $3.nibbles_ptr[i - n_bytes_1];
897 $$.nibbles_ptr[i - 1] |= S3_byte << 4;
898 $$.nibbles_ptr[i] = S3_byte >> 4;
900 if ($3.n_nibbles % 2)
901 $$.nibbles_ptr[n_bytes - 1] |= $3.nibbles_ptr[n_bytes_3 - 1] << 4;
903 memcpy($$.nibbles_ptr + n_bytes_1, $3.nibbles_ptr, n_bytes_3);
905 Free($3.nibbles_ptr);
914 | OctetstringValue ConcatOp Ostring
916 $$.n_octets = $1.n_octets + $3.n_octets;
917 $$.octets_ptr = (unsigned char *)Realloc($1.octets_ptr, $$.n_octets);
918 memcpy($$.octets_ptr + $1.n_octets, $3.octets_ptr, $3.n_octets);
923 UniversalCharstringValue:
924 Cstring seqUniversalCharstringFragment
926 $$.n_uchars = $1.n_chars + $2.n_uchars;
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];
935 memcpy($$.uchars_ptr + $1.n_chars, $2.uchars_ptr,
936 $2.n_uchars * sizeof(universal_char));
937 $$.n_quads = $2.n_quads;
938 $$.quad_positions = (int*)Malloc($$.n_quads * sizeof(int));
939 for (int i = 0; i < $$.n_quads; i++) {
940 $$.quad_positions[i] = $2.quad_positions[i] + $1.n_chars;
944 Free($2.quad_positions);
949 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
950 $$.uchars_ptr[0] = $1;
952 $$.quad_positions = (int*)Malloc(sizeof(int));
953 $$.quad_positions[0] = 0;
955 | Quadruple seqUniversalCharstringFragment
957 $$.n_uchars = $2.n_uchars + 1;
958 $$.uchars_ptr = (universal_char*)
959 Malloc($$.n_uchars * sizeof(universal_char));
960 $$.uchars_ptr[0] = $1;
961 memcpy($$.uchars_ptr + 1, $2.uchars_ptr,
962 $2.n_uchars * sizeof(universal_char));
963 $$.n_quads = $2.n_quads + 1;
964 $$.quad_positions = (int*)Malloc($$.n_quads * sizeof(int));
965 $$.quad_positions[0] = 0;
966 for (int i = 0; i < $2.n_quads; i++) {
967 $$.quad_positions[i + 1] = $2.quad_positions[i] + 1;
970 Free($2.quad_positions);
974 seqUniversalCharstringFragment:
975 ConcatOp UniversalCharstringFragment
979 | seqUniversalCharstringFragment ConcatOp UniversalCharstringFragment
981 $$.n_uchars = $1.n_uchars + $3.n_uchars;
982 $$.uchars_ptr = (universal_char*)
983 Realloc($1.uchars_ptr, $$.n_uchars * sizeof(universal_char));
984 memcpy($$.uchars_ptr + $1.n_uchars, $3.uchars_ptr,
985 $3.n_uchars * sizeof(universal_char));
986 $$.n_quads = $1.n_quads + $3.n_quads;
987 $$.quad_positions = (int*)Realloc($1.quad_positions, $$.n_quads * sizeof(int));
988 for (int i = 0; i < $3.n_quads; i++) {
989 $$.quad_positions[$1.n_quads + i] = $3.quad_positions[i] + $1.n_uchars;
992 Free($3.quad_positions);
996 UniversalCharstringFragment:
999 $$.n_uchars = $1.n_chars;
1000 $$.uchars_ptr = (universal_char*)
1001 Malloc($$.n_uchars * sizeof(universal_char));
1002 for (int i = 0; i < $1.n_chars; i++) {
1003 $$.uchars_ptr[i].uc_group = 0;
1004 $$.uchars_ptr[i].uc_plane = 0;
1005 $$.uchars_ptr[i].uc_row = 0;
1006 $$.uchars_ptr[i].uc_cell = $1.chars_ptr[i];
1009 $$.quad_positions = 0;
1015 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
1016 $$.uchars_ptr[0] = $1;
1018 $$.quad_positions = (int*)Malloc(sizeof(int));
1019 $$.quad_positions[0] = 0;
1024 CharKeyword '(' IntegerValue ',' IntegerValue ',' IntegerValue ','
1027 if (*$3 < 0 || *$3 > 127) {
1028 char *s = $3->as_string();
1029 config_process_error_f("The first number of quadruple (group) must be "
1030 "within the range 0 .. 127 instead of %s.", s);
1032 $$.uc_group = *$3 < 0 ? 0 : 127;
1034 $$.uc_group = $3->get_val();
1036 if (*$5 < 0 || *$5 > 255) {
1037 char *s = $5->as_string();
1038 config_process_error_f("The second number of quadruple (plane) must be "
1039 "within the range 0 .. 255 instead of %s.", s);
1041 $$.uc_plane = *$5 < 0 ? 0 : 255;
1043 $$.uc_plane = $5->get_val();
1045 if (*$7 < 0 || *$7 > 255) {
1046 char *s = $7->as_string();
1047 config_process_error_f("The third number of quadruple (row) must be "
1048 "within the range 0 .. 255 instead of %s.", s);
1050 $$.uc_row = *$7 < 0 ? 0 : 255;
1052 $$.uc_row = $7->get_val();
1054 if (*$9 < 0 || *$9 > 255) {
1055 char *s = $9->as_string();
1056 config_process_error_f("The fourth number of quadruple (cell) must be "
1057 "within the range 0 .. 255 instead of %s.", s);
1059 $$.uc_cell = *$9 < 0 ? 0 : 255;
1061 $$.uc_cell = $9->get_val();
1077 $$ = mcopystr($1.chars_ptr);
1080 | StringValue ConcatOp Cstring
1082 $$ = mputstr($1, $3.chars_ptr);
1088 Identifier { $$ = $1; }
1089 | ASN1LowerIdentifier { $$ = $1; }
1095 $$ = new Module_Param_Value_List();
1097 | '{' FieldValueList '}'
1101 | '{' ArrayItemList '}'
1105 | '{' IndexItemList '}'
1109 | '(' ParameterValue ',' TemplateItemList ')' /* at least 2 elements to avoid shift/reduce conflicts with IntegerValue and FloatValue rules */
1111 $$ = new Module_Param_List_Template();
1112 $2->set_id(new Module_Param_Index($$->get_size(),false));
1114 $$->add_list_with_implicit_ids($4);
1117 | ComplementKeyword '(' TemplateItemList ')'
1119 $$ = new Module_Param_ComplementList_Template();
1120 $$->add_list_with_implicit_ids($3);
1123 | SupersetKeyword '(' TemplateItemList ')'
1125 $$ = new Module_Param_Superset_Template();
1126 $$->add_list_with_implicit_ids($3);
1129 | SubsetKeyword '(' TemplateItemList ')'
1131 $$ = new Module_Param_Subset_Template();
1132 $$->add_list_with_implicit_ids($3);
1137 ParameterValueOrNotUsedSymbol:
1144 $$ = new Module_Param_NotUsed();
1151 $$ = new Vector<Module_Param*>();
1154 | TemplateItemList ',' ParameterValue
1164 $$ = new Module_Param_Assignment_List();
1167 | FieldValueList ',' FieldValue
1175 FieldName AssignmentChar ParameterValueOrNotUsedSymbol
1178 $$->set_id(new Module_Param_FieldName($1));
1187 | ASN1LowerIdentifier
1196 $$ = new Module_Param_Value_List();
1197 $1->set_id(new Module_Param_Index($$->get_size(),false));
1200 | ArrayItemList ',' ArrayItem
1203 $3->set_id(new Module_Param_Index($$->get_size(),false));
1209 ParameterValueOrNotUsedSymbol
1213 | PermutationKeyword '(' TemplateItemList ')'
1215 $$ = new Module_Param_Permutation_Template();
1216 $$->add_list_with_implicit_ids($3);
1224 $$ = new Module_Param_Indexed_List();
1227 | IndexItemList ',' IndexItem
1235 IndexItemIndex AssignmentChar ParameterValue
1238 $$->set_id(new Module_Param_Index((size_t)$1,true));
1243 '[' IntegerValue ']'
1245 if (!$2->is_native()) {
1246 config_process_error("bignum index."); // todo
1248 if ($2->is_negative()) {
1249 config_process_error("negative index."); // todo
1256 /*************** [LOGGING] section *********************************/
1259 LoggingKeyword LoggingParamList
1264 | LoggingParamList LoggingParamLines optSemiColon
1266 // Centralized duplication handling for `[LOGGING]'.
1267 if ($2.logparam.log_param_selection != LP_UNKNOWN && TTCN_Logger::add_parameter($2)) {
1268 switch ($2.logparam.log_param_selection) {
1270 check_duplicate_option("LOGGING", "FileMask", file_mask_set);
1272 case LP_CONSOLEMASK:
1273 check_duplicate_option("LOGGING", "ConsoleMask", console_mask_set);
1275 case LP_LOGFILESIZE:
1276 check_duplicate_option("LOGGING", "LogFileSize", log_file_size_set);
1278 case LP_LOGFILENUMBER:
1279 check_duplicate_option("LOGGING", "LogFileNumber", log_file_number_set);
1281 case LP_DISKFULLACTION:
1282 check_duplicate_option("LOGGING", "DiskFullAction", log_disk_full_action_set);
1285 check_duplicate_option("LOGGING", "LogFile", file_name_set);
1287 case LP_TIMESTAMPFORMAT:
1288 check_duplicate_option("LOGGING", "TimeStampFormat", timestamp_format_set);
1290 case LP_SOURCEINFOFORMAT:
1291 check_duplicate_option("LOGGING", "SourceInfoFormat", source_info_format_set);
1294 check_duplicate_option("LOGGING", "AppendFile", append_file_set);
1296 case LP_LOGEVENTTYPES:
1297 check_duplicate_option("LOGGING", "LogEventTypes", log_event_types_set);
1299 case LP_LOGENTITYNAME:
1300 check_duplicate_option("LOGGING", "LogEntityName", log_entity_name_set);
1302 case LP_MATCHINGHINTS:
1303 check_duplicate_option("LOGGING", "MatchingVerbosity", matching_verbosity_set);
1305 case LP_PLUGIN_SPECIFIC:
1306 // It would be an overkill to check for the infinite number of custom parameters...
1307 check_duplicate_option("LOGGING", "PluginSpecific", plugin_specific_set);
1319 $$.component.id_selector = COMPONENT_ID_ALL;
1320 $$.component.id_name = NULL;
1321 $$.plugin_id = NULL;
1324 | ComponentId '.' LoggingParam
1327 $$.plugin_id = NULL;
1330 | ComponentId '.' LoggerPluginId '.' LoggingParam
1336 | LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1338 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1339 component_id_t comp;
1340 comp.id_selector = COMPONENT_ID_ALL;
1341 comp.id_name = NULL;
1342 logging_plugin_t *plugin = $4;
1343 while (plugin != NULL) {
1344 // `identifier' and `filename' are reused. Various checks and
1345 // validations must be done in the logger itself (e.g. looking for
1346 // duplicate options).
1347 TTCN_Logger::register_plugin(comp, plugin->identifier, plugin->filename);
1348 logging_plugin_t *tmp = plugin;
1352 $$.logparam.log_param_selection = LP_UNKNOWN;
1354 | ComponentId '.' LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1356 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1357 logging_plugin_t *plugin = $6;
1358 while (plugin != NULL) {
1359 TTCN_Logger::register_plugin($1, plugin->identifier, plugin->filename);
1360 logging_plugin_t *tmp = plugin;
1364 // Component names shall be duplicated in `register_plugin()'.
1365 if ($1.id_selector == COMPONENT_ID_NAME)
1367 $$.logparam.log_param_selection = LP_UNKNOWN;
1376 | LoggerPluginList ',' LoggerPlugin
1386 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1387 $$->identifier = $1;
1388 $$->filename = NULL;
1391 | Identifier AssignmentChar StringValue
1393 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1394 $$->identifier = $1;
1401 '*' { $$ = mcopystr("*"); }
1402 | Identifier { $$ = $1; }
1406 FileMask AssignmentChar LoggingBitmask
1408 $$.log_param_selection = LP_FILEMASK;
1409 $$.logoptions_val = $3;
1411 | ConsoleMask AssignmentChar LoggingBitmask
1413 $$.log_param_selection = LP_CONSOLEMASK;
1414 $$.logoptions_val = $3;
1416 | LogFileSize AssignmentChar Number
1418 $$.log_param_selection = LP_LOGFILESIZE;
1419 $$.int_val = (int)$3->get_val();
1422 | EmergencyLogging AssignmentChar Number
1424 $$.log_param_selection = LP_EMERGENCY;
1425 $$.int_val = (int)$3->get_val();
1428 | EmergencyLoggingBehaviour AssignmentChar EmergencyLoggingBehaviourValue
1430 $$.log_param_selection = LP_EMERGENCYBEHAVIOR;
1431 $$.emergency_logging_behaviour_value = $3;
1433 | EmergencyLoggingMask AssignmentChar LoggingBitmask
1435 $$.log_param_selection = LP_EMERGENCYMASK;
1436 $$.logoptions_val = $3;
1438 | LogFileNumber AssignmentChar Number
1440 $$.log_param_selection = LP_LOGFILENUMBER;
1441 $$.int_val = (int)$3->get_val();
1444 | DiskFullAction AssignmentChar DiskFullActionValue
1446 $$.log_param_selection = LP_DISKFULLACTION;
1447 $$.disk_full_action_value = $3;
1449 | LogFile AssignmentChar LogFileName
1451 $$.log_param_selection = LP_LOGFILE;
1454 | TimestampFormat AssignmentChar TimestampValue
1456 $$.log_param_selection = LP_TIMESTAMPFORMAT;
1457 $$.timestamp_value = $3;
1459 | ConsoleTimestampFormat AssignmentChar TimestampValue
1461 $$.log_param_selection = LP_UNKNOWN;
1463 | SourceInfoFormat AssignmentChar SourceInfoSetting
1465 $$.log_param_selection = LP_SOURCEINFOFORMAT;
1466 $$.source_info_value = $3;
1468 | AppendFile AssignmentChar YesNoOrBoolean
1470 $$.log_param_selection = LP_APPENDFILE;
1473 | LogEventTypes AssignmentChar LogEventTypesValue
1475 $$.log_param_selection = LP_LOGEVENTTYPES;
1476 $$.log_event_types_value = $3;
1478 | LogEntityName AssignmentChar YesNoOrBoolean
1480 $$.log_param_selection = LP_LOGENTITYNAME;
1483 | MatchingHints AssignmentChar VerbosityValue
1485 $$.log_param_selection = LP_MATCHINGHINTS;
1486 $$.matching_verbosity_value = $3;
1488 | Identifier AssignmentChar StringValue
1490 $$.log_param_selection = LP_PLUGIN_SPECIFIC;
1497 Compact { $$ = TTCN_Logger::VERBOSITY_COMPACT; }
1498 | Detailed { $$ = TTCN_Logger::VERBOSITY_FULL; }
1501 DiskFullActionValue:
1502 Error { $$.type = TTCN_Logger::DISKFULL_ERROR; }
1503 | Stop { $$.type = TTCN_Logger::DISKFULL_STOP; }
1506 $$.type = TTCN_Logger::DISKFULL_RETRY;
1507 $$.retry_interval = 30; /* default retry interval */
1509 | Retry '(' Number ')'
1511 $$.type = TTCN_Logger::DISKFULL_RETRY;
1512 $$.retry_interval = (size_t)$3->get_val();
1515 | Delete { $$.type = TTCN_Logger::DISKFULL_DELETE; }
1519 StringValue { $$ = $1; }
1522 LoggingBitOrCollection:
1528 | LoggingBitCollection
1533 case TTCN_Logger::ACTION_UNQUALIFIED:
1534 $$.add_sev(TTCN_Logger::ACTION_UNQUALIFIED);
1536 case TTCN_Logger::DEFAULTOP_UNQUALIFIED:
1537 $$.add_sev(TTCN_Logger::DEFAULTOP_ACTIVATE);
1538 $$.add_sev(TTCN_Logger::DEFAULTOP_DEACTIVATE);
1539 $$.add_sev(TTCN_Logger::DEFAULTOP_EXIT);
1540 $$.add_sev(TTCN_Logger::DEFAULTOP_UNQUALIFIED);
1542 case TTCN_Logger::ERROR_UNQUALIFIED:
1543 $$.add_sev(TTCN_Logger::ERROR_UNQUALIFIED);
1545 case TTCN_Logger::EXECUTOR_UNQUALIFIED:
1546 $$.add_sev(TTCN_Logger::EXECUTOR_RUNTIME);
1547 $$.add_sev(TTCN_Logger::EXECUTOR_CONFIGDATA);
1548 $$.add_sev(TTCN_Logger::EXECUTOR_EXTCOMMAND);
1549 $$.add_sev(TTCN_Logger::EXECUTOR_COMPONENT);
1550 $$.add_sev(TTCN_Logger::EXECUTOR_LOGOPTIONS);
1551 $$.add_sev(TTCN_Logger::EXECUTOR_UNQUALIFIED);
1553 case TTCN_Logger::FUNCTION_UNQUALIFIED:
1554 $$.add_sev(TTCN_Logger::FUNCTION_RND);
1555 $$.add_sev(TTCN_Logger::FUNCTION_UNQUALIFIED);
1557 case TTCN_Logger::PARALLEL_UNQUALIFIED:
1558 $$.add_sev(TTCN_Logger::PARALLEL_PTC);
1559 $$.add_sev(TTCN_Logger::PARALLEL_PORTCONN);
1560 $$.add_sev(TTCN_Logger::PARALLEL_PORTMAP);
1561 $$.add_sev(TTCN_Logger::PARALLEL_UNQUALIFIED);
1563 case TTCN_Logger::PORTEVENT_UNQUALIFIED:
1564 $$.add_sev(TTCN_Logger::PORTEVENT_PQUEUE);
1565 $$.add_sev(TTCN_Logger::PORTEVENT_MQUEUE);
1566 $$.add_sev(TTCN_Logger::PORTEVENT_STATE);
1567 $$.add_sev(TTCN_Logger::PORTEVENT_PMIN);
1568 $$.add_sev(TTCN_Logger::PORTEVENT_PMOUT);
1569 $$.add_sev(TTCN_Logger::PORTEVENT_PCIN);
1570 $$.add_sev(TTCN_Logger::PORTEVENT_PCOUT);
1571 $$.add_sev(TTCN_Logger::PORTEVENT_MMRECV);
1572 $$.add_sev(TTCN_Logger::PORTEVENT_MMSEND);
1573 $$.add_sev(TTCN_Logger::PORTEVENT_MCRECV);
1574 $$.add_sev(TTCN_Logger::PORTEVENT_MCSEND);
1575 $$.add_sev(TTCN_Logger::PORTEVENT_DUALRECV);
1576 $$.add_sev(TTCN_Logger::PORTEVENT_DUALSEND);
1577 $$.add_sev(TTCN_Logger::PORTEVENT_UNQUALIFIED);
1579 case TTCN_Logger::TESTCASE_UNQUALIFIED:
1580 $$.add_sev(TTCN_Logger::TESTCASE_START);
1581 $$.add_sev(TTCN_Logger::TESTCASE_FINISH);
1582 $$.add_sev(TTCN_Logger::TESTCASE_UNQUALIFIED);
1584 case TTCN_Logger::TIMEROP_UNQUALIFIED:
1585 $$.add_sev(TTCN_Logger::TIMEROP_READ);
1586 $$.add_sev(TTCN_Logger::TIMEROP_START);
1587 $$.add_sev(TTCN_Logger::TIMEROP_GUARD);
1588 $$.add_sev(TTCN_Logger::TIMEROP_STOP);
1589 $$.add_sev(TTCN_Logger::TIMEROP_TIMEOUT);
1590 $$.add_sev(TTCN_Logger::TIMEROP_UNQUALIFIED);
1592 case TTCN_Logger::USER_UNQUALIFIED:
1593 $$.add_sev(TTCN_Logger::USER_UNQUALIFIED);
1595 case TTCN_Logger::STATISTICS_UNQUALIFIED:
1596 $$.add_sev(TTCN_Logger::STATISTICS_VERDICT);
1597 $$.add_sev(TTCN_Logger::STATISTICS_UNQUALIFIED);
1599 case TTCN_Logger::VERDICTOP_UNQUALIFIED:
1600 $$.add_sev(TTCN_Logger::VERDICTOP_GETVERDICT);
1601 $$.add_sev(TTCN_Logger::VERDICTOP_SETVERDICT);
1602 $$.add_sev(TTCN_Logger::VERDICTOP_FINAL);
1603 $$.add_sev(TTCN_Logger::VERDICTOP_UNQUALIFIED);
1605 case TTCN_Logger::WARNING_UNQUALIFIED:
1606 $$.add_sev(TTCN_Logger::WARNING_UNQUALIFIED);
1608 case TTCN_Logger::MATCHING_UNQUALIFIED:
1609 $$.add_sev(TTCN_Logger::MATCHING_DONE);
1610 $$.add_sev(TTCN_Logger::MATCHING_TIMEOUT);
1611 $$.add_sev(TTCN_Logger::MATCHING_PCSUCCESS);
1612 $$.add_sev(TTCN_Logger::MATCHING_PCUNSUCC);
1613 $$.add_sev(TTCN_Logger::MATCHING_PMSUCCESS);
1614 $$.add_sev(TTCN_Logger::MATCHING_PMUNSUCC);
1615 $$.add_sev(TTCN_Logger::MATCHING_MCSUCCESS);
1616 $$.add_sev(TTCN_Logger::MATCHING_MCUNSUCC);
1617 $$.add_sev(TTCN_Logger::MATCHING_MMSUCCESS);
1618 $$.add_sev(TTCN_Logger::MATCHING_MMUNSUCC);
1619 $$.add_sev(TTCN_Logger::MATCHING_PROBLEM);
1620 $$.add_sev(TTCN_Logger::MATCHING_UNQUALIFIED);
1622 case TTCN_Logger::DEBUG_UNQUALIFIED:
1623 $$.add_sev(TTCN_Logger::DEBUG_ENCDEC);
1624 $$.add_sev(TTCN_Logger::DEBUG_TESTPORT);
1625 $$.add_sev(TTCN_Logger::DEBUG_UNQUALIFIED);
1627 case TTCN_Logger::LOG_ALL_IMPORTANT:
1628 $$ = Logging_Bits::log_all;
1631 /* The lexer sent something the parser doesn't understand!
1632 Parser needs to be updated.
1634 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
1635 "Internal error: unknown logbit from lexer.");
1642 LoggingBitOrCollection
1646 | LoggingBitmask '|' LoggingBitOrCollection
1654 SourceInfoValue { $$ = $1; }
1657 $$ = $1 ? TTCN_Logger::SINFO_SINGLE : TTCN_Logger::SINFO_NONE;
1663 | BooleanValue { $$ = $1; }
1667 YesNoOrBoolean { $$ = $1 ? TTCN_Logger::LOGEVENTTYPES_YES :
1668 TTCN_Logger::LOGEVENTTYPES_NO; }
1669 | SubCategories { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1670 | Detailed { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1673 /*********************** [PROFILER] ********************************/
1676 ProfilerKeyword ProfilerSettings
1681 | ProfilerSettings ProfilerSetting optSemiColon
1685 DisableProfilerSetting
1686 | DisableCoverageSetting
1687 | DatabaseFileSetting
1688 | AggregateDataSetting
1689 | StatisticsFileSetting
1690 | DisableStatisticsSetting
1693 DisableProfilerSetting:
1694 DisableProfilerKeyword AssignmentChar BooleanValue {
1695 ttcn3_prof.set_disable_profiler($3);
1699 DisableCoverageSetting:
1700 DisableCoverageKeyword AssignmentChar BooleanValue {
1701 ttcn3_prof.set_disable_coverage($3);
1705 DatabaseFileSetting:
1706 DatabaseFileKeyword AssignmentChar StringValue {
1707 ttcn3_prof.set_database_filename($3);
1711 AggregateDataSetting:
1712 AggregateDataKeyword AssignmentChar BooleanValue {
1713 ttcn3_prof.set_aggregate_data($3);
1717 StatisticsFileSetting:
1718 StatisticsFileKeyword AssignmentChar StringValue {
1719 ttcn3_prof.set_stats_filename($3);
1723 DisableStatisticsSetting:
1724 DisableStatisticsKeyword AssignmentChar BooleanValue {
1725 ttcn3_prof.set_disable_stats($3);
1729 /**************** [TESTPORT_PARAMETERS] ****************************/
1731 TestportParametersSection:
1732 TestportParametersKeyword TestportParameterList
1735 TestportParameterList:
1737 | TestportParameterList TestportParameter optSemiColon
1741 ComponentId '.' TestportName '.' TestportParameterName AssignmentChar
1742 TestportParameterValue
1744 PORT::add_parameter($1, $3, $5, $7);
1745 if ($1.id_selector == COMPONENT_ID_NAME) Free($1.id_name);
1755 $$.id_selector = COMPONENT_ID_NAME;
1760 $$.id_selector = COMPONENT_ID_NAME;
1761 $$.id_name = $1.chars_ptr;
1765 $$.id_selector = COMPONENT_ID_COMPREF;
1766 $$.id_compref = (component)$1->get_val();
1771 $$.id_selector = COMPONENT_ID_COMPREF;
1772 $$.id_compref = MTC_COMPREF;
1776 $$.id_selector = COMPONENT_ID_ALL;
1781 $$.id_selector = COMPONENT_ID_SYSTEM;
1787 Identifier { $$ = $1; }
1788 | Identifier ArrayRef
1790 $$ = mputstr($1, $2);
1793 | '*' { $$ = NULL; }
1797 '[' IntegerValue ']'
1799 char *s = $2->as_string();
1801 $$ = mputc ($$, '[');
1802 $$ = mputstr($$, s);
1803 $$ = mputc ($$, ']');
1807 | ArrayRef '[' IntegerValue ']'
1809 char *s = $3->as_string();
1810 $$ = mputc ($1, '[');
1811 $$ = mputstr($$, s);
1812 $$ = mputc ($$, ']');
1818 TestportParameterName:
1819 Identifier { $$ = $1; }
1822 TestportParameterValue:
1823 StringValue { $$ = $1; }
1826 /****************** [EXECUTE] section *************/
1829 ExecuteKeyword ExecuteList
1831 if (!TTCN_Runtime::is_single()) config_process_error("Internal error: "
1832 "the Main Controller must not send section [EXECUTE] of the "
1833 "configuration file.");
1839 | ExecuteList ExecuteItem optSemiColon
1841 if (TTCN_Runtime::is_single()) {
1842 execute_list = (execute_list_item *)Realloc(
1843 execute_list, (execute_list_len + 1) *
1844 sizeof(*execute_list));
1845 execute_list[execute_list_len++] = $2;
1847 Free($2.module_name);
1848 Free($2.testcase_name);
1856 $$.module_name = $1;
1857 $$.testcase_name = NULL;
1859 | Identifier '.' ControlKeyword
1861 $$.module_name = $1;
1862 $$.testcase_name = NULL;
1864 | Identifier '.' Identifier
1866 $$.module_name = $1;
1867 $$.testcase_name = $3;
1869 | Identifier '.' '*'
1871 $$.module_name = $1;
1872 $$.testcase_name = mcopystr("*");
1876 /****************** [EXTERNAL_COMMANDS] section **********************/
1878 ExternalCommandsSection:
1879 ExternalCommandsKeyword ExternalCommandList
1882 ExternalCommandList:
1884 | ExternalCommandList ExternalCommand optSemiColon
1888 BeginControlPart AssignmentChar Command
1890 check_duplicate_option("EXTERNAL_COMMANDS", "BeginControlPart",
1891 begin_controlpart_command_set);
1893 TTCN_Runtime::set_begin_controlpart_command($3);
1897 | EndControlPart AssignmentChar Command
1899 check_duplicate_option("EXTERNAL_COMMANDS", "EndControlPart",
1900 end_controlpart_command_set);
1902 TTCN_Runtime::set_end_controlpart_command($3);
1906 | BeginTestCase AssignmentChar Command
1908 check_duplicate_option("EXTERNAL_COMMANDS", "BeginTestCase",
1909 begin_testcase_command_set);
1911 TTCN_Runtime::set_begin_testcase_command($3);
1915 | EndTestCase AssignmentChar Command
1917 check_duplicate_option("EXTERNAL_COMMANDS", "EndTestCase",
1918 end_testcase_command_set);
1920 TTCN_Runtime::set_end_testcase_command($3);
1927 StringValue { $$ = $1; }
1930 /***************** [GROUPS] section *******************/
1933 GroupsKeyword GroupList
1935 check_ignored_section("GROUPS");
1941 | GroupList Group optSemiColon
1945 GroupName AssignmentChar GroupMembers
1949 Identifier { Free($1); }
1959 | seqGroupMember ',' HostName
1964 | Identifier { Free($1); }
1967 /******************** [COMPONENTS] section *******************/
1969 ComponentsKeyword ComponentList
1971 check_ignored_section("COMPONENTS");
1977 | ComponentList ComponentItem optSemiColon
1981 ComponentName AssignmentChar ComponentLocation
1985 Identifier { Free($1); }
1990 Identifier { Free($1); }
1994 /****************** [MAIN_CONTROLLER] section *********************/
1995 MainControllerSection:
1996 MainControllerKeyword MCParameterList
1998 check_ignored_section("MAIN_CONTROLLER");
2004 | MCParameterList MCParameter optSemiColon
2008 LocalAddress AssignmentChar HostName { }
2009 | TCPPort AssignmentChar IntegerValue { delete $3; }
2010 | KillTimer AssignmentChar KillTimerValue { }
2011 | NumHCs AssignmentChar IntegerValue { delete $3; }
2012 | UnixSocketEnabled AssignmentChar YesToken {}
2013 | UnixSocketEnabled AssignmentChar NoToken {}
2014 | UnixSocketEnabled AssignmentChar HostName {}
2019 | IntegerValue { delete $1; }
2022 /****************** [INCLUDE] section *********************/
2024 IncludeKeyword IncludeFiles
2026 if(!TTCN_Runtime::is_single())
2027 config_process_error
2028 ("Internal error: the Main Controller must not send section [INCLUDE]"
2029 " of the configuration file.");
2035 | IncludeFiles IncludeFile
2039 Cstring { Free($1.chars_ptr); }
2042 /****************** [DEFINE] section *********************/
2046 if(!TTCN_Runtime::is_single())
2047 config_process_error
2048 ("Internal error: the Main Controller must not send section [DEFINE]"
2049 " of the configuration file.");
2053 /*********************************************************/
2058 $$ = Module_Param::OT_ASSIGN;
2063 $$ = Module_Param::OT_CONCAT;
2074 static void reset_configuration_options()
2076 /* Section [MODULE_PARAMETERS */
2077 /** \todo reset module parameters to their default values */
2078 /* Section [LOGGING] */
2079 TTCN_Logger::close_file();
2080 TTCN_Logger::reset_configuration();
2081 file_name_set = FALSE;
2082 file_mask_set = TRUE;
2083 console_mask_set = TRUE;
2084 timestamp_format_set = FALSE;
2085 source_info_format_set = FALSE;
2086 append_file_set = FALSE;
2087 log_event_types_set = FALSE;
2088 log_entity_name_set = FALSE;
2089 /* Section [TESTPORT_PARAMETERS] */
2090 PORT::clear_parameters();
2091 /* Section [EXTERNAL_COMMANDS] */
2093 TTCN_Runtime::clear_external_commands();
2095 begin_controlpart_command_set = FALSE;
2096 end_controlpart_command_set = FALSE;
2097 begin_testcase_command_set = FALSE;
2098 end_testcase_command_set = FALSE;
2101 Module_Param* process_config_string2ttcn(const char* mp_str, bool is_component)
2103 if (parsed_module_param!=NULL || parsing_error_messages!=NULL) TTCN_error("Internal error: previously parsed ttcn string was not cleared.");
2104 // add the hidden keyword
2105 std::string mp_string = (is_component) ? std::string("$#&&&(#TTCNSTRINGPARSING_COMPONENT$#&&^#% ") + mp_str
2106 : std::string("$#&&&(#TTCNSTRINGPARSING$#&&^#% ") + mp_str;
2107 struct yy_buffer_state *flex_buffer = config_process__scan_bytes(mp_string.c_str(), (int)mp_string.size());
2108 if (flex_buffer == NULL) TTCN_error("Internal error: flex buffer creation failed.");
2109 reset_config_process_lex(NULL);
2112 Ttcn_String_Parsing ttcn_string_parsing;
2113 if (config_process_parse()) error_flag = TRUE;
2114 } catch (const TC_Error& TC_error) {
2115 if (parsed_module_param!=NULL) { delete parsed_module_param; parsed_module_param = NULL; }
2118 config_process_close();
2119 config_process_lex_destroy();
2121 if (error_flag || parsing_error_messages!=NULL) {
2122 delete parsed_module_param;
2123 parsed_module_param = NULL;
2124 char* pem = parsing_error_messages!=NULL ? parsing_error_messages : mcopystr("Unknown parsing error");
2125 parsing_error_messages = NULL;
2126 TTCN_error_begin("%s", pem);
2131 if (parsed_module_param==NULL) TTCN_error("Internal error: could not parse ttcn string.");
2132 Module_Param* ret_val = parsed_module_param;
2133 parsed_module_param = NULL;
2138 boolean process_config_string(const char *config_string, int string_len)
2142 struct yy_buffer_state *flex_buffer =
2143 config_process__scan_bytes(config_string, string_len);
2144 if (flex_buffer == NULL) {
2145 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
2146 "Internal error: flex buffer creation failed.");
2151 reset_configuration_options();
2152 reset_config_process_lex(NULL);
2153 if (config_process_parse()) error_flag = TRUE;
2155 } catch (const TC_Error& TC_error) {
2159 config_process_close();
2160 config_process_lex_destroy();
2166 boolean process_config_file(const char *file_name)
2169 string_chain_t *filenames=NULL;
2171 reset_configuration_options();
2173 if(preproc_parse_file(file_name, &filenames, &config_defines))
2177 char *fn=string_chain_cut(&filenames);
2178 reset_config_process_lex(fn);
2179 /* The lexer can modify config_process_in
2180 * when it's input buffer is changed */
2181 config_process_in = fopen(fn, "r");
2182 FILE* tmp_cfg = config_process_in;
2183 if (config_process_in != NULL) {
2185 if(config_process_parse()) error_flag=TRUE;
2186 } catch (const TC_Error& TC_error) {
2190 config_process_close();
2191 config_process_lex_destroy();
2193 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2194 TTCN_Logger::log_event("Cannot open configuration file: %s", fn);
2195 TTCN_Logger::OS_error();
2196 TTCN_Logger::end_event();
2199 /* During parsing flex or libc may use some system calls (e.g. ioctl)
2200 * that fail with an error status. Such error codes shall be ignored in
2201 * future error messages. */
2207 string_map_free(config_defines);
2208 config_defines = NULL;
2210 ttcn3_prof.init_data_file();
2215 void config_process_error_f(const char *error_str, ...)
2217 if (Ttcn_String_Parsing::happening()) {
2219 va_start(p_var, error_str);
2220 char* error_msg_str = mprintf_va_list(error_str, p_var);
2222 if (parsing_error_messages!=NULL) parsing_error_messages = mputc(parsing_error_messages, '\n');
2223 parsing_error_messages = mputprintf(parsing_error_messages,
2224 "Parse error in line %d, at or before token `%s': %s", config_process_get_current_line(), config_process_text, error_msg_str);
2225 Free(error_msg_str);
2229 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2230 if (!get_cfg_process_current_file().empty()) {
2231 TTCN_Logger::log_event("Parse error in configuration file `%s': in line %d, "
2232 "at or before token `%s': ",
2233 get_cfg_process_current_file().c_str(), config_process_get_current_line(),
2237 TTCN_Logger::log_event("Parse error while reading configuration "
2238 "information: in line %d, at or before token `%s': ",
2239 config_process_get_current_line(), config_process_text);
2242 va_start(pvar, error_str);
2243 TTCN_Logger::log_event_va_list(error_str, pvar);
2245 TTCN_Logger::end_event();
2249 void config_process_error(const char *error_str)
2251 config_process_error_f("%s", error_str);
2254 void config_preproc_error(const char *error_str, ...)
2256 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2257 TTCN_Logger::log_event("Parse error while pre-processing configuration"
2258 " file `%s': in line %d: ",
2259 get_cfg_preproc_current_file().c_str(),
2260 config_preproc_yylineno);
2262 va_start(pvar, error_str);
2263 TTCN_Logger::log_event_va_list(error_str, pvar);
2265 TTCN_Logger::end_event();
2269 void path_error(const char *fmt, ...)
2272 fprintf(stderr, "File error: ");
2273 va_start(parameters, fmt);
2274 vfprintf(stderr, fmt, parameters);
2276 fprintf(stderr, "\n");
2279 static void check_duplicate_option(const char *section_name,
2280 const char *option_name, boolean& option_flag)
2283 TTCN_warning("Option `%s' was given more than once in section [%s] of the "
2284 "configuration file.", option_name, section_name);
2285 } else option_flag = TRUE;
2288 static void check_ignored_section(const char *section_name)
2290 if (TTCN_Runtime::is_single()) TTCN_warning("Section [%s] of "
2291 "configuration file is ignored in single mode.", section_name);
2292 else config_process_error_f("Internal error: the Main Controller must not "
2293 "send section [%s] of the configuration file.", section_name);
2296 static void set_param(Module_Param& param)
2299 Module_List::set_param(param);
2301 catch (const TC_Error& TC_error) {
2306 unsigned char char_to_hexdigit(char c)
2308 if (c >= '0' && c <= '9') return c - '0';
2309 else if (c >= 'A' && c <= 'F') return c - 'A' + 10;
2310 else if (c >= 'a' && c <= 'f') return c - 'a' + 10;
2312 config_process_error_f("char_to_hexdigit(): invalid argument: %c", c);
2313 return 0; // to avoid warning