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 #define YYERROR_VERBOSE
42 #include "config_process.lex.hh"
44 extern void reset_config_process_lex(const char* fname);
45 extern void config_process_close();
46 extern int config_process_get_current_line();
47 extern std::string get_cfg_process_current_file();
49 static int config_process_parse();
50 static void check_duplicate_option(const char *section_name,
51 const char *option_name, boolean& option_flag);
52 static void check_ignored_section(const char *section_name);
53 static void set_param(Module_Param& module_param);
54 static unsigned char char_to_hexdigit(char c);
56 static boolean error_flag = FALSE;
58 static Module_Param* parsed_module_param = NULL;
59 static char * parsing_error_messages = NULL;
62 For detecting duplicate entries in the config file. Start out as FALSE,
63 set to TRUE bycheck_duplicate_option().
64 Exception: duplication of parameters that can be component specific is checked
65 by set_xxx(), these start out as TRUE.
67 static boolean file_name_set = FALSE,
69 console_mask_set = TRUE,
70 timestamp_format_set = FALSE,
71 source_info_format_set = FALSE,
72 append_file_set = FALSE,
73 log_event_types_set = FALSE,
74 log_entity_name_set = FALSE,
75 begin_controlpart_command_set = FALSE,
76 end_controlpart_command_set = FALSE,
77 begin_testcase_command_set = FALSE,
78 end_testcase_command_set = FALSE,
79 log_file_size_set = TRUE,
80 log_file_number_set = TRUE,
81 log_disk_full_action_set = TRUE,
82 matching_verbosity_set = FALSE,
83 logger_plugins_set = FALSE,
84 plugin_specific_set = FALSE;
86 int execute_list_len = 0;
87 execute_list_item *execute_list = NULL;
89 string_map_t *config_defines;
97 unsigned int uint_val;
100 param_objid_t objid_val;
101 verdicttype verdict_val;
102 param_bitstring_t bitstring_val;
103 param_hexstring_t hexstring_val;
104 param_charstring_t charstring_val;
105 param_octetstring_t octetstring_val;
106 universal_char universal_char_val;
107 param_universal_charstring_t universal_charstring_val;
108 Module_Param::operation_type_t param_optype_val;
109 Vector<Module_Param*>* module_param_list;
110 Module_Param* module_param_val;
111 Module_Param_Length_Restriction* module_param_length_restriction;
112 Vector<char*>* name_vector;
113 component_id_t comp_id;
114 execute_list_item execute_item_val;
115 TTCN_Logger::emergency_logging_behaviour_t emergency_logging_behaviour_value;
116 TTCN_Logger::timestamp_format_t timestamp_value;
117 TTCN_Logger::source_info_format_t source_info_value;
118 TTCN_Logger::log_event_types_t log_event_types_value;
119 TTCN_Logger::disk_full_action_t disk_full_action_value;
120 TTCN_Logger::matching_verbosity_t matching_verbosity_value;
121 TTCN_Logger::Severity logseverity_val;
122 Logging_Bits logoptions_val;
124 logging_plugin_t *logging_plugins;
125 logging_param_t logging_params;
126 logging_setting_t logging_param_line;
129 %token ModuleParametersKeyword
130 %token LoggingKeyword
131 %token TestportParametersKeyword
132 %token ExecuteKeyword
133 %token ExternalCommandsKeyword
135 %token ComponentsKeyword
136 %token MainControllerKeyword
137 %token IncludeKeyword
142 %token ObjIdKeyword "objid"
143 %token CharKeyword "char"
144 %token ControlKeyword "control"
145 %token MTCKeyword "mtc"
146 %token SystemKeyword "system"
147 %token NULLKeyword "NULL"
148 %token nullKeyword "null"
149 %token OmitKeyword "omit"
150 %token ComplementKeyword "complement"
152 %token SupersetKeyword "superset"
153 %token SubsetKeyword "subset"
154 %token PatternKeyword "pattern"
155 %token PermutationKeyword "permutation"
156 %token LengthKeyword "length"
157 %token IfpresentKeyword "ifpresent"
158 %token InfinityKeyword "infinity"
159 %token AssignmentChar ":= or ="
160 %token ConcatChar "&="
161 %token LogFile "LogFile or FileName"
162 %token EmergencyLogging
163 %token EmergencyLoggingBehaviour
164 %token EmergencyLoggingMask
169 %token TimestampFormat
170 %token ConsoleTimestampFormat
171 %token SourceInfoFormat "LogSourceInfo or SourceInfoFormat"
175 %token BeginControlPart
176 %token EndControlPart
179 %token <str_val> Identifier
180 %token <str_val> ASN1LowerIdentifier "ASN.1 identifier beginning with a lowercase letter"
181 %token <int_val> Number
182 %token <float_val> Float
183 %token <bool_val> BooleanValue "true or false"
184 %token <verdict_val> VerdictValue
185 %token <bitstring_val> Bstring "bit string value"
186 %token <hexstring_val> Hstring "hex string value"
187 %token <octetstring_val> Ostring "octet string value"
188 %token <str_val> BstringMatch "bit string template"
189 %token <str_val> HstringMatch "hex string template"
190 %token <str_val> OstringMatch "octet string template"
191 %token <charstring_val> Cstring "charstring value"
192 %token DNSName "hostname"
194 %token <logseverity_val> LoggingBit
195 /* a collection of bits */
196 %token <logseverity_val> LoggingBitCollection
198 %token <emergency_logging_behaviour_value> EmergencyLoggingBehaviourValue "BufferAll or BufferMasked"
199 %token <timestamp_value> TimestampValue "Time, Datetime or Seconds"
200 %token <source_info_value> SourceInfoValue "None, Single or Stack"
201 %token <bool_val> YesNo "yes or no"
206 %token UnixSocketEnabled
207 %token YesToken "yes"
211 %token DiskFullAction
218 %token TtcnStringParsingKeyword
220 %type <int_val> IntegerValue
221 %type <float_val> FloatValue
222 %type <objid_val> ObjIdValue ObjIdComponentList
223 %type <int_val> ObjIdComponent NumberForm NameAndNumberForm
225 %type <universal_charstring_val> UniversalCharstringValue
226 seqUniversalCharstringFragment UniversalCharstringFragment
227 %type <universal_char_val> Quadruple
228 %type <str_val> EnumeratedValue
230 %type <str_val> LoggerPluginId
231 %type <logging_plugins> LoggerPlugin LoggerPluginList
232 %type <logging_params> LoggingParam
233 %type <logging_param_line> LoggingParamLines
234 %type <str_val> LogFileName StringValue
235 /* a collection of bits */
236 %type <logoptions_val> LoggingBitmask
237 %type <logoptions_val> LoggingBitOrCollection
238 %type <source_info_value> SourceInfoSetting
239 %type <bool_val> YesNoOrBoolean
240 %type <log_event_types_value> LogEventTypesValue
241 %type <disk_full_action_value> DiskFullActionValue
242 %type <str_val> Command
243 %type <matching_verbosity_value> VerbosityValue
244 %type <comp_id> ComponentId
245 %type <str_val> TestportName ArrayRef TestportParameterName
246 TestportParameterValue
248 %type <execute_item_val> ExecuteItem
250 %type <bitstring_val> BitstringValue
251 %type <hexstring_val> HexstringValue
252 %type <octetstring_val> OctetstringValue
254 %type <name_vector> ParameterName ParameterNameSegment
255 %type <param_optype_val> ParamOpType
256 %type <str_val> FieldName
257 %type <module_param_val> ParameterValue SimpleParameterValue ParameterValueOrNotUsedSymbol
258 FieldValue ArrayItem IndexItem IndexItemList FieldValueList ArrayItemList CompoundValue IntegerRange FloatRange StringRange
259 %type <module_param_list> TemplateItemList
260 %type <module_param_length_restriction> LengthMatch
261 %type <str_val> PatternChunk PatternChunkList
262 %type <int_native> IndexItemIndex LengthBound
264 %destructor { Free($$); }
274 TestportParameterName
275 TestportParameterValue
282 %destructor { Free($$.components_ptr); }
286 %destructor { Free($$.bits_ptr); }
290 %destructor { Free($$.nibbles_ptr); }
294 %destructor { Free($$.octets_ptr); }
298 %destructor { Free($$.chars_ptr); }
301 %destructor { Free($$.uchars_ptr); Free($$.quad_positions); }
302 seqUniversalCharstringFragment
303 UniversalCharstringFragment
304 UniversalCharstringValue
306 %destructor { if ($$.id_selector == COMPONENT_ID_NAME) Free($$.id_name); }
309 %destructor { Free($$.module_name); Free($$.testcase_name); }
312 %destructor { delete $$; }
320 ParameterValueOrNotUsedSymbol
332 %destructor { delete $$; }
335 %destructor { for(size_t i=0; i<$$->size(); i++) { delete $$->at(i); } delete $$; }
338 %destructor { for(size_t i=0; i<$$->size(); i++) { Free($$->at(i)); } delete $$; }
349 2 conflicts in two distinct states.
350 When seeing a '*' token after an integer or float value in section
351 [MODULE_PARAMETERS] parser cannot decide whether the token is a multiplication
352 operator (shift) or it refers to all modules in the next module parameter
360 if (Ttcn_String_Parsing::happening()) {
361 config_process_error("Config file cannot be parsed as ttcn string");
364 | TtcnStringParsingKeyword ParameterValue
366 parsed_module_param = $2;
376 ModuleParametersSection
378 | TestportParametersSection
380 | ExternalCommandsSection
383 | MainControllerSection
388 ModuleParametersSection:
389 ModuleParametersKeyword ModuleParameters
394 | ModuleParameters ModuleParameter optSemiColon
398 ParameterName ParamOpType ParameterValue
400 Module_Param* mp = $3;
401 mp->set_id(new Module_Param_Name(*$1));
402 mp->set_operation_type($2);
410 ParameterNameSegment { $$ = $1; }
411 | '*' '.' ParameterNameSegment { $$ = $3; }
414 ParameterNameSegment:
415 ParameterNameSegment '.' Identifier
420 | ParameterNameSegment '[' Number ']'
423 $$->push_back($3->as_string());
428 $$ = new Vector<char*>();
438 | SimpleParameterValue LengthMatch
441 $$->set_length_restriction($2);
443 | SimpleParameterValue IfpresentKeyword
448 | SimpleParameterValue LengthMatch IfpresentKeyword
451 $$->set_length_restriction($2);
457 LengthKeyword '(' LengthBound ')'
459 $$ = new Module_Param_Length_Restriction();
460 $$->set_single((size_t)$3);
462 | LengthKeyword '(' LengthBound DotDot LengthBound ')'
465 config_process_error("invalid length restriction: lower bound > upper bound");
467 $$ = new Module_Param_Length_Restriction();
468 $$->set_min((size_t)$3);
469 $$->set_max((size_t)$5);
471 | LengthKeyword '(' LengthBound DotDot InfinityKeyword ')'
473 $$ = new Module_Param_Length_Restriction();
474 $$->set_min((size_t)$3);
481 if (!$1->is_native()) {
482 config_process_error("bignum length restriction bound.");
484 } else if ($1->is_negative()) {
485 config_process_error("negative length restriction bound.");
494 SimpleParameterValue:
497 $$ = new Module_Param_Integer($1);
501 $$ = new Module_Param_Float($1);
505 $$ = new Module_Param_Boolean($1);
509 $$ = new Module_Param_Objid($1.n_components, $1.components_ptr);
513 $$ = new Module_Param_Verdict($1);
517 $$ = new Module_Param_Bitstring($1.n_bits, $1.bits_ptr);
521 $$ = new Module_Param_Hexstring($1.n_nibbles, $1.nibbles_ptr);
525 $$ = new Module_Param_Octetstring($1.n_octets, $1.octets_ptr);
529 $$ = new Module_Param_Charstring($1.n_chars, $1.chars_ptr);
531 | UniversalCharstringValue
533 $$ = new Module_Param_Universal_Charstring($1.n_uchars, $1.uchars_ptr, $1.n_quads, $1.quad_positions);
537 $$ = new Module_Param_Enumerated($1);
541 $$ = new Module_Param_Omit();
545 $$ = new Module_Param_Asn_Null();
549 $$ = new Module_Param_Ttcn_Null();
553 $$ = new Module_Param_Ttcn_mtc();
557 $$ = new Module_Param_Ttcn_system();
561 $$ = new Module_Param_Any();
565 $$ = new Module_Param_AnyOrNone();
579 | PatternKeyword PatternChunkList
581 $$ = new Module_Param_Pattern($2);
586 int n_chars = (int)mstrlen($1);
587 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
588 for (int i=0; i<n_chars; i++) {
604 config_process_error_f("Invalid char (%c) in bitstring template", $1[i]);
608 $$ = new Module_Param_Bitstring_Template(n_chars, chars_ptr);
612 int n_chars = (int)mstrlen($1);
613 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
614 for (int i=0; i<n_chars; i++) {
615 if ($1[i]=='?') chars_ptr[i] = 16;
616 else if ($1[i]=='*') chars_ptr[i] = 17;
617 else chars_ptr[i] = char_to_hexdigit($1[i]);
620 $$ = new Module_Param_Hexstring_Template(n_chars, chars_ptr);
624 Vector<unsigned short> octet_vec;
625 int str_len = (int)mstrlen($1);
626 for (int i=0; i<str_len; i++) {
628 if ($1[i]=='?') num = 256;
629 else if ($1[i]=='*') num = 257;
632 num = 16 * char_to_hexdigit($1[i]);
634 if (i>=str_len) config_process_error("Unexpected end of octetstring pattern");
636 num += char_to_hexdigit($1[i]);
638 octet_vec.push_back(num);
641 int n_chars = (int)octet_vec.size();
642 unsigned short* chars_ptr = (unsigned short*)Malloc(n_chars*sizeof(unsigned short));
643 for (int i=0; i<n_chars; i++) chars_ptr[i] = octet_vec[i];
644 $$ = new Module_Param_Octetstring_Template(n_chars, chars_ptr);
657 | PatternChunkList '&' PatternChunk
660 $$ = mputstr($$, $3);
668 $$ = mcopystr($1.chars_ptr);
673 $$ = mprintf("\\q{%d,%d,%d,%d}", $1.uc_group, $1.uc_plane, $1.uc_row, $1.uc_cell);
678 '(' '-' InfinityKeyword DotDot IntegerValue ')'
680 $$ = new Module_Param_IntRange(NULL, $5);
682 | '(' IntegerValue DotDot IntegerValue ')'
684 $$ = new Module_Param_IntRange($2, $4);
686 | '(' IntegerValue DotDot InfinityKeyword ')'
688 $$ = new Module_Param_IntRange($2, NULL);
693 '(' '-' InfinityKeyword DotDot FloatValue ')'
695 $$ = new Module_Param_FloatRange(0.0, false, $5, true);
697 | '(' FloatValue DotDot FloatValue ')'
699 $$ = new Module_Param_FloatRange($2, true, $4, true);
701 | '(' FloatValue DotDot InfinityKeyword ')'
703 $$ = new Module_Param_FloatRange($2, true, 0.0, false);
708 '(' UniversalCharstringFragment DotDot UniversalCharstringFragment ')'
710 universal_char lower; lower.uc_group=lower.uc_plane=lower.uc_row=lower.uc_cell=0;
711 universal_char upper; upper.uc_group=upper.uc_plane=upper.uc_row=upper.uc_cell=0;
712 if ($2.n_uchars!=1) {
713 config_process_error("Lower bound of char range must be 1 character only");
714 } else if ($4.n_uchars!=1) {
715 config_process_error("Upper bound of char range must be 1 character only");
717 lower = *($2.uchars_ptr);
718 upper = *($4.uchars_ptr);
720 config_process_error("Lower bound is larger than upper bound in the char range");
726 Free($2.quad_positions);
727 Free($4.quad_positions);
728 $$ = new Module_Param_StringRange(lower, upper);
734 | '(' IntegerValue ')' { $$ = $2; }
735 | '+' IntegerValue %prec UnarySign { $$ = $2; }
736 | '-' IntegerValue %prec UnarySign
740 $$ = new int_val_t((-op1).get_val());
743 | IntegerValue '+' IntegerValue
748 $$ = new int_val_t((op1 + op2).get_val());
752 | IntegerValue '-' IntegerValue
757 $$ = new int_val_t((op1 - op2).get_val());
761 | IntegerValue '*' IntegerValue
766 $$ = new int_val_t((op1 * op2).get_val());
770 | IntegerValue '/' IntegerValue
773 config_process_error("Integer division by zero.");
774 $$ = new int_val_t((RInt)0);
781 $$ = new int_val_t((op1 / op2).get_val());
790 | '(' FloatValue ')' { $$ = $2; }
791 | '+' FloatValue %prec UnarySign { $$ = $2; }
792 | '-' FloatValue %prec UnarySign { $$ = -$2; }
793 | FloatValue '+' FloatValue { $$ = $1 + $3; }
794 | FloatValue '-' FloatValue { $$ = $1 - $3; }
795 | FloatValue '*' FloatValue { $$ = $1 * $3; }
796 | FloatValue '/' FloatValue
799 config_process_error("Floating point division by zero.");
806 ObjIdKeyword '{' ObjIdComponentList '}' { $$ = $3; }
813 $$.components_ptr = (int *)Malloc(sizeof(int));
814 $$.components_ptr[0] = $1->get_val();
817 | ObjIdComponentList ObjIdComponent
819 $$.n_components = $1.n_components + 1;
820 $$.components_ptr = (int *)Realloc($1.components_ptr,
821 $$.n_components * sizeof(int));
822 $$.components_ptr[$$.n_components - 1] = $2->get_val();
828 NumberForm { $$ = $1; }
829 | NameAndNumberForm { $$ = $1; }
837 Identifier '(' Number ')'
849 | BitstringValue ConcatOp Bstring
851 $$.n_bits = $1.n_bits + $3.n_bits;
852 int n_bytes_1 = ($1.n_bits+7)/8;
853 int n_bytes_3 = ($3.n_bits+7)/8;
854 int n_bytes = ($$.n_bits+7)/8;
855 $$.bits_ptr = (unsigned char *)Realloc($1.bits_ptr, n_bytes);
856 int n_rem_1 = $1.n_bits % 8; // remainder bits
858 for (int i=n_bytes_1; i<n_bytes; i++) {
859 unsigned char S3_byte = $3.bits_ptr[i-n_bytes_1];
860 $$.bits_ptr[i-1] |= S3_byte << n_rem_1;
861 $$.bits_ptr[i] = S3_byte >> (8-n_rem_1);
863 if (n_bytes_1+n_bytes_3>n_bytes)
864 $$.bits_ptr[n_bytes-1] |= $3.bits_ptr[n_bytes_3-1] << n_rem_1;
866 memcpy($$.bits_ptr + n_bytes_1, $3.bits_ptr, n_bytes_3);
877 | HexstringValue ConcatOp Hstring
879 $$.n_nibbles = $1.n_nibbles + $3.n_nibbles;
880 int n_bytes = ($$.n_nibbles + 1) / 2;
881 $$.nibbles_ptr = (unsigned char *)Realloc($1.nibbles_ptr, n_bytes);
882 int n_bytes_1 = ($1.n_nibbles + 1) / 2;
883 int n_bytes_3 = ($3.n_nibbles + 1) / 2;
884 if ($1.n_nibbles % 2) {
885 for (int i=n_bytes_1; i<n_bytes; i++) {
886 unsigned char S3_byte = $3.nibbles_ptr[i - n_bytes_1];
887 $$.nibbles_ptr[i - 1] |= S3_byte << 4;
888 $$.nibbles_ptr[i] = S3_byte >> 4;
890 if ($3.n_nibbles % 2)
891 $$.nibbles_ptr[n_bytes - 1] |= $3.nibbles_ptr[n_bytes_3 - 1] << 4;
893 memcpy($$.nibbles_ptr + n_bytes_1, $3.nibbles_ptr, n_bytes_3);
895 Free($3.nibbles_ptr);
904 | OctetstringValue ConcatOp Ostring
906 $$.n_octets = $1.n_octets + $3.n_octets;
907 $$.octets_ptr = (unsigned char *)Realloc($1.octets_ptr, $$.n_octets);
908 memcpy($$.octets_ptr + $1.n_octets, $3.octets_ptr, $3.n_octets);
913 UniversalCharstringValue:
914 Cstring seqUniversalCharstringFragment
916 $$.n_uchars = $1.n_chars + $2.n_uchars;
917 $$.uchars_ptr = (universal_char*)
918 Malloc($$.n_uchars * sizeof(universal_char));
919 for (int i = 0; i < $1.n_chars; i++) {
920 $$.uchars_ptr[i].uc_group = 0;
921 $$.uchars_ptr[i].uc_plane = 0;
922 $$.uchars_ptr[i].uc_row = 0;
923 $$.uchars_ptr[i].uc_cell = $1.chars_ptr[i];
925 memcpy($$.uchars_ptr + $1.n_chars, $2.uchars_ptr,
926 $2.n_uchars * sizeof(universal_char));
927 $$.n_quads = $2.n_quads;
928 $$.quad_positions = (int*)Malloc($$.n_quads * sizeof(int));
929 for (int i = 0; i < $$.n_quads; i++) {
930 $$.quad_positions[i] = $2.quad_positions[i] + $1.n_chars;
934 Free($2.quad_positions);
939 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
940 $$.uchars_ptr[0] = $1;
942 $$.quad_positions = (int*)Malloc(sizeof(int));
943 $$.quad_positions[0] = 0;
945 | Quadruple seqUniversalCharstringFragment
947 $$.n_uchars = $2.n_uchars + 1;
948 $$.uchars_ptr = (universal_char*)
949 Malloc($$.n_uchars * sizeof(universal_char));
950 $$.uchars_ptr[0] = $1;
951 memcpy($$.uchars_ptr + 1, $2.uchars_ptr,
952 $2.n_uchars * sizeof(universal_char));
953 $$.n_quads = $2.n_quads + 1;
954 $$.quad_positions = (int*)Malloc($$.n_quads * sizeof(int));
955 $$.quad_positions[0] = 0;
956 for (int i = 0; i < $2.n_quads; i++) {
957 $$.quad_positions[i + 1] = $2.quad_positions[i] + 1;
960 Free($2.quad_positions);
964 seqUniversalCharstringFragment:
965 ConcatOp UniversalCharstringFragment
969 | seqUniversalCharstringFragment ConcatOp UniversalCharstringFragment
971 $$.n_uchars = $1.n_uchars + $3.n_uchars;
972 $$.uchars_ptr = (universal_char*)
973 Realloc($1.uchars_ptr, $$.n_uchars * sizeof(universal_char));
974 memcpy($$.uchars_ptr + $1.n_uchars, $3.uchars_ptr,
975 $3.n_uchars * sizeof(universal_char));
976 $$.n_quads = $1.n_quads + $3.n_quads;
977 $$.quad_positions = (int*)Realloc($1.quad_positions, $$.n_quads * sizeof(int));
978 for (int i = 0; i < $3.n_quads; i++) {
979 $$.quad_positions[$1.n_quads + i] = $3.quad_positions[i] + $1.n_uchars;
982 Free($3.quad_positions);
986 UniversalCharstringFragment:
989 $$.n_uchars = $1.n_chars;
990 $$.uchars_ptr = (universal_char*)
991 Malloc($$.n_uchars * sizeof(universal_char));
992 for (int i = 0; i < $1.n_chars; i++) {
993 $$.uchars_ptr[i].uc_group = 0;
994 $$.uchars_ptr[i].uc_plane = 0;
995 $$.uchars_ptr[i].uc_row = 0;
996 $$.uchars_ptr[i].uc_cell = $1.chars_ptr[i];
999 $$.quad_positions = 0;
1005 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
1006 $$.uchars_ptr[0] = $1;
1008 $$.quad_positions = (int*)Malloc(sizeof(int));
1009 $$.quad_positions[0] = 0;
1014 CharKeyword '(' IntegerValue ',' IntegerValue ',' IntegerValue ','
1017 if (*$3 < 0 || *$3 > 127) {
1018 char *s = $3->as_string();
1019 config_process_error_f("The first number of quadruple (group) must be "
1020 "within the range 0 .. 127 instead of %s.", s);
1022 $$.uc_group = *$3 < 0 ? 0 : 127;
1024 $$.uc_group = $3->get_val();
1026 if (*$5 < 0 || *$5 > 255) {
1027 char *s = $5->as_string();
1028 config_process_error_f("The second number of quadruple (plane) must be "
1029 "within the range 0 .. 255 instead of %s.", s);
1031 $$.uc_plane = *$5 < 0 ? 0 : 255;
1033 $$.uc_plane = $5->get_val();
1035 if (*$7 < 0 || *$7 > 255) {
1036 char *s = $7->as_string();
1037 config_process_error_f("The third number of quadruple (row) must be "
1038 "within the range 0 .. 255 instead of %s.", s);
1040 $$.uc_row = *$7 < 0 ? 0 : 255;
1042 $$.uc_row = $7->get_val();
1044 if (*$9 < 0 || *$9 > 255) {
1045 char *s = $9->as_string();
1046 config_process_error_f("The fourth number of quadruple (cell) must be "
1047 "within the range 0 .. 255 instead of %s.", s);
1049 $$.uc_cell = *$9 < 0 ? 0 : 255;
1051 $$.uc_cell = $9->get_val();
1067 $$ = mcopystr($1.chars_ptr);
1070 | StringValue ConcatOp Cstring
1072 $$ = mputstr($1, $3.chars_ptr);
1078 Identifier { $$ = $1; }
1079 | ASN1LowerIdentifier { $$ = $1; }
1085 $$ = new Module_Param_Value_List();
1087 | '{' FieldValueList '}'
1091 | '{' ArrayItemList '}'
1095 | '{' IndexItemList '}'
1099 | '(' ParameterValue ',' TemplateItemList ')' /* at least 2 elements to avoid shift/reduce conflicts with IntegerValue and FloatValue rules */
1101 $$ = new Module_Param_List_Template();
1102 $2->set_id(new Module_Param_Index($$->get_size(),false));
1104 $$->add_list_with_implicit_ids($4);
1107 | ComplementKeyword '(' TemplateItemList ')'
1109 $$ = new Module_Param_ComplementList_Template();
1110 $$->add_list_with_implicit_ids($3);
1113 | SupersetKeyword '(' TemplateItemList ')'
1115 $$ = new Module_Param_Superset_Template();
1116 $$->add_list_with_implicit_ids($3);
1119 | SubsetKeyword '(' TemplateItemList ')'
1121 $$ = new Module_Param_Subset_Template();
1122 $$->add_list_with_implicit_ids($3);
1127 ParameterValueOrNotUsedSymbol:
1134 $$ = new Module_Param_NotUsed();
1141 $$ = new Vector<Module_Param*>();
1144 | TemplateItemList ',' ParameterValue
1154 $$ = new Module_Param_Assignment_List();
1157 | FieldValueList ',' FieldValue
1165 FieldName AssignmentChar ParameterValueOrNotUsedSymbol
1168 $$->set_id(new Module_Param_FieldName($1));
1177 | ASN1LowerIdentifier
1186 $$ = new Module_Param_Value_List();
1187 $1->set_id(new Module_Param_Index($$->get_size(),false));
1190 | ArrayItemList ',' ArrayItem
1193 $3->set_id(new Module_Param_Index($$->get_size(),false));
1199 ParameterValueOrNotUsedSymbol
1203 | PermutationKeyword '(' TemplateItemList ')'
1205 $$ = new Module_Param_Permutation_Template();
1206 $$->add_list_with_implicit_ids($3);
1214 $$ = new Module_Param_Indexed_List();
1217 | IndexItemList ',' IndexItem
1225 IndexItemIndex AssignmentChar ParameterValue
1228 $$->set_id(new Module_Param_Index((size_t)$1,true));
1233 '[' IntegerValue ']'
1235 if (!$2->is_native()) {
1236 config_process_error("bignum index."); // todo
1238 if ($2->is_negative()) {
1239 config_process_error("negative index."); // todo
1246 /*************** [LOGGING] section *********************************/
1249 LoggingKeyword LoggingParamList
1254 | LoggingParamList LoggingParamLines optSemiColon
1256 // Centralized duplication handling for `[LOGGING]'.
1257 if ($2.logparam.log_param_selection != LP_UNKNOWN && TTCN_Logger::add_parameter($2)) {
1258 switch ($2.logparam.log_param_selection) {
1260 check_duplicate_option("LOGGING", "FileMask", file_mask_set);
1262 case LP_CONSOLEMASK:
1263 check_duplicate_option("LOGGING", "ConsoleMask", console_mask_set);
1265 case LP_LOGFILESIZE:
1266 check_duplicate_option("LOGGING", "LogFileSize", log_file_size_set);
1268 case LP_LOGFILENUMBER:
1269 check_duplicate_option("LOGGING", "LogFileNumber", log_file_number_set);
1271 case LP_DISKFULLACTION:
1272 check_duplicate_option("LOGGING", "DiskFullAction", log_disk_full_action_set);
1275 check_duplicate_option("LOGGING", "LogFile", file_name_set);
1277 case LP_TIMESTAMPFORMAT:
1278 check_duplicate_option("LOGGING", "TimeStampFormat", timestamp_format_set);
1280 case LP_SOURCEINFOFORMAT:
1281 check_duplicate_option("LOGGING", "SourceInfoFormat", source_info_format_set);
1284 check_duplicate_option("LOGGING", "AppendFile", append_file_set);
1286 case LP_LOGEVENTTYPES:
1287 check_duplicate_option("LOGGING", "LogEventTypes", log_event_types_set);
1289 case LP_LOGENTITYNAME:
1290 check_duplicate_option("LOGGING", "LogEntityName", log_entity_name_set);
1292 case LP_MATCHINGHINTS:
1293 check_duplicate_option("LOGGING", "MatchingVerbosity", matching_verbosity_set);
1295 case LP_PLUGIN_SPECIFIC:
1296 // It would be an overkill to check for the infinite number of custom parameters...
1297 check_duplicate_option("LOGGING", "PluginSpecific", plugin_specific_set);
1309 $$.component.id_selector = COMPONENT_ID_ALL;
1310 $$.component.id_name = NULL;
1311 $$.plugin_id = NULL;
1314 | ComponentId '.' LoggingParam
1317 $$.plugin_id = NULL;
1320 | ComponentId '.' LoggerPluginId '.' LoggingParam
1326 | LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1328 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1329 component_id_t comp;
1330 comp.id_selector = COMPONENT_ID_ALL;
1331 comp.id_name = NULL;
1332 logging_plugin_t *plugin = $4;
1333 while (plugin != NULL) {
1334 // `identifier' and `filename' are reused. Various checks and
1335 // validations must be done in the logger itself (e.g. looking for
1336 // duplicate options).
1337 TTCN_Logger::register_plugin(comp, plugin->identifier, plugin->filename);
1338 logging_plugin_t *tmp = plugin;
1342 $$.logparam.log_param_selection = LP_UNKNOWN;
1344 | ComponentId '.' LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1346 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1347 logging_plugin_t *plugin = $6;
1348 while (plugin != NULL) {
1349 TTCN_Logger::register_plugin($1, plugin->identifier, plugin->filename);
1350 logging_plugin_t *tmp = plugin;
1354 // Component names shall be duplicated in `register_plugin()'.
1355 if ($1.id_selector == COMPONENT_ID_NAME)
1357 $$.logparam.log_param_selection = LP_UNKNOWN;
1366 | LoggerPluginList ',' LoggerPlugin
1376 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1377 $$->identifier = $1;
1378 $$->filename = NULL;
1381 | Identifier AssignmentChar StringValue
1383 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1384 $$->identifier = $1;
1391 '*' { $$ = mcopystr("*"); }
1392 | Identifier { $$ = $1; }
1396 FileMask AssignmentChar LoggingBitmask
1398 $$.log_param_selection = LP_FILEMASK;
1399 $$.logoptions_val = $3;
1401 | ConsoleMask AssignmentChar LoggingBitmask
1403 $$.log_param_selection = LP_CONSOLEMASK;
1404 $$.logoptions_val = $3;
1406 | LogFileSize AssignmentChar Number
1408 $$.log_param_selection = LP_LOGFILESIZE;
1409 $$.int_val = (int)$3->get_val();
1412 | EmergencyLogging AssignmentChar Number
1414 $$.log_param_selection = LP_EMERGENCY;
1415 $$.int_val = (int)$3->get_val();
1418 | EmergencyLoggingBehaviour AssignmentChar EmergencyLoggingBehaviourValue
1420 $$.log_param_selection = LP_EMERGENCYBEHAVIOR;
1421 $$.emergency_logging_behaviour_value = $3;
1423 | EmergencyLoggingMask AssignmentChar LoggingBitmask
1425 $$.log_param_selection = LP_EMERGENCYMASK;
1426 $$.logoptions_val = $3;
1428 | LogFileNumber AssignmentChar Number
1430 $$.log_param_selection = LP_LOGFILENUMBER;
1431 $$.int_val = (int)$3->get_val();
1434 | DiskFullAction AssignmentChar DiskFullActionValue
1436 $$.log_param_selection = LP_DISKFULLACTION;
1437 $$.disk_full_action_value = $3;
1439 | LogFile AssignmentChar LogFileName
1441 $$.log_param_selection = LP_LOGFILE;
1444 | TimestampFormat AssignmentChar TimestampValue
1446 $$.log_param_selection = LP_TIMESTAMPFORMAT;
1447 $$.timestamp_value = $3;
1449 | ConsoleTimestampFormat AssignmentChar TimestampValue
1451 $$.log_param_selection = LP_UNKNOWN;
1453 | SourceInfoFormat AssignmentChar SourceInfoSetting
1455 $$.log_param_selection = LP_SOURCEINFOFORMAT;
1456 $$.source_info_value = $3;
1458 | AppendFile AssignmentChar YesNoOrBoolean
1460 $$.log_param_selection = LP_APPENDFILE;
1463 | LogEventTypes AssignmentChar LogEventTypesValue
1465 $$.log_param_selection = LP_LOGEVENTTYPES;
1466 $$.log_event_types_value = $3;
1468 | LogEntityName AssignmentChar YesNoOrBoolean
1470 $$.log_param_selection = LP_LOGENTITYNAME;
1473 | MatchingHints AssignmentChar VerbosityValue
1475 $$.log_param_selection = LP_MATCHINGHINTS;
1476 $$.matching_verbosity_value = $3;
1478 | Identifier AssignmentChar StringValue
1480 $$.log_param_selection = LP_PLUGIN_SPECIFIC;
1487 Compact { $$ = TTCN_Logger::VERBOSITY_COMPACT; }
1488 | Detailed { $$ = TTCN_Logger::VERBOSITY_FULL; }
1491 DiskFullActionValue:
1492 Error { $$.type = TTCN_Logger::DISKFULL_ERROR; }
1493 | Stop { $$.type = TTCN_Logger::DISKFULL_STOP; }
1496 $$.type = TTCN_Logger::DISKFULL_RETRY;
1497 $$.retry_interval = 30; /* default retry interval */
1499 | Retry '(' Number ')'
1501 $$.type = TTCN_Logger::DISKFULL_RETRY;
1502 $$.retry_interval = (size_t)$3->get_val();
1505 | Delete { $$.type = TTCN_Logger::DISKFULL_DELETE; }
1509 StringValue { $$ = $1; }
1512 LoggingBitOrCollection:
1518 | LoggingBitCollection
1523 case TTCN_Logger::ACTION_UNQUALIFIED:
1524 $$.add_sev(TTCN_Logger::ACTION_UNQUALIFIED);
1526 case TTCN_Logger::DEFAULTOP_UNQUALIFIED:
1527 $$.add_sev(TTCN_Logger::DEFAULTOP_ACTIVATE);
1528 $$.add_sev(TTCN_Logger::DEFAULTOP_DEACTIVATE);
1529 $$.add_sev(TTCN_Logger::DEFAULTOP_EXIT);
1530 $$.add_sev(TTCN_Logger::DEFAULTOP_UNQUALIFIED);
1532 case TTCN_Logger::ERROR_UNQUALIFIED:
1533 $$.add_sev(TTCN_Logger::ERROR_UNQUALIFIED);
1535 case TTCN_Logger::EXECUTOR_UNQUALIFIED:
1536 $$.add_sev(TTCN_Logger::EXECUTOR_RUNTIME);
1537 $$.add_sev(TTCN_Logger::EXECUTOR_CONFIGDATA);
1538 $$.add_sev(TTCN_Logger::EXECUTOR_EXTCOMMAND);
1539 $$.add_sev(TTCN_Logger::EXECUTOR_COMPONENT);
1540 $$.add_sev(TTCN_Logger::EXECUTOR_LOGOPTIONS);
1541 $$.add_sev(TTCN_Logger::EXECUTOR_UNQUALIFIED);
1543 case TTCN_Logger::FUNCTION_UNQUALIFIED:
1544 $$.add_sev(TTCN_Logger::FUNCTION_RND);
1545 $$.add_sev(TTCN_Logger::FUNCTION_UNQUALIFIED);
1547 case TTCN_Logger::PARALLEL_UNQUALIFIED:
1548 $$.add_sev(TTCN_Logger::PARALLEL_PTC);
1549 $$.add_sev(TTCN_Logger::PARALLEL_PORTCONN);
1550 $$.add_sev(TTCN_Logger::PARALLEL_PORTMAP);
1551 $$.add_sev(TTCN_Logger::PARALLEL_UNQUALIFIED);
1553 case TTCN_Logger::PORTEVENT_UNQUALIFIED:
1554 $$.add_sev(TTCN_Logger::PORTEVENT_PQUEUE);
1555 $$.add_sev(TTCN_Logger::PORTEVENT_MQUEUE);
1556 $$.add_sev(TTCN_Logger::PORTEVENT_STATE);
1557 $$.add_sev(TTCN_Logger::PORTEVENT_PMIN);
1558 $$.add_sev(TTCN_Logger::PORTEVENT_PMOUT);
1559 $$.add_sev(TTCN_Logger::PORTEVENT_PCIN);
1560 $$.add_sev(TTCN_Logger::PORTEVENT_PCOUT);
1561 $$.add_sev(TTCN_Logger::PORTEVENT_MMRECV);
1562 $$.add_sev(TTCN_Logger::PORTEVENT_MMSEND);
1563 $$.add_sev(TTCN_Logger::PORTEVENT_MCRECV);
1564 $$.add_sev(TTCN_Logger::PORTEVENT_MCSEND);
1565 $$.add_sev(TTCN_Logger::PORTEVENT_DUALRECV);
1566 $$.add_sev(TTCN_Logger::PORTEVENT_DUALSEND);
1567 $$.add_sev(TTCN_Logger::PORTEVENT_UNQUALIFIED);
1569 case TTCN_Logger::TESTCASE_UNQUALIFIED:
1570 $$.add_sev(TTCN_Logger::TESTCASE_START);
1571 $$.add_sev(TTCN_Logger::TESTCASE_FINISH);
1572 $$.add_sev(TTCN_Logger::TESTCASE_UNQUALIFIED);
1574 case TTCN_Logger::TIMEROP_UNQUALIFIED:
1575 $$.add_sev(TTCN_Logger::TIMEROP_READ);
1576 $$.add_sev(TTCN_Logger::TIMEROP_START);
1577 $$.add_sev(TTCN_Logger::TIMEROP_GUARD);
1578 $$.add_sev(TTCN_Logger::TIMEROP_STOP);
1579 $$.add_sev(TTCN_Logger::TIMEROP_TIMEOUT);
1580 $$.add_sev(TTCN_Logger::TIMEROP_UNQUALIFIED);
1582 case TTCN_Logger::USER_UNQUALIFIED:
1583 $$.add_sev(TTCN_Logger::USER_UNQUALIFIED);
1585 case TTCN_Logger::STATISTICS_UNQUALIFIED:
1586 $$.add_sev(TTCN_Logger::STATISTICS_VERDICT);
1587 $$.add_sev(TTCN_Logger::STATISTICS_UNQUALIFIED);
1589 case TTCN_Logger::VERDICTOP_UNQUALIFIED:
1590 $$.add_sev(TTCN_Logger::VERDICTOP_GETVERDICT);
1591 $$.add_sev(TTCN_Logger::VERDICTOP_SETVERDICT);
1592 $$.add_sev(TTCN_Logger::VERDICTOP_FINAL);
1593 $$.add_sev(TTCN_Logger::VERDICTOP_UNQUALIFIED);
1595 case TTCN_Logger::WARNING_UNQUALIFIED:
1596 $$.add_sev(TTCN_Logger::WARNING_UNQUALIFIED);
1598 case TTCN_Logger::MATCHING_UNQUALIFIED:
1599 $$.add_sev(TTCN_Logger::MATCHING_DONE);
1600 $$.add_sev(TTCN_Logger::MATCHING_TIMEOUT);
1601 $$.add_sev(TTCN_Logger::MATCHING_PCSUCCESS);
1602 $$.add_sev(TTCN_Logger::MATCHING_PCUNSUCC);
1603 $$.add_sev(TTCN_Logger::MATCHING_PMSUCCESS);
1604 $$.add_sev(TTCN_Logger::MATCHING_PMUNSUCC);
1605 $$.add_sev(TTCN_Logger::MATCHING_MCSUCCESS);
1606 $$.add_sev(TTCN_Logger::MATCHING_MCUNSUCC);
1607 $$.add_sev(TTCN_Logger::MATCHING_MMSUCCESS);
1608 $$.add_sev(TTCN_Logger::MATCHING_MMUNSUCC);
1609 $$.add_sev(TTCN_Logger::MATCHING_PROBLEM);
1610 $$.add_sev(TTCN_Logger::MATCHING_UNQUALIFIED);
1612 case TTCN_Logger::DEBUG_UNQUALIFIED:
1613 $$.add_sev(TTCN_Logger::DEBUG_ENCDEC);
1614 $$.add_sev(TTCN_Logger::DEBUG_TESTPORT);
1615 $$.add_sev(TTCN_Logger::DEBUG_UNQUALIFIED);
1617 case TTCN_Logger::LOG_ALL_IMPORTANT:
1618 $$ = Logging_Bits::log_all;
1621 /* The lexer sent something the parser doesn't understand!
1622 Parser needs to be updated.
1624 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
1625 "Internal error: unknown logbit from lexer.");
1632 LoggingBitOrCollection
1636 | LoggingBitmask '|' LoggingBitOrCollection
1644 SourceInfoValue { $$ = $1; }
1647 $$ = $1 ? TTCN_Logger::SINFO_SINGLE : TTCN_Logger::SINFO_NONE;
1653 | BooleanValue { $$ = $1; }
1657 YesNoOrBoolean { $$ = $1 ? TTCN_Logger::LOGEVENTTYPES_YES :
1658 TTCN_Logger::LOGEVENTTYPES_NO; }
1659 | SubCategories { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1660 | Detailed { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1663 /**************** [TESTPORT_PARAMETERS] ****************************/
1665 TestportParametersSection:
1666 TestportParametersKeyword TestportParameterList
1669 TestportParameterList:
1671 | TestportParameterList TestportParameter optSemiColon
1675 ComponentId '.' TestportName '.' TestportParameterName AssignmentChar
1676 TestportParameterValue
1678 PORT::add_parameter($1, $3, $5, $7);
1679 if ($1.id_selector == COMPONENT_ID_NAME) Free($1.id_name);
1689 $$.id_selector = COMPONENT_ID_NAME;
1694 $$.id_selector = COMPONENT_ID_NAME;
1695 $$.id_name = $1.chars_ptr;
1699 $$.id_selector = COMPONENT_ID_COMPREF;
1700 $$.id_compref = (component)$1->get_val();
1705 $$.id_selector = COMPONENT_ID_COMPREF;
1706 $$.id_compref = MTC_COMPREF;
1710 $$.id_selector = COMPONENT_ID_ALL;
1715 $$.id_selector = COMPONENT_ID_SYSTEM;
1721 Identifier { $$ = $1; }
1722 | Identifier ArrayRef
1724 $$ = mputstr($1, $2);
1727 | '*' { $$ = NULL; }
1731 '[' IntegerValue ']'
1733 char *s = $2->as_string();
1735 $$ = mputc ($$, '[');
1736 $$ = mputstr($$, s);
1737 $$ = mputc ($$, ']');
1741 | ArrayRef '[' IntegerValue ']'
1743 char *s = $3->as_string();
1744 $$ = mputc ($1, '[');
1745 $$ = mputstr($$, s);
1746 $$ = mputc ($$, ']');
1752 TestportParameterName:
1753 Identifier { $$ = $1; }
1756 TestportParameterValue:
1757 StringValue { $$ = $1; }
1760 /****************** [EXECUTE] section *************/
1763 ExecuteKeyword ExecuteList
1765 if (!TTCN_Runtime::is_single()) config_process_error("Internal error: "
1766 "the Main Controller must not send section [EXECUTE] of the "
1767 "configuration file.");
1773 | ExecuteList ExecuteItem optSemiColon
1775 if (TTCN_Runtime::is_single()) {
1776 execute_list = (execute_list_item *)Realloc(
1777 execute_list, (execute_list_len + 1) *
1778 sizeof(*execute_list));
1779 execute_list[execute_list_len++] = $2;
1781 Free($2.module_name);
1782 Free($2.testcase_name);
1790 $$.module_name = $1;
1791 $$.testcase_name = NULL;
1793 | Identifier '.' ControlKeyword
1795 $$.module_name = $1;
1796 $$.testcase_name = NULL;
1798 | Identifier '.' Identifier
1800 $$.module_name = $1;
1801 $$.testcase_name = $3;
1803 | Identifier '.' '*'
1805 $$.module_name = $1;
1806 $$.testcase_name = mcopystr("*");
1810 /****************** [EXTERNAL_COMMANDS] section **********************/
1812 ExternalCommandsSection:
1813 ExternalCommandsKeyword ExternalCommandList
1816 ExternalCommandList:
1818 | ExternalCommandList ExternalCommand optSemiColon
1822 BeginControlPart AssignmentChar Command
1824 check_duplicate_option("EXTERNAL_COMMANDS", "BeginControlPart",
1825 begin_controlpart_command_set);
1827 TTCN_Runtime::set_begin_controlpart_command($3);
1831 | EndControlPart AssignmentChar Command
1833 check_duplicate_option("EXTERNAL_COMMANDS", "EndControlPart",
1834 end_controlpart_command_set);
1836 TTCN_Runtime::set_end_controlpart_command($3);
1840 | BeginTestCase AssignmentChar Command
1842 check_duplicate_option("EXTERNAL_COMMANDS", "BeginTestCase",
1843 begin_testcase_command_set);
1845 TTCN_Runtime::set_begin_testcase_command($3);
1849 | EndTestCase AssignmentChar Command
1851 check_duplicate_option("EXTERNAL_COMMANDS", "EndTestCase",
1852 end_testcase_command_set);
1854 TTCN_Runtime::set_end_testcase_command($3);
1861 StringValue { $$ = $1; }
1864 /***************** [GROUPS] section *******************/
1867 GroupsKeyword GroupList
1869 check_ignored_section("GROUPS");
1875 | GroupList Group optSemiColon
1879 GroupName AssignmentChar GroupMembers
1883 Identifier { Free($1); }
1893 | seqGroupMember ',' HostName
1898 | Identifier { Free($1); }
1901 /******************** [COMPONENTS] section *******************/
1903 ComponentsKeyword ComponentList
1905 check_ignored_section("COMPONENTS");
1911 | ComponentList ComponentItem optSemiColon
1915 ComponentName AssignmentChar ComponentLocation
1919 Identifier { Free($1); }
1924 Identifier { Free($1); }
1928 /****************** [MAIN_CONTROLLER] section *********************/
1929 MainControllerSection:
1930 MainControllerKeyword MCParameterList
1932 check_ignored_section("MAIN_CONTROLLER");
1938 | MCParameterList MCParameter optSemiColon
1942 LocalAddress AssignmentChar HostName { }
1943 | TCPPort AssignmentChar IntegerValue { delete $3; }
1944 | KillTimer AssignmentChar KillTimerValue { }
1945 | NumHCs AssignmentChar IntegerValue { delete $3; }
1946 | UnixSocketEnabled AssignmentChar YesToken {}
1947 | UnixSocketEnabled AssignmentChar NoToken {}
1948 | UnixSocketEnabled AssignmentChar HostName {}
1953 | IntegerValue { delete $1; }
1956 /****************** [INCLUDE] section *********************/
1958 IncludeKeyword IncludeFiles
1960 if(!TTCN_Runtime::is_single())
1961 config_process_error
1962 ("Internal error: the Main Controller must not send section [INCLUDE]"
1963 " of the configuration file.");
1969 | IncludeFiles IncludeFile
1973 Cstring { Free($1.chars_ptr); }
1976 /****************** [DEFINE] section *********************/
1980 if(!TTCN_Runtime::is_single())
1981 config_process_error
1982 ("Internal error: the Main Controller must not send section [DEFINE]"
1983 " of the configuration file.");
1987 /*********************************************************/
1992 $$ = Module_Param::OT_ASSIGN;
1997 $$ = Module_Param::OT_CONCAT;
2008 static void reset_configuration_options()
2010 /* Section [MODULE_PARAMETERS */
2011 /** \todo reset module parameters to their default values */
2012 /* Section [LOGGING] */
2013 TTCN_Logger::close_file();
2014 TTCN_Logger::reset_configuration();
2015 file_name_set = FALSE;
2016 file_mask_set = TRUE;
2017 console_mask_set = TRUE;
2018 timestamp_format_set = FALSE;
2019 source_info_format_set = FALSE;
2020 append_file_set = FALSE;
2021 log_event_types_set = FALSE;
2022 log_entity_name_set = FALSE;
2023 /* Section [TESTPORT_PARAMETERS] */
2024 PORT::clear_parameters();
2025 /* Section [EXTERNAL_COMMANDS] */
2027 TTCN_Runtime::clear_external_commands();
2029 begin_controlpart_command_set = FALSE;
2030 end_controlpart_command_set = FALSE;
2031 begin_testcase_command_set = FALSE;
2032 end_testcase_command_set = FALSE;
2035 Module_Param* process_config_string2ttcn(const char* mp_str, bool is_component)
2037 if (parsed_module_param!=NULL || parsing_error_messages!=NULL) TTCN_error("Internal error: previously parsed ttcn string was not cleared.");
2038 // add the hidden keyword
2039 std::string mp_string = (is_component) ? std::string("$#&&&(#TTCNSTRINGPARSING_COMPONENT$#&&^#% ") + mp_str
2040 : std::string("$#&&&(#TTCNSTRINGPARSING$#&&^#% ") + mp_str;
2041 struct yy_buffer_state *flex_buffer = config_process__scan_bytes(mp_string.c_str(), (int)mp_string.size());
2042 if (flex_buffer == NULL) TTCN_error("Internal error: flex buffer creation failed.");
2043 reset_config_process_lex(NULL);
2046 Ttcn_String_Parsing ttcn_string_parsing;
2047 if (config_process_parse()) error_flag = TRUE;
2048 } catch (const TC_Error& TC_error) {
2049 if (parsed_module_param!=NULL) { delete parsed_module_param; parsed_module_param = NULL; }
2052 config_process_close();
2053 config_process_lex_destroy();
2055 if (error_flag || parsing_error_messages!=NULL) {
2056 delete parsed_module_param;
2057 parsed_module_param = NULL;
2058 char* pem = parsing_error_messages!=NULL ? parsing_error_messages : mcopystr("Unknown parsing error");
2059 parsing_error_messages = NULL;
2060 TTCN_error_begin("%s", pem);
2065 if (parsed_module_param==NULL) TTCN_error("Internal error: could not parse ttcn string.");
2066 Module_Param* ret_val = parsed_module_param;
2067 parsed_module_param = NULL;
2072 boolean process_config_string(const char *config_string, int string_len)
2076 struct yy_buffer_state *flex_buffer =
2077 config_process__scan_bytes(config_string, string_len);
2078 if (flex_buffer == NULL) {
2079 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
2080 "Internal error: flex buffer creation failed.");
2085 reset_configuration_options();
2086 reset_config_process_lex(NULL);
2087 if (config_process_parse()) error_flag = TRUE;
2089 } catch (const TC_Error& TC_error) {
2093 config_process_close();
2094 config_process_lex_destroy();
2100 boolean process_config_file(const char *file_name)
2103 string_chain_t *filenames=NULL;
2105 reset_configuration_options();
2107 if(preproc_parse_file(file_name, &filenames, &config_defines))
2111 char *fn=string_chain_cut(&filenames);
2112 reset_config_process_lex(fn);
2113 /* The lexer can modify config_process_in
2114 * when it's input buffer is changed */
2115 config_process_in = fopen(fn, "r");
2116 FILE* tmp_cfg = config_process_in;
2117 if (config_process_in != NULL) {
2119 if(config_process_parse()) error_flag=TRUE;
2120 } catch (const TC_Error& TC_error) {
2124 config_process_close();
2125 config_process_lex_destroy();
2127 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2128 TTCN_Logger::log_event("Cannot open configuration file: %s", fn);
2129 TTCN_Logger::OS_error();
2130 TTCN_Logger::end_event();
2133 /* During parsing flex or libc may use some system calls (e.g. ioctl)
2134 * that fail with an error status. Such error codes shall be ignored in
2135 * future error messages. */
2141 string_map_free(config_defines);
2142 config_defines = NULL;
2147 void config_process_error_f(const char *error_str, ...)
2149 if (Ttcn_String_Parsing::happening()) {
2151 va_start(p_var, error_str);
2152 char* error_msg_str = mprintf_va_list(error_str, p_var);
2154 if (parsing_error_messages!=NULL) parsing_error_messages = mputc(parsing_error_messages, '\n');
2155 parsing_error_messages = mputprintf(parsing_error_messages,
2156 "Parse error in line %d, at or before token `%s': %s", config_process_get_current_line(), config_process_text, error_msg_str);
2157 Free(error_msg_str);
2161 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2162 if (!get_cfg_process_current_file().empty()) {
2163 TTCN_Logger::log_event("Parse error in configuration file `%s': in line %d, "
2164 "at or before token `%s': ",
2165 get_cfg_process_current_file().c_str(), config_process_get_current_line(),
2169 TTCN_Logger::log_event("Parse error while reading configuration "
2170 "information: in line %d, at or before token `%s': ",
2171 config_process_get_current_line(), config_process_text);
2174 va_start(pvar, error_str);
2175 TTCN_Logger::log_event_va_list(error_str, pvar);
2177 TTCN_Logger::end_event();
2181 void config_process_error(const char *error_str)
2183 config_process_error_f("%s", error_str);
2186 void config_preproc_error(const char *error_str, ...)
2188 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2189 TTCN_Logger::log_event("Parse error while pre-processing configuration"
2190 " file `%s': in line %d: ",
2191 get_cfg_preproc_current_file().c_str(),
2192 config_preproc_yylineno);
2194 va_start(pvar, error_str);
2195 TTCN_Logger::log_event_va_list(error_str, pvar);
2197 TTCN_Logger::end_event();
2201 void path_error(const char *fmt, ...)
2204 fprintf(stderr, "File error: ");
2205 va_start(parameters, fmt);
2206 vfprintf(stderr, fmt, parameters);
2208 fprintf(stderr, "\n");
2211 static void check_duplicate_option(const char *section_name,
2212 const char *option_name, boolean& option_flag)
2215 TTCN_warning("Option `%s' was given more than once in section [%s] of the "
2216 "configuration file.", option_name, section_name);
2217 } else option_flag = TRUE;
2220 static void check_ignored_section(const char *section_name)
2222 if (TTCN_Runtime::is_single()) TTCN_warning("Section [%s] of "
2223 "configuration file is ignored in single mode.", section_name);
2224 else config_process_error_f("Internal error: the Main Controller must not "
2225 "send section [%s] of the configuration file.", section_name);
2228 static void set_param(Module_Param& param)
2231 Module_List::set_param(param);
2233 catch (const TC_Error& TC_error) {
2238 unsigned char char_to_hexdigit(char c)
2240 if (c >= '0' && c <= '9') return c - '0';
2241 else if (c >= 'A' && c <= 'F') return c - 'A' + 10;
2242 else if (c >= 'a' && c <= 'f') return c - 'a' + 10;
2244 config_process_error_f("char_to_hexdigit(): invalid argument: %c", c);
2245 return 0; // to avoid warning