Newer
Older
/******************************************************************************
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*
* Baji, Laszlo
* Balasko, Jeno
* Baranyi, Botond
* Beres, Szabolcs
* Delic, Adam
* Forstner, Matyas
* Kovacs, Ferenc
* Pandi, Krisztian
* Raduly, Csaba
* Szabados, Kristof
* Szabo, Janos Zoltan – initial implementation
* Szalai, Gabor
* Zalanyi, Balazs Andor
*
******************************************************************************/
%{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#include <errno.h>
#include <openssl/bn.h>
#include "../common/config_preproc.h"
#include "Param_Types.hh"
#include "Integer.hh"
#include "Float.hh"
#include "Boolean.hh"
#include "Objid.hh"
#include "Verdicttype.hh"
#include "Bitstring.hh"
#include "Hexstring.hh"
#include "Octetstring.hh"
#include "Charstring.hh"
#include "Universal_charstring.hh"
#include "Module_list.hh"
#include "Port.hh"
#include "Runtime.hh"
#include "LoggingBits.hh"
#include "LoggingParam.hh"
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#define YYERROR_VERBOSE
#include "config_process.lex.hh"
extern void reset_config_process_lex(const char* fname);
extern void config_process_close();
extern int config_process_get_current_line();
extern std::string get_cfg_process_current_file();
static int config_process_parse();
static void check_duplicate_option(const char *section_name,
const char *option_name, boolean& option_flag);
static void check_ignored_section(const char *section_name);
static void set_param(Module_Param& module_param);
static unsigned char char_to_hexdigit(char c);
static boolean error_flag = FALSE;
static Module_Param* parsed_module_param = NULL;
static char * parsing_error_messages = NULL;
/*
For detecting duplicate entries in the config file. Start out as FALSE,
set to TRUE bycheck_duplicate_option().
Exception: duplication of parameters that can be component specific is checked
by set_xxx(), these start out as TRUE.
*/
static boolean file_name_set = FALSE,
file_mask_set = TRUE,
console_mask_set = TRUE,
timestamp_format_set = FALSE,
source_info_format_set = FALSE,
append_file_set = FALSE,
log_event_types_set = FALSE,
log_entity_name_set = FALSE,
begin_controlpart_command_set = FALSE,
end_controlpart_command_set = FALSE,
begin_testcase_command_set = FALSE,
end_testcase_command_set = FALSE,
log_file_size_set = TRUE,
log_file_number_set = TRUE,
log_disk_full_action_set = TRUE,
matching_verbosity_set = FALSE,
logger_plugins_set = FALSE,
plugin_specific_set = FALSE;
int execute_list_len = 0;
execute_list_item *execute_list = NULL;
string_map_t *config_defines;
%}
%union{
char *str_val;
int_val_t *int_val;
int int_native;
unsigned int uint_val;
double float_val;
boolean bool_val;
param_objid_t objid_val;
verdicttype verdict_val;
param_bitstring_t bitstring_val;
param_hexstring_t hexstring_val;
param_charstring_t charstring_val;
param_octetstring_t octetstring_val;
universal_char universal_char_val;
param_universal_charstring_t universal_charstring_val;
Module_Param::operation_type_t param_optype_val;
Vector<Module_Param*>* module_param_list;
Module_Param* module_param_val;
Module_Param_Length_Restriction* module_param_length_restriction;
Vector<char*>* name_vector;
component_id_t comp_id;
execute_list_item execute_item_val;
TTCN_Logger::emergency_logging_behaviour_t emergency_logging_behaviour_value;
TTCN_Logger::timestamp_format_t timestamp_value;
TTCN_Logger::source_info_format_t source_info_value;
TTCN_Logger::log_event_types_t log_event_types_value;
TTCN_Logger::disk_full_action_t disk_full_action_value;
TTCN_Logger::matching_verbosity_t matching_verbosity_value;
TTCN_Logger::Severity logseverity_val;
Logging_Bits logoptions_val;
logging_plugin_t *logging_plugins;
logging_param_t logging_params;
logging_setting_t logging_param_line;
struct {
size_t nElements;
const char **elements;
} uid_list;
}
%token ModuleParametersKeyword
%token LoggingKeyword
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
%token TestportParametersKeyword
%token ExecuteKeyword
%token ExternalCommandsKeyword
%token GroupsKeyword
%token ComponentsKeyword
%token MainControllerKeyword
%token IncludeKeyword
%token DefineKeyword
%token Detailed
%token Compact
%token ObjIdKeyword "objid"
%token CharKeyword "char"
%token ControlKeyword "control"
%token MTCKeyword "mtc"
%token SystemKeyword "system"
%token NULLKeyword "NULL"
%token nullKeyword "null"
%token OmitKeyword "omit"
%token ComplementKeyword "complement"
%token DotDot ".."
%token SupersetKeyword "superset"
%token SubsetKeyword "subset"
%token PatternKeyword "pattern"
%token PermutationKeyword "permutation"
%token LengthKeyword "length"
%token IfpresentKeyword "ifpresent"
%token InfinityKeyword "infinity"
%token AssignmentChar ":= or ="
%token ConcatChar "&="
%token LogFile "LogFile or FileName"
%token EmergencyLogging
%token EmergencyLoggingBehaviour
%token EmergencyLoggingMask
%token BufferAll
%token BufferMasked
%token FileMask
%token ConsoleMask
%token TimestampFormat
%token ConsoleTimestampFormat
%token SourceInfoFormat "LogSourceInfo or SourceInfoFormat"
%token AppendFile
%token LogEventTypes
%token LogEntityName
%token BeginControlPart
%token EndControlPart
%token BeginTestCase
%token EndTestCase
%token <str_val> Identifier
%token <str_val> ASN1LowerIdentifier "ASN.1 identifier beginning with a lowercase letter"
%token <int_val> Number MPNumber "integer value"
%token <float_val> Float MPFloat "float value"
%token <bool_val> BooleanValue "true or false"
%token <verdict_val> VerdictValue
%token <bitstring_val> Bstring "bit string value"
%token <hexstring_val> Hstring "hex string value"
%token <octetstring_val> Ostring "octet string value"
%token <str_val> BstringMatch "bit string template"
%token <str_val> HstringMatch "hex string template"
%token <str_val> OstringMatch "octet string template"
%token <charstring_val> Cstring MPCstring "charstring value"
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
%token DNSName "hostname"
/* a single bit */
%token <logseverity_val> LoggingBit
/* a collection of bits */
%token <logseverity_val> LoggingBitCollection
%token SubCategories
%token <emergency_logging_behaviour_value> EmergencyLoggingBehaviourValue "BufferAll or BufferMasked"
%token <timestamp_value> TimestampValue "Time, Datetime or Seconds"
%token <source_info_value> SourceInfoValue "None, Single or Stack"
%token <bool_val> YesNo "yes or no"
%token LocalAddress
%token TCPPort
%token KillTimer
%token NumHCs
%token UnixSocketEnabled
%token YesToken "yes"
%token NoToken "no"
%token LogFileSize
%token LogFileNumber
%token DiskFullAction
%token MatchingHints
%token LoggerPlugins
%token Error
%token Stop
%token Retry
%token Delete
%token TtcnStringParsingKeyword
%token DisableProfilerKeyword "DisableProfiler"
%token DisableCoverageKeyword "DisableCoverage"
%token DatabaseFileKeyword "DatabaseFile"
%token AggregateDataKeyword "AggregateData"
%token StatisticsFileKeyword "StatisticsFile"
%token DisableStatisticsKeyword "DisableStatistics"
%token StatisticsFilterKeyword "StatisticsFilter"
%token StartAutomaticallyKeyword "StartAutomatically"
%token NetLineTimesKeyword "NetLineTimes"
%token NetFunctionTimesKeyword "NetFunctionTimes"
%token <uint_val> ProfilerStatsFlag "profiler statistics filter"
%type <int_val> IntegerValue
%type <float_val> FloatValue
%type <objid_val> ObjIdValue ObjIdComponentList
%type <int_val> ObjIdComponent NumberForm NameAndNumberForm
%type <universal_charstring_val> UniversalCharstringValue UniversalCharstringFragment
%type <uid_list> USI UIDlike
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
%type <str_val> LoggerPluginId
%type <logging_plugins> LoggerPlugin LoggerPluginList
%type <logging_params> LoggingParam
%type <logging_param_line> LoggingParamLines
%type <str_val> LogFileName StringValue
/* a collection of bits */
%type <logoptions_val> LoggingBitmask
%type <logoptions_val> LoggingBitOrCollection
%type <source_info_value> SourceInfoSetting
%type <bool_val> YesNoOrBoolean
%type <log_event_types_value> LogEventTypesValue
%type <disk_full_action_value> DiskFullActionValue
%type <str_val> Command
%type <matching_verbosity_value> VerbosityValue
%type <comp_id> ComponentId
%type <str_val> TestportName ArrayRef TestportParameterName
TestportParameterValue
%type <execute_item_val> ExecuteItem
%type <bitstring_val> BitstringValue
%type <hexstring_val> HexstringValue
%type <octetstring_val> OctetstringValue
%type <name_vector> ParameterName ParameterNameSegment
%type <param_optype_val> ParamOpType
%type <str_val> FieldName
%type <module_param_val> ParameterValue SimpleParameterValue ParameterValueOrNotUsedSymbol
FieldValue ArrayItem IndexItem IndexItemList FieldValueList ArrayItemList CompoundValue IntegerRange FloatRange StringRange
%type <module_param_list> TemplateItemList
%type <module_param_length_restriction> LengthMatch
%type <int_native> IndexItemIndex LengthBound
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
%destructor { Free($$); }
ArrayRef
ASN1LowerIdentifier
Command
FieldName
Identifier
LogFileName
StringValue
TestportName
TestportParameterName
TestportParameterValue
PatternChunk
BstringMatch
HstringMatch
OstringMatch
%destructor { Free($$.components_ptr); }
ObjIdComponentList
ObjIdValue
%destructor { Free($$.bits_ptr); }
Bstring
BitstringValue
%destructor { Free($$.nibbles_ptr); }
Hstring
HexstringValue
%destructor { Free($$.octets_ptr); }
Ostring
OctetstringValue
%destructor { Free($$.chars_ptr); }
Cstring
UniversalCharstringFragment
UniversalCharstringValue
%destructor { if ($$.id_selector == COMPONENT_ID_NAME) Free($$.id_name); }
ComponentId
%destructor { Free($$.module_name); Free($$.testcase_name); }
ExecuteItem
%destructor { delete $$; }
IntegerValue
NameAndNumberForm
Number
NumberForm
ObjIdComponent
ParameterValue
SimpleParameterValue
ParameterValueOrNotUsedSymbol
ArrayItemList
FieldValueList
IndexItemList
CompoundValue
ArrayItem
FieldValue
IndexItem
IntegerRange
FloatRange
StringRange
%destructor { delete $$; }
LengthMatch
%destructor { for(size_t i=0; i<$$->size(); i++) { delete $$->at(i); } delete $$; }
TemplateItemList
%destructor { for(size_t i=0; i<$$->size(); i++) { Free($$->at(i)); } delete $$; }
ParameterName
ParameterNameSegment
%left '+' '-'
%left '*' '/'
%left UnarySign
1 conflict:
When seeing a '*' token after a module parameter expression the parser cannot
decide whether the token is a multiplication operator (shift) or it refers to
all modules in the next module parameter (reduce).
*/
%%
GrammarRoot:
ConfigFile
{
if (Ttcn_String_Parsing::happening()) {
config_process_error("Config file cannot be parsed as ttcn string");
}
}
| TtcnStringParsingKeyword ParameterValue
{
parsed_module_param = $2;
}
;
ConfigFile:
/* empty */
| ConfigFile Section
;
Section:
ModuleParametersSection
| LoggingSection
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
| TestportParametersSection
| ExecuteSection
| ExternalCommandsSection
| GroupsSection
| ComponentsSection
| MainControllerSection
| IncludeSection
| DefineSection
;
ModuleParametersSection:
ModuleParametersKeyword ModuleParameters
;
ModuleParameters:
/* empty */
| ModuleParameters ModuleParameter optSemiColon
;
ModuleParameter:
ParameterName ParamOpType ParameterValue
{
Module_Param* mp = $3;
mp->set_id(new Module_Param_Name(*$1));
mp->set_operation_type($2);
set_param(*mp);
delete mp;
delete $1;
}
;
ParameterName:
ParameterNameSegment { $$ = $1; }
| '*' '.' ParameterNameSegment { $$ = $3; }
;
ParameterNameSegment:
ParameterNameSegment '.' Identifier
{
$$ = $1;
$$->push_back($3);
}
}
| Identifier
{
$$ = new Vector<char*>();
$$->push_back($1);
}
;
ParameterValue:
{
$$ = $1;
$$->set_length_restriction($2);
}
{
$$ = $1;
$$->set_ifpresent();
}
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
{
$$ = $1;
$$->set_length_restriction($2);
$$->set_ifpresent();
}
;
LengthMatch:
LengthKeyword '(' LengthBound ')'
{
$$ = new Module_Param_Length_Restriction();
$$->set_single((size_t)$3);
}
| LengthKeyword '(' LengthBound DotDot LengthBound ')'
{
if ($3>$5) {
config_process_error("invalid length restriction: lower bound > upper bound");
}
$$ = new Module_Param_Length_Restriction();
$$->set_min((size_t)$3);
$$->set_max((size_t)$5);
}
| LengthKeyword '(' LengthBound DotDot InfinityKeyword ')'
{
$$ = new Module_Param_Length_Restriction();
$$->set_min((size_t)$3);
}
;
LengthBound:
$1->set_id(new Module_Param_CustomName(mcopystr("length bound")));
INTEGER tmp;
tmp.set_param(*$1);
if (!tmp.get_val().is_native()) {
config_process_error("bignum length restriction bound.");
$$ = 0;
config_process_error("negative length restriction bound.");
$$ = 0;
} else {
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
// one global rule for expressions in module parameters
// the expression's result will be calculated by set_param()
ParameterExpression:
SimpleParameterValue { $$ = $1; }
| ParameterReference { $$ = $1; }
| '(' ParameterExpression ')' { $$ = $2; }
| '+' ParameterExpression %prec UnarySign { $$ = $2; }
| '-' ParameterExpression %prec UnarySign { $$ = new Module_Param_Expression($2); }
| ParameterExpression '+' ParameterExpression
{
$$ = new Module_Param_Expression(Module_Param::EXPR_ADD, $1, $3);
}
| ParameterExpression '-' ParameterExpression
{
$$ = new Module_Param_Expression(Module_Param::EXPR_SUBTRACT, $1, $3);
}
| ParameterExpression '*' ParameterExpression
{
$$ = new Module_Param_Expression(Module_Param::EXPR_MULTIPLY, $1, $3);
}
| ParameterExpression '/' ParameterExpression
{
$$ = new Module_Param_Expression(Module_Param::EXPR_DIVIDE, $1, $3);
}
| ParameterExpression '&' ParameterExpression
{
$$ = new Module_Param_Expression(Module_Param::EXPR_CONCATENATE, $1, $3);
}
;
ParameterReference:
// enumerated values are also treated as references by the parser,
// these will be sorted out later during set_param()
ParameterNameSegment
{
$$ = new Module_Param_Reference(new Module_Param_Name(*$1));
}
;
{
$$ = new Module_Param_Integer($1);
}
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
{
$$ = new Module_Param_Float($1);
}
| BooleanValue
{
$$ = new Module_Param_Boolean($1);
}
| ObjIdValue
{
$$ = new Module_Param_Objid($1.n_components, $1.components_ptr);
}
| VerdictValue
{
$$ = new Module_Param_Verdict($1);
}
| BitstringValue
{
$$ = new Module_Param_Bitstring($1.n_bits, $1.bits_ptr);
}
| HexstringValue
{
$$ = new Module_Param_Hexstring($1.n_nibbles, $1.nibbles_ptr);
}
| OctetstringValue
{
$$ = new Module_Param_Octetstring($1.n_octets, $1.octets_ptr);
}
{
$$ = new Module_Param_Charstring($1.n_chars, $1.chars_ptr);
}
| UniversalCharstringValue
{
$$ = new Module_Param_Universal_Charstring($1.n_uchars, $1.uchars_ptr);
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
}
| OmitKeyword
{
$$ = new Module_Param_Omit();
}
| NULLKeyword
{
$$ = new Module_Param_Asn_Null();
}
| nullKeyword
{
$$ = new Module_Param_Ttcn_Null();
}
| MTCKeyword
{
$$ = new Module_Param_Ttcn_mtc();
}
| SystemKeyword
{
$$ = new Module_Param_Ttcn_system();
}
| '?'
{
$$ = new Module_Param_Any();
}
| '*'
{
$$ = new Module_Param_AnyOrNone();
}
| IntegerRange
{
$$ = $1;
}
| FloatRange
{
$$ = $1;
}
| StringRange
{
$$ = $1;
}
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
{
$$ = new Module_Param_Pattern($2);
}
| BstringMatch
{
// conversion
int n_chars = (int)mstrlen($1);
unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
for (int i=0; i<n_chars; i++) {
switch ($1[i]) {
case '0':
chars_ptr[i] = 0;
break;
case '1':
chars_ptr[i] = 1;
break;
case '?':
chars_ptr[i] = 2;
break;
case '*':
chars_ptr[i] = 3;
break;
default:
chars_ptr[i] = 0;
config_process_error_f("Invalid char (%c) in bitstring template", $1[i]);
}
}
Free($1);
$$ = new Module_Param_Bitstring_Template(n_chars, chars_ptr);
}
| HstringMatch
{
int n_chars = (int)mstrlen($1);
unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
for (int i=0; i<n_chars; i++) {
if ($1[i]=='?') chars_ptr[i] = 16;
else if ($1[i]=='*') chars_ptr[i] = 17;
else chars_ptr[i] = char_to_hexdigit($1[i]);
}
Free($1);
$$ = new Module_Param_Hexstring_Template(n_chars, chars_ptr);
}
| OstringMatch
{
Vector<unsigned short> octet_vec;
int str_len = (int)mstrlen($1);
for (int i=0; i<str_len; i++) {
unsigned short num;
if ($1[i]=='?') num = 256;
else if ($1[i]=='*') num = 257;
else {
// first digit
num = 16 * char_to_hexdigit($1[i]);
i++;
if (i>=str_len) config_process_error("Unexpected end of octetstring pattern");
// second digit
num += char_to_hexdigit($1[i]);
}
octet_vec.push_back(num);
}
Free($1);
int n_chars = (int)octet_vec.size();
unsigned short* chars_ptr = (unsigned short*)Malloc(n_chars*sizeof(unsigned short));
for (int i=0; i<n_chars; i++) chars_ptr[i] = octet_vec[i];
$$ = new Module_Param_Octetstring_Template(n_chars, chars_ptr);
}
| CompoundValue
{
$$ = $1;
}
;
PatternChunk:
{
$$ = mcopystr($1.chars_ptr);
Free($1.chars_ptr);
}
| Quadruple
{
$$ = mprintf("\\q{%d,%d,%d,%d}", $1.uc_group, $1.uc_plane, $1.uc_row, $1.uc_cell);
}
;
IntegerRange:
{
$$ = new Module_Param_IntRange(NULL, $5);
}
{
$$ = new Module_Param_IntRange($2, $4);
}
{
$$ = new Module_Param_IntRange($2, NULL);
}
;
FloatRange:
{
$$ = new Module_Param_FloatRange(0.0, false, $5, true);
}
{
$$ = new Module_Param_FloatRange($2, true, $4, true);
}
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
{
$$ = new Module_Param_FloatRange($2, true, 0.0, false);
}
;
StringRange:
'(' UniversalCharstringFragment DotDot UniversalCharstringFragment ')'
{
universal_char lower; lower.uc_group=lower.uc_plane=lower.uc_row=lower.uc_cell=0;
universal_char upper; upper.uc_group=upper.uc_plane=upper.uc_row=upper.uc_cell=0;
if ($2.n_uchars!=1) {
config_process_error("Lower bound of char range must be 1 character only");
} else if ($4.n_uchars!=1) {
config_process_error("Upper bound of char range must be 1 character only");
} else {
lower = *($2.uchars_ptr);
upper = *($4.uchars_ptr);
if (upper<lower) {
config_process_error("Lower bound is larger than upper bound in the char range");
lower = upper;
}
}
Free($2.uchars_ptr);
Free($4.uchars_ptr);
$$ = new Module_Param_StringRange(lower, upper);
}
;
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
IntegerValue:
Number { $$ = $1; }
| '(' IntegerValue ')' { $$ = $2; }
| '+' IntegerValue %prec UnarySign { $$ = $2; }
| '-' IntegerValue %prec UnarySign
{
INTEGER op1;
op1.set_val(*$2);
$$ = new int_val_t((-op1).get_val());
delete $2;
}
| IntegerValue '+' IntegerValue
{
INTEGER op1, op2;
op1.set_val(*$1);
op2.set_val(*$3);
$$ = new int_val_t((op1 + op2).get_val());
delete $1;
delete $3;
}
| IntegerValue '-' IntegerValue
{
INTEGER op1, op2;
op1.set_val(*$1);
op2.set_val(*$3);
$$ = new int_val_t((op1 - op2).get_val());
delete $1;
delete $3;
}
| IntegerValue '*' IntegerValue
{
INTEGER op1, op2;
op1.set_val(*$1);
op2.set_val(*$3);
$$ = new int_val_t((op1 * op2).get_val());
delete $1;
delete $3;
}
| IntegerValue '/' IntegerValue
{
if (*$3 == 0) {
config_process_error("Integer division by zero.");
$$ = new int_val_t((RInt)0);
delete $1;
delete $3;
} else {
INTEGER op1, op2;
op1.set_val(*$1);
op2.set_val(*$3);
$$ = new int_val_t((op1 / op2).get_val());
delete $1;
delete $3;
}
}
;
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
FloatValue:
Float { $$ = $1; }
| '(' FloatValue ')' { $$ = $2; }
| '+' FloatValue %prec UnarySign { $$ = $2; }
| '-' FloatValue %prec UnarySign { $$ = -$2; }
| FloatValue '+' FloatValue { $$ = $1 + $3; }
| FloatValue '-' FloatValue { $$ = $1 - $3; }
| FloatValue '*' FloatValue { $$ = $1 * $3; }
| FloatValue '/' FloatValue
{
if ($3 == 0.0) {
config_process_error("Floating point division by zero.");
$$ = 0.0;
} else $$ = $1 / $3;
}
;
ObjIdValue:
ObjIdKeyword '{' ObjIdComponentList '}' { $$ = $3; }
;
ObjIdComponentList:
ObjIdComponent
{
$$.n_components = 1;
$$.components_ptr = (int *)Malloc(sizeof(int));
$$.components_ptr[0] = $1->get_val();
delete $1;
}
| ObjIdComponentList ObjIdComponent
{
$$.n_components = $1.n_components + 1;
$$.components_ptr = (int *)Realloc($1.components_ptr,
$$.n_components * sizeof(int));
$$.components_ptr[$$.n_components - 1] = $2->get_val();
delete $2;
}
;
ObjIdComponent:
NumberForm { $$ = $1; }
| NameAndNumberForm { $$ = $1; }
;
NumberForm:
{
Free($1);
$$ = $3;
}
;
BitstringValue:
{
$$.n_uchars = 1;
$$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
$$.uchars_ptr[0] = $1;
}
| USI
{
$$.n_uchars = $1.nElements;
$$.uchars_ptr = (universal_char*)Malloc($$.n_uchars * sizeof(universal_char));
for (int i = 0; i < $$.n_uchars; ++i) {
size_t offset = 1; //Always starts with u or U
offset = $1.elements[i][1] == '+' ? offset + 1 : offset; //Optional '+'
char* p;
unsigned long int_val = strtoul($1.elements[i] + offset, &p, 16);
if(*p != 0) {
//Error, should not happen
config_process_error_f("Invalid hexadecimal string %s.", $1.elements[i] + offset);
}
//Fill in the quadruple
$$.uchars_ptr[i].uc_group = (int_val >> 24) & 0xFF;
$$.uchars_ptr[i].uc_plane = (int_val >> 16) & 0xFF;
$$.uchars_ptr[i].uc_row = (int_val >> 8) & 0xFF;
$$.uchars_ptr[i].uc_cell = int_val & 0xFF;
Free((char*)$1.elements[i]);
}
Free($1.elements);
}
;
UniversalCharstringFragment:
{
$$.n_uchars = $1.n_chars;
$$.uchars_ptr = (universal_char*)
Malloc($$.n_uchars * sizeof(universal_char));
for (int i = 0; i < $1.n_chars; i++) {
$$.uchars_ptr[i].uc_group = 0;
$$.uchars_ptr[i].uc_plane = 0;
$$.uchars_ptr[i].uc_row = 0;
$$.uchars_ptr[i].uc_cell = $1.chars_ptr[i];
}
Free($1.chars_ptr);
}
| Quadruple
{
$$.n_uchars = 1;
$$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
$$.uchars_ptr[0] = $1;
}
;
Quadruple:
CharKeyword '(' ParameterExpression ',' ParameterExpression ','
ParameterExpression ',' ParameterExpression ')'
$3->set_id(new Module_Param_CustomName(mcopystr("quadruple group")));
$5->set_id(new Module_Param_CustomName(mcopystr("quadruple plane")));
$7->set_id(new Module_Param_CustomName(mcopystr("quadruple row")));
$9->set_id(new Module_Param_CustomName(mcopystr("quadruple cell")));
INTEGER g, p, r, c;
g.set_param(*$3);
p.set_param(*$5);
r.set_param(*$7);
c.set_param(*$9);
if (g < 0 || g > 127) {
char *s = g.get_val().as_string();
config_process_error_f("The first number of quadruple (group) must be "
"within the range 0 .. 127 instead of %s.", s);
Free(s);
if (p < 0 || p > 255) {
char *s = p.get_val().as_string();