Last sync 2016.04.01
[deliverable/titan.core.git] / mctr2 / cli / config_read.l
CommitLineData
970ed795 1/******************************************************************************
d44e3c4f 2 * Copyright (c) 2000-2016 Ericsson Telecom AB
970ed795
EL
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
d44e3c4f 7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Baranyi, Botond
11 * Beres, Szabolcs
12 * Delic, Adam
13 * Forstner, Matyas
14 * Gecse, Roland
15 * Kovacs, Ferenc
16 * Pandi, Krisztian
17 * Raduly, Csaba
18 * Szabados, Kristof
19 * Szabo, Janos Zoltan – initial implementation
20 * Szalai, Gabor
21 * Zalanyi, Balazs Andor
22 *
970ed795
EL
23 ******************************************************************************/
24%option yylineno
25%option noyywrap
26%option never-interactive
27%option nounput
28
29%{
30
31#include <string.h>
32#include <ctype.h>
33#include <stdlib.h>
34
35#include <deque>
36#include <string>
37
38#include <openssl/crypto.h>
39#include <openssl/bn.h>
40
41#include "../../common/cfg_process_utils.hh"
42#include "../../common/Path2.hh"
43#include "../../common/config_preproc.h"
44
45#include "../../common/memory.h"
46#include "../mctr/config_data.h"
47#include "../../core/Types.h"
48#include "config_read.tab.hh"
49
50//#include "../../common/dbgnew.hh"
51
52extern string_map_t *config_defines;
53
54#define yylval config_read_lval
55
56/* This buffer stores the state of the main buffer
57 while the macro expansion is happening. */
58static YY_BUFFER_STATE main_buffer = NULL;
59/* This buffer is active while the expansion of
60 a reference to a structured macro definition is happening.
61 Otherwise its value is NULL. */
62static YY_BUFFER_STATE expansion_buffer = NULL;
63
64static void update_buffer();
65static boolean whether_update_buffer();
66
67#define RETURN(x) do {update_buffer(); return (x);} while(0)
68
69void config_read_warning(const char *warning_str, ...);
70extern void config_read_error(const char *error_str, ...);
71extern config_data *cfg;
72
73static std::deque<IncludeElem<YY_BUFFER_STATE> >* include_chain = NULL;
74
75std::string get_cfg_read_current_file() {
76 if (include_chain && !include_chain->empty()) {
77 return include_chain->back().get_full_path();
78 }
79 return std::string();
80}
81
82%}
83
84WHITESPACE [ \t]
85WS {WHITESPACE}*
86NEWLINE \r|\n|\r\n
87LINECOMMENT ("//"|"#")[^\r\n]*{NEWLINE}
88
89NUMBER 0|([1-9][0-9]*)
90
91FLOAT [+-]?({NUMBER}\.[0-9]+)|((({NUMBER}(\.[0-9]+)?)|(\.[0-9]+))[Ee][+-]?{NUMBER})
92
93BIN 0|1
94BITSTRING '{BIN}*'B
95BINMATCH 0|1|\?|\*
96BITSTRINGMATCH '{BINMATCH}*'B
97BITSTRING_BAD '[^']*'B
98
99HEX [0-9A-Fa-f]
100HEXSTRING '{HEX}*'H
101HEXMATCH [0-9A-Fa-f\?\*]
102HEXSTRINGMATCH '{HEXMATCH}*'H
103HEXSTRING_BAD '[^']*'H
104
105OCT {HEX}{HEX}
106OCTETSTRING '{OCT}*'O
107OCTMATCH {HEX}{HEX}|\?|\*
108OCTETSTRINGMATCH '{OCTMATCH}*'O
109OCTETSTRING_BAD '[^']*'O
110
111BINSTRING_BAD '[^']*'
112
113TTCN3IDENTIFIER [A-Za-z][A-Za-z0-9_]*
114ASN1LOWERIDENTIFIER [a-z](-?[A-Za-z0-9]+)*
115
116MACRORVALUE ([0-9A-Za-z._-]+)|{IPV6}
117MACRO_CSTR \${TTCN3IDENTIFIER}|\$"{"{WS}{TTCN3IDENTIFIER}{WS}(","{WS}charstring{WS})?"}"
118MACRO_BOOL \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}boolean{WS}"}"
119MACRO_FLOAT \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}float{WS}"}"
120MACRO_ID \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}identifier{WS}"}"
121MACRO_INT \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}integer{WS}"}"
122MACRO_BSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}bitstring{WS}"}"
123MACRO_HSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}hexstring{WS}"}"
124MACRO_OSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}octetstring{WS}"}"
125MACRO_BINARY \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}binaryoctet{WS}"}"
126MACRO_HOSTNAME \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}hostname{WS}"}"
127
128CHAR [^\\\"]|\\([\\\'\"\?abfnrtv]|{NEWLINE}|[0-7]{1,3}|x{HEX}{1,2})|\"\"
129CHARSTRING \"{CHAR}*\"
130
131HOSTNAME [A-Za-z0-9]([A-Za-z0-9_\-]*[A-Za-z0-9])?
132DNSNAME {HOSTNAME}(\.{HOSTNAME})*\.?
133
134/* Example: fe80::c002:37ff:fe6c:0%fastethernet0/0 */
135IPV6 [0-9A-Fa-f:.]+(%[0-9A-Za-z]+)?
136
137
138%x SC_blockcomment SC_DEFINE SC_CSTRING SC_ORDERED_INCLUDE
139%s SC_MODULE_PARAMETERS SC_LOGGING SC_TESTPORT_PARAMETERS SC_EXECUTE SC_GROUPS
af710487 140%s SC_COMPONENTS SC_EXTERNAL_COMMANDS SC_MAIN_CONTROLLER SC_INCLUDE SC_PROFILER
970ed795
EL
141
142%%
143 int comment_caller = INITIAL;
144
145 std::string cstring;
146
147 /* Eat up comments and whitespaces */
148
149"/*" {
150 comment_caller = YY_START;
151 BEGIN(SC_blockcomment);
152 }
153<SC_blockcomment>
154{
155"*/" BEGIN(comment_caller);
156.|\n
157}
158
159{LINECOMMENT}|{WHITESPACE}|{NEWLINE}
160
161 /* Section delimiters */
162
163<*>"["{WS}MODULE_PARAMETERS{WS}"]" {
164 if (YY_START!=SC_blockcomment) {
165 BEGIN(SC_MODULE_PARAMETERS);
166 RETURN(ModuleParametersKeyword);
167 }
168}
169
170<*>"["{WS}LOGGING{WS}"]" {
171 if (YY_START!=SC_blockcomment) {
172 BEGIN(SC_LOGGING);
173 RETURN(LoggingKeyword);
174 }
175}
176
af710487 177<*>"["{WS}PROFILER{WS}"]" {
178 if (YY_START!=SC_blockcomment) {
179 BEGIN(SC_PROFILER);
180 RETURN(ProfilerKeyword);
181 }
182}
183
970ed795
EL
184<*>"["{WS}TESTPORT_PARAMETERS{WS}"]" {
185 if (YY_START!=SC_blockcomment) {
186 BEGIN(SC_TESTPORT_PARAMETERS);
187 RETURN(TestportParametersKeyword);
188 }
189}
190
191<*>"["{WS}EXECUTE{WS}"]" {
192 if (YY_START!=SC_blockcomment) {
193 BEGIN(SC_EXECUTE);
194 RETURN(ExecuteKeyword);
195 }
196}
197
198<*>"["{WS}EXTERNAL_COMMANDS{WS}"]" {
199 if (YY_START!=SC_blockcomment) {
200 BEGIN(SC_EXTERNAL_COMMANDS);
201 RETURN(ExternalCommandsKeyword);
202 }
203}
204
205<*>"["{WS}GROUPS{WS}"]" {
206 if (YY_START!=SC_blockcomment) {
207 BEGIN(SC_GROUPS);
208 RETURN(GroupsKeyword);
209 }
210}
211
212<*>"["{WS}COMPONENTS{WS}"]" {
213 if (YY_START!=SC_blockcomment) {
214 BEGIN(SC_COMPONENTS);
215 RETURN(ComponentsKeyword);
216 }
217}
218
219<*>"["{WS}MAIN_CONTROLLER{WS}"]" {
220 if (YY_START!=SC_blockcomment) {
221 BEGIN(SC_MAIN_CONTROLLER);
222 RETURN(MainControllerKeyword);
223 }
224}
225
226<*>"["{WS}INCLUDE{WS}"]" {
227 if (YY_START!=SC_blockcomment) {
228 BEGIN(SC_INCLUDE);
229 RETURN(IncludeKeyword);
230 }
231}
232
233<*>"["{WS}ORDERED_INCLUDE{WS}"]" {
234 if (YY_START!=SC_blockcomment) {
235 BEGIN(SC_ORDERED_INCLUDE);
236 }
237}
238
239
240<*>"["{WS}DEFINE{WS}"]" {
241 if (YY_START!=SC_blockcomment) {
242 BEGIN(SC_DEFINE);
243 RETURN(DefineKeyword);
244 }
245}
246
247 /* Rules for SC_DEFINE must precede everything else */
248
249<SC_DEFINE>{
250
251"/*" {
252 comment_caller = SC_DEFINE;
253 BEGIN(SC_blockcomment);
254}
255
256{CHARSTRING} /* eats string */
257
258{LINECOMMENT}
259
260{NEWLINE} /* this is not in . */
261
262\\\"
263
264. /* eats unnecessary things */
265
266}
267
268<SC_ORDERED_INCLUDE>{
269
270"/*" {
271 comment_caller = YY_START;
272 BEGIN(SC_blockcomment);
273 }
274
275\" { BEGIN(SC_CSTRING); }
276
277{LINECOMMENT}
278
279{NEWLINE} /* this is not in . */
280
281\\\"
282
283. /* eat unnecessary chars */
284
285}
286
287
288<SC_CSTRING>{
289
290\"\" cstring += '"';
291
292\" {
293 std::string error_msg = switch_lexer(include_chain, cstring,
294 YY_CURRENT_BUFFER, yy_create_buffer, yy_switch_to_buffer, yylineno,
295 YY_BUF_SIZE);
296 if (error_msg.empty()) {
297 BEGIN(INITIAL);
298 } else {
299 config_read_error(error_msg.c_str());
300 }
301
302 cstring.clear();
303} /* end of string */
304
305\\[\\'"?] cstring += yytext[1]; /* backslash-quoted \ or " or ' or ? */
306\\{NEWLINE} yylineno++;
307\\a cstring += '\a';
308\\b cstring += '\b';
309\\f cstring += '\f';
310\\n cstring += '\n';
311\\r cstring += '\r';
312\\t cstring += '\t';
313\\v cstring += '\v';
314
315\\[0-7]{1,3} {
316 unsigned int c;
317 sscanf(yytext + 1, "%o", &c);
318 if (c <= 255) cstring += c;
319 else config_read_error("Invalid octal character code in string literal");
320}
321
322\\x{HEX}{1,2} {
323 unsigned int c;
324 sscanf(yytext + 2, "%x", &c);
325 cstring += c;
326}
327
328\\(x[^\\\"]|.) config_read_error("Invalid excape sequence in string literal.");
329
330{NEWLINE} {
331 cstring.append(yytext, yyleng);
332 yylineno++;
333}
334
335. {
336 cstring += yytext[0];
337}
338}
339 /* SC_cstring */
340
341
a38c6d4c 342<SC_PROFILER>{HEX}+ {
343 /* numeric statistics filter (check this before checking NUMBERs) */
344 RETURN(ProfilerStatsFlag);
345}
346
347
970ed795
EL
348 /* Values */
349
350{NUMBER} {
351 yylval.int_val = NULL;
352 BN_dec2bn(&yylval.int_val, *yytext == '+' ? yytext + 1 : yytext);
3abe9331 353 if (YY_START == SC_MODULE_PARAMETERS) {
354 RETURN(MPNumber);
355 }
970ed795
EL
356 RETURN(Number);
357}
358
359{FLOAT} {
360 yylval.float_val = atof(yytext);
3abe9331 361 if (YY_START == SC_MODULE_PARAMETERS) {
362 RETURN(MPFloat);
363 }
970ed795
EL
364 RETURN(Float);
365}
366
367{BITSTRING} RETURN(Bstring);
368
369{BITSTRINGMATCH} RETURN(BstringMatch);
370
371{BITSTRING_BAD} {
372 config_read_error("Invalid bitstring value.");
373 RETURN(Bstring);
374}
375
376{HEXSTRING} RETURN(Hstring);
377
378{HEXSTRINGMATCH} RETURN(HstringMatch);
379
380{HEXSTRING_BAD} {
381 config_read_error("Invalid hexstring value.");
382 RETURN(Hstring);
383}
384
385{OCTETSTRING} RETURN(Ostring);
386
387{OCTETSTRINGMATCH} RETURN(OstringMatch);
388
389{OCTETSTRING_BAD} {
390 config_read_error("Invalid octetstring value.");
391 RETURN(Ostring);
392}
393
394{BINSTRING_BAD} config_read_error("Invalid string value.");
395
396' config_read_error("Unmatched ' character.");
397
398{CHARSTRING} {
399 yylval.str_val = mcopystrn(yytext, yyleng);
3abe9331 400 if (YY_START == SC_MODULE_PARAMETERS) {
401 RETURN(MPCstring);
402 }
970ed795
EL
403 RETURN(Cstring);
404}
405
406 /* Section-wide keywords */
407
408<SC_MODULE_PARAMETERS>
409{
410NULL RETURN(NULLKeyword);
411null RETURN(nullKeyword);
412char RETURN(CharKeyword);
413objid RETURN(ObjIdKeyword);
414omit RETURN(OmitKeyword);
415none |
416pass |
417inconc |
418fail |
419error RETURN(VerdictValue);
420complement RETURN(ComplementKeyword);
421"\.\." RETURN(DotDot);
422superset RETURN(SupersetKeyword);
423subset RETURN(SubsetKeyword);
424pattern RETURN(PatternKeyword);
425permutation RETURN(PermutationKeyword);
426length RETURN(LengthKeyword);
427ifpresent RETURN(IfpresentKeyword);
428infinity RETURN(InfinityKeyword);
429}
430
af710487 431<SC_MODULE_PARAMETERS,SC_LOGGING,SC_PROFILER>
970ed795
EL
432{
433true |
434false RETURN(BooleanValue);
435}
436
437<SC_MODULE_PARAMETERS,SC_LOGGING,SC_TESTPORT_PARAMETERS>
438{
439mtc RETURN(MTCKeyword);
440system RETURN(SystemKeyword);
441}
442
443<SC_LOGGING>
444{
445[Ff]ile[Nn]ame |
446[Ll]og[Ff]ile RETURN(LogFile);
447
448[Ee]mergency[Ll]ogging RETURN(EmergencyLogging);
449
450[Ee]mergency[Ll]ogging[Bb]ehaviour RETURN(EmergencyLoggingBehaviour);
451
452[Bb]uffer[Aa]ll |
453[Bb]uffer[Ma]asked RETURN(EmergencyLoggingBehaviourValue);
454
455[Ee]mergency[Ll]ogging[Mm]ask RETURN(EmergencyLoggingMask);
456
d44e3c4f 457[Ee]mergency[Ll]ogging[Ff]or[Ff]ail[Vv]erdict RETURN(EmergencyLoggingForFailVerdict);
970ed795
EL
458
459[Ff]ile[Mm]ask RETURN(FileMask);
460
461[Cc]onsole[Mm]ask RETURN(ConsoleMask);
462
463[Tt]ime[Ss]tamp[Ff]ormat RETURN(TimestampFormat);
464[Cc]onsole[Tt]ime[Ss]tamp[Ff]ormat RETURN(ConsoleTimestampFormat);
465
466[Ll]og[Ss]ource[Ii]nfo |
467[Ss]ource[Ii]nfo[Ff]ormat RETURN(SourceInfoFormat);
468
469[Aa]ppend[Ff]ile RETURN(AppendFile);
470
471[Ll]og[Ee]vent[Tt]ypes RETURN(LogEventTypes);
472
473[Ll]og[Ee]ntity[Nn]ame RETURN(LogEntityName);
474
475[Ll]og[Ff]ile[Ss]ize RETURN(LogFileSize);
476
477[Ll]og[Ff]ile[Nn]umber RETURN(LogFileNumber);
478
479[Dd]isk[Ff]ull[Aa]ction RETURN(DiskFullAction);
480
481[Mm]atching[Hh]ints RETURN(MatchingHints);
482
483[Ll]ogger[Pp]lugins RETURN(LoggerPlugins);
484
485LOG_NOTHING RETURN(LoggingBit);
486
487(TTCN_)?ACTION |
488(TTCN_)?DEBUG |
489(TTCN_)?DEFAULTOP |
490(TTCN_)?ERROR |
491(TTCN_)?EXECUTOR |
492(TTCN_)?FUNCTION |
493(TTCN_)?MATCHING |
494(TTCN_)?PARALLEL |
495(TTCN_)?PORTEVENT |
496(TTCN_)?STATISTICS |
497(TTCN_)?TESTCASE |
498(TTCN_)?TIMEROP |
499(TTCN_)?USER |
500(TTCN_)?VERDICTOP |
501(TTCN_)?WARNING |
502LOG_ALL RETURN(LoggingBitCollection);
503
504ACTION_UNQUALIFIED |
505DEBUG_ENCDEC |
3f84031e 506DEBUG_FRAMEWORK |
970ed795
EL
507DEBUG_TESTPORT |
508DEBUG_UNQUALIFIED |
3f84031e 509DEBUG_USER |
970ed795
EL
510DEFAULTOP_ACTIVATE |
511DEFAULTOP_DEACTIVATE |
512DEFAULTOP_EXIT |
513DEFAULTOP_UNQUALIFIED |
514ERROR_UNQUALIFIED |
515EXECUTOR_COMPONENT |
516EXECUTOR_CONFIGDATA |
517EXECUTOR_EXTCOMMAND |
518EXECUTOR_LOGOPTIONS |
519EXECUTOR_RUNTIME |
520EXECUTOR_UNQUALIFIED |
521FUNCTION_RND |
522FUNCTION_UNQUALIFIED |
523MATCHING_DONE |
524MATCHING_MCSUCCESS |
525MATCHING_MCUNSUCC |
526MATCHING_MMSUCCESS |
527MATCHING_MMUNSUCC |
528MATCHING_PCSUCCESS |
529MATCHING_PCUNSUCC |
530MATCHING_PMSUCCESS |
531MATCHING_PMUNSUCC |
532MATCHING_PROBLEM |
533MATCHING_TIMEOUT |
534MATCHING_UNQUALIFIED |
535PARALLEL_PORTCONN |
536PARALLEL_PORTMAP |
537PARALLEL_PTC |
538PARALLEL_UNQUALIFIED |
539PORTEVENT_DUALRECV |
540PORTEVENT_DUALSEND |
541PORTEVENT_MCRECV |
542PORTEVENT_MCSEND |
543PORTEVENT_MMRECV |
544PORTEVENT_MMSEND |
545PORTEVENT_MQUEUE |
546PORTEVENT_PCIN |
547PORTEVENT_PCOUT |
548PORTEVENT_PMIN |
549PORTEVENT_PMOUT |
550PORTEVENT_PQUEUE |
551PORTEVENT_STATE |
552PORTEVENT_UNQUALIFIED |
553STATISTICS_UNQUALIFIED |
554STATISTICS_VERDICT |
555TESTCASE_FINISH |
556TESTCASE_START |
557TESTCASE_UNQUALIFIED |
558TIMEROP_GUARD |
559TIMEROP_READ |
560TIMEROP_START |
561TIMEROP_STOP |
562TIMEROP_TIMEOUT |
563TIMEROP_UNQUALIFIED |
564USER_UNQUALIFIED |
565VERDICTOP_FINAL |
566VERDICTOP_GETVERDICT |
567VERDICTOP_SETVERDICT |
568VERDICTOP_UNQUALIFIED |
569WARNING_UNQUALIFIED RETURN(LoggingBit);
570
571[Tt][Ii][Mm][Ee] {yylval.ts_val=TSF_TIME; RETURN(TimestampValue);}
572[Dd][Aa][Tt][Ee][Tt][Ii][Mm][Ee] {yylval.ts_val=TSF_DATE_TIME; RETURN(TimestampValue);}
573[Ss][Ee][Cc][Oo][Nn][Dd][Ss] {yylval.ts_val=TSF_SEC; RETURN(TimestampValue);}
574
575[Nn][Oo][Nn][Ee] |
576[Ss][Ii][Nn][Gg][Ll][Ee] |
577[Ss][Tt][Aa][Cc][Kk] RETURN(SourceInfoValue);
578
579[Yy][Ee][Ss] |
580[Nn][Oo] RETURN(YesNo);
581
582[Dd]etailed RETURN(Detailed);
583[Cc]ompact RETURN(Compact);
584[Ss]ub[Cc]ategories RETURN(SubCategories);
585
586[Ee]rror RETURN(Error);
587
588[Ss]top RETURN(Stop);
589
590[Rr]etry RETURN(Re_try);
591
592[Dd]elete RETURN(Delete);
593}
594
af710487 595<SC_PROFILER>
596{
a38c6d4c 597 [Dd]isable[Pp]rofiler RETURN(DisableProfilerKeyword);
598 [Dd]isable[Cc]overage RETURN(DisableCoverageKeyword);
599 [Dd]ata[Bb]ase[Ff]ile RETURN(DatabaseFileKeyword);
600 [Aa]ggregate[Dd]ata RETURN(AggregateDataKeyword);
601 [Ss]tatistics[Ff]ile RETURN(StatisticsFileKeyword);
602 [Dd]isable[Ss]tatistics RETURN(DisableStatisticsKeyword);
603 [Ss]tatistics[Ff]ilter RETURN(StatisticsFilterKeyword);
604 [Ss]tart[Aa]utomatically RETURN(StartAutomaticallyKeyword);
605 [Nn]et[Ll]ine[Tt]imes RETURN(NetLineTimesKeyword);
606 [Nn]et[Ff]unction[Tt]imes RETURN(NetFunctionTimesKeyword);
607
608 /* statistics filters */
609 [Nn]umber[Oo]f[Ll]ines |
610 [Ll]ine[Dd]ata[Rr]aw |
611 [Ff]unc[Dd]ata[Rr]aw |
612 [Ll]ine[Aa]vg[Rr]aw |
613 [Ff]unc[Aa]vg[Rr]aw |
614 [Ll]ine[Tt]imes[Ss]orted[Bb]y[Mm]od |
615 [Ff]unc[Tt]imes[Ss]orted[Bb]y[Mm]od |
616 [Ll]ine[Tt]imes[Ss]orted[Tt]otal |
617 [Ff]unc[Tt]imes[Ss]orted[Tt]otal |
618 [Ll]ine[Cc]ount[Ss]orted[Bb]y[Mm]od |
619 [Ff]unc[Cc]ount[Ss]orted[Bb]y[Mm]od |
620 [Ll]ine[Cc]ount[Ss]orted[Tt]otal |
621 [Ff]unc[Cc]ount[Ss]orted[Tt]otal |
622 [Ll]ine[Aa]vg[Ss]orted[Bb]y[Mm]od |
623 [Ff]unc[Aa]vg[Ss]orted[Bb]y[Mm]od |
624 [Ll]ine[Aa]vg[Ss]orted[Tt]otal |
625 [Ff]unc[Aa]vg[Ss]orted[Tt]otal |
626 [Tt]op10[Ll]ine[Tt]imes |
627 [Tt]op10[Ff]unc[Tt]imes |
628 [Tt]op10[Ll]ine[Cc]ount |
629 [Tt]op10[Ff]unc[Cc]ount |
630 [Tt]op10[Ll]ine[Aa]vg |
631 [Tt]op10[Ff]unc[Aa]vg |
632 [Uu]nused[Ll]ines |
633 [Uu]nused[Ff]unc |
634 [Aa]ll[Rr]aw[Dd]ata |
635 [Ll]ine[Dd]ata[Ss]orted[Bb]y[Mm]od |
636 [Ff]unc[Dd]ata[Ss]orted[Bb]y[Mm]od |
637 [Ll]ine[Dd]ata[Ss]orted[Tt]otal |
638 [Ff]unc[Dd]ata[Ss]orted[Tt]otal |
639 [Ll]ine[Dd]ata[Ss]orted |
640 [Ff]unc[Dd]ata[Ss]orted |
641 [Aa]ll[Dd]ata[Ss]orted |
642 [Tt]op10[Ll]ine[Dd]ata |
643 [Tt]op10[Ff]unc[Dd]ata |
644 [Tt]op10[Aa]ll[Dd]ata |
645 [Uu]nused[Dd]ata |
646 [Aa]ll RETURN(ProfilerStatsFlag);
af710487 647}
648
970ed795
EL
649<SC_EXECUTE>control RETURN(ControlKeyword);
650
651<SC_EXTERNAL_COMMANDS>
652{
653[Bb]egin[Cc]ontrol[Pp]art RETURN(BeginControlPart);
654[Ee]nd[Cc]ontrol[Pp]art RETURN(EndControlPart);
655[Bb]egin[Tt]est[Cc]ase RETURN(BeginTestCase);
656[Ee]nd[Tt]est[Cc]ase RETURN(EndTestCase);
657}
658
659<SC_MAIN_CONTROLLER>
660{
661[Ll]ocal[Aa]ddress RETURN(LocalAddress);
662[Tt][Cc][Pp][Pp]ort RETURN(TCPPort);
663[Kk]ill[Tt]imer RETURN(KillTimer);
664[Nn]um[Hh][Cc]s RETURN(NumHCs);
665[Uu]nix[Ss]ockets[Ee]nabled RETURN(UnixSocketEnabled);
666[Yy][Ee][Ss] RETURN(YesToken);
667[Nn][Oo] RETURN(NoToken);
668}
669
670{TTCN3IDENTIFIER} {
671 switch (YY_START) {
672 case SC_GROUPS:
673 case SC_COMPONENTS:
674 case SC_EXECUTE:
675 case SC_MAIN_CONTROLLER:
676 yylval.str_val = (char*)Malloc(yyleng + 1);
677 memcpy(yylval.str_val, yytext, yyleng + 1);
678 break;
679 default:
680 yylval.str_val = NULL;
681 }
682 RETURN(Identifier);
683}
684
685<SC_MODULE_PARAMETERS>{ASN1LOWERIDENTIFIER} {
686 char *ttcn3_id = (char*)Malloc(yyleng + 1);
3abe9331 687 for (size_t i = 0; i < yyleng; i++) {
970ed795
EL
688 if (yytext[i] == '-') ttcn3_id[i] = '_';
689 else ttcn3_id[i] = yytext[i];
690 }
691 ttcn3_id[yyleng] = '\0';
692 config_read_warning("`%s' is not a valid TTCN-3 identifier. Did you mean "
693 "`%s'?", yytext, ttcn3_id);
694 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%s ", ttcn3_id);
695 Free(ttcn3_id);
696 return ASN1LowerIdentifier;
697}
698
699<SC_GROUPS,SC_COMPONENTS,SC_MAIN_CONTROLLER>{DNSNAME}|{IPV6} {
700 yylval.str_val = (char*)Malloc(yyleng + 1);
3abe9331 701 for (size_t i = 0; i < yyleng; i++) yylval.str_val[i] = tolower(yytext[i]);
970ed795
EL
702 yylval.str_val[yyleng] = '\0';
703 RETURN(DNSName);
704}
705
706{MACRO_BOOL} {
707 char *macroname = get_macro_id_from_ref(yytext);
708 size_t macrolen;
709 const char *macrovalue =
710 string_map_get_bykey(config_defines, macroname, &macrolen);
711 boolean bool_val;
712 if (macrovalue != NULL) {
713 if (!strcmp(macrovalue, "true")) bool_val = TRUE;
714 else if (!strcmp(macrovalue, "false")) bool_val = FALSE;
715 else {
716 config_read_error("Macro `%s' cannot be interpreted as boolean value: "
717 "`%s'", macroname, macrovalue);
718 bool_val = FALSE;
719 }
720 } else {
721 config_read_error("No macro or environmental variable defined with name "
722 "`%s'", macroname);
723 bool_val = FALSE;
724 }
725 Free(macroname);
726 if (whether_update_buffer()) cfg->config_read_buffer =
727 mputprintf(cfg->config_read_buffer, "%s ", bool_val ? "true" : "false");
728 return BooleanValue;
729}
730
731{MACRO_INT} {
732 char *macroname = get_macro_id_from_ref(yytext);
733 size_t macrolen = 0;
734 BIGNUM *BN_0 = BN_new();
735 BN_set_word(BN_0, 0);
736 const char *macrovalue =
737 string_map_get_bykey(config_defines, macroname, &macrolen);
738 if (macrovalue != NULL) {
739 if (string_is_int(macrovalue, macrolen)) {
740 yylval.int_val = NULL;
741 BN_dec2bn(&yylval.int_val,
742 *macrovalue == '+' ? macrovalue + 1 : macrovalue);
743 } else {
744 config_read_error("Macro `%s' cannot be interpreted as integer value: "
745 "`%s'", macroname, macrovalue);
746 yylval.int_val = BN_dup(BN_0);
747 }
748 } else {
749 config_read_error("No macro or environmental variable defined with name "
750 "`%s'", macroname);
751 yylval.int_val = BN_dup(BN_0);
752 }
753 BN_free(BN_0);
754 Free(macroname);
755 char *int_val_str = BN_bn2dec(yylval.int_val);
756 if (whether_update_buffer())
757 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%s ", int_val_str);
758 OPENSSL_free(int_val_str);
3abe9331 759 if (YY_START == SC_MODULE_PARAMETERS) {
760 return MPNumber;
761 }
970ed795
EL
762 return Number;
763}
764
765{MACRO_FLOAT} {
766 char *macroname = get_macro_id_from_ref(yytext);
767 size_t macrolen;
768 const char *macrovalue =
769 string_map_get_bykey(config_defines, macroname, &macrolen);
770 if (macrovalue != NULL) {
771 if (string_is_float(macrovalue, macrolen))
772 yylval.float_val = atof(macrovalue);
773 else {
774 config_read_error("Macro `%s' cannot be interpreted as float value: "
775 "`%s'", macroname, macrovalue);
776 yylval.float_val = 0.0;
777 }
778 } else {
779 config_read_error("No macro or environmental variable defined"
780 " with name `%s'", macroname);
781 yylval.float_val = 0.0;
782 }
783 Free(macroname);
784 if (whether_update_buffer()) cfg->config_read_buffer =
785 mputprintf(cfg->config_read_buffer, "%f ", yylval.float_val);
3abe9331 786 if (YY_START == SC_MODULE_PARAMETERS) {
787 return MPFloat;
788 }
970ed795
EL
789 return Float;
790}
791
792{MACRO_ID} {
793 char *macroname = get_macro_id_from_ref(yytext);
794 size_t macrolen;
795 const char *macrovalue =
796 string_map_get_bykey(config_defines, macroname, &macrolen);
797 boolean is_asn = FALSE;
798 if (macrovalue != NULL) {
799 if (string_is_id(macrovalue, macrolen)) {
800 yylval.str_val = mcopystr(macrovalue);
801 for (size_t i = 0; i < macrolen; i++) {
802 if (yylval.str_val[i] == '-') {
803 is_asn = TRUE;
804 yylval.str_val[i] = '_';
805 }
806 }
807 if (is_asn) config_read_warning("`%s' is not a valid TTCN-3 identifier. "
808 "Did you mean `%s'?", macrovalue, yylval.str_val);
809 if (whether_update_buffer()) cfg->config_read_buffer =
810 mputprintf(cfg->config_read_buffer, "%s ", yylval.str_val);
811 } else {
812 config_read_error("Macro `%s' cannot be interpreted as identifier: `%s'",
813 macroname, macrovalue);
814 yylval.str_val = NULL;
815 }
816 } else {
817 config_read_error("No macro or environmental variable defined with name "
818 "`%s'", macroname);
819 yylval.str_val = NULL;
820 }
821 Free(macroname);
822 return Identifier;
823}
824
825{MACRO_CSTR} {
826 char *macroname;
827 if (yytext[1] == '{') macroname = get_macro_id_from_ref(yytext);
828 else macroname = mcopystr(yytext + 1);
829 size_t macrolen;
830 const char *macrovalue = string_map_get_bykey
831 (config_defines, macroname, &macrolen);
832 if (macrovalue == NULL) {
833 config_read_error("No macro or environmental variable defined with "
834 "name `%s'", macroname);
835 yylval.str_val = memptystr();
836 Free(macroname);
3abe9331 837 if (YY_START == SC_MODULE_PARAMETERS) {
838 return MPCstring;
839 }
970ed795
EL
840 return Cstring;
841 }
842
843 if (macrolen > 0 && macrovalue[0] == '{') { // structured
844 main_buffer = YY_CURRENT_BUFFER;
845 expansion_buffer = yy_scan_string(macrovalue);
846 yy_switch_to_buffer(expansion_buffer);
847 Free(macroname);
848 } else {
849 if (whether_update_buffer()) {
850 cfg->config_read_buffer=mputc(cfg->config_read_buffer, '"');
851 for (size_t i = 0; i < macrolen; i++) {
852 switch (macrovalue[i]) {
853 case '"':
854 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\\"");
855 break;
856 case '\\':
857 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\\\");
858 break;
859 case '\0':
860 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\000");
861 break;
862 default:
863 cfg->config_read_buffer = mputc(cfg->config_read_buffer, macrovalue[i]);
864 } /* switch */
865 } /* for */
866 cfg->config_read_buffer=mputstr(cfg->config_read_buffer, "\" ");
867 }
868 Free(macroname);
869 yylval.str_val = mcopystr(macrovalue);
3abe9331 870 if (YY_START == SC_MODULE_PARAMETERS) {
871 return MPCstring;
872 }
970ed795
EL
873 return Cstring;
874 }
875}
876
877{MACRO_BSTR} {
878 char *macroname = get_macro_id_from_ref(yytext);
879 size_t macrolen;
880 const char *macrovalue =
881 string_map_get_bykey(config_defines, macroname, &macrolen);
882 if (macrovalue != NULL) {
883 if (string_is_bstr(macrovalue, macrolen)) {
884 if (whether_update_buffer()) cfg->config_read_buffer =
885 mputprintf(cfg->config_read_buffer, "'%s'B ", macrovalue);
886 } else config_read_error("Macro `%s' cannot be interpreted as bitstring "
887 "value: `%s'", macroname, macrovalue);
888 } else config_read_error("No macro or environmental variable defined with "
889 "name `%s'", macroname);
890 Free(macroname);
891 return Bstring;
892}
893
894{MACRO_HSTR} {
895 char *macroname = get_macro_id_from_ref(yytext);
896 size_t macrolen;
897 const char *macrovalue =
898 string_map_get_bykey(config_defines, macroname, &macrolen);
899 if (macrovalue != NULL) {
900 if (string_is_hstr(macrovalue, macrolen)) {
901 if (whether_update_buffer()) cfg->config_read_buffer =
902 mputprintf(cfg->config_read_buffer, "'%s'H ", macrovalue);
903 } else config_read_error("Macro `%s' cannot be interpreted as hexstring "
904 "value: `%s'", macroname, macrovalue);
905 } else config_read_error("No macro or environmental variable defined with "
906 "name `%s'", macroname);
907 Free(macroname);
908 return Hstring;
909}
910
911{MACRO_OSTR} {
912 char *macroname = get_macro_id_from_ref(yytext);
913 size_t macrolen;
914 const char *macrovalue =
915 string_map_get_bykey(config_defines, macroname, &macrolen);
916 if (macrovalue != NULL) {
917 if (string_is_ostr(macrovalue, macrolen)) {
918 if (whether_update_buffer()) cfg->config_read_buffer =
919 mputprintf(cfg->config_read_buffer, "'%s'O ", macrovalue);
920 } else config_read_error("Macro `%s' cannot be interpreted as octetstring "
921 "value: `%s'", macroname, macrovalue);
922 } else config_read_error("No macro or environmental variable defined with "
923 "name `%s'", macroname);
924 Free(macroname);
925 return Ostring;
926}
927
928{MACRO_BINARY} {
929 char *macroname = get_macro_id_from_ref(yytext);
930 size_t macrolen;
931 const char *macrovalue =
932 string_map_get_bykey(config_defines, macroname, &macrolen);
933 if (macrovalue != NULL) {
934 if (whether_update_buffer()) {
935 cfg->config_read_buffer = mputc(cfg->config_read_buffer, '\'');
936 for (size_t i = 0; i < macrolen; i++) {
937 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%02X",
938 macrovalue[i]);
939 }
940 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "'O ");
941 }
942 } else config_read_error("No macro or environmental variable defined with "
943 "name `%s'", macroname);
944 Free(macroname);
945 return Ostring;
946}
947
948{MACRO_HOSTNAME} {
949 char *macroname = get_macro_id_from_ref(yytext);
950 size_t macrolen;
951 const char *macrovalue =
952 string_map_get_bykey(config_defines, macroname, &macrolen);
953 if (macrovalue != NULL) {
954 if (string_is_hostname(macrovalue, macrolen)) {
955 if (whether_update_buffer()) {
956 for (size_t i = 0; i < macrolen; i++) {
957 cfg->config_read_buffer =
958 mputc(cfg->config_read_buffer, tolower(macrovalue[i]));
959 }
960 yylval.str_val = NULL;
961 } else {
962 yylval.str_val = (char*)Malloc(macrolen + 1);
963 for (size_t i = 0; i < macrolen; i++)
964 yylval.str_val[i] = tolower(macrovalue[i]);
965 yylval.str_val[macrolen] = '\0';
966 }
967 } else {
968 config_read_error("Macro `%s' cannot be interpreted as host name: "
969 "`%s'", macroname, macrovalue);
970 yylval.str_val = NULL;
971 }
972 } else {
973 config_read_error("No macro or environmental variable defined with "
974 "name `%s'", macroname);
975 yylval.str_val = NULL;
976 }
977 Free(macroname);
978 return DNSName;
979}
980
981":="|"=" RETURN(AssignmentChar);
982"&=" RETURN(ConcatChar);
983
984. RETURN(yytext[0]);
985
986<*><<EOF>> {
987 if (expansion_buffer) {
988 yy_switch_to_buffer(main_buffer);
989 yy_delete_buffer(expansion_buffer);
990 expansion_buffer = NULL;
991 } else {
992 if (YY_START == SC_blockcomment) {
993 config_read_error("Unterminated block "
994 "comment (missing */ at the end of file).");
995 return EOF;
996 } else {
997 if (include_chain->size() > 1) {
998 yy_delete_buffer(YY_CURRENT_BUFFER);
999 fclose(include_chain->back().fp);
1000 include_chain->pop_back();
1001 yy_switch_to_buffer(include_chain->back().buffer_state);
1002 yylineno = include_chain->back().line_number;
1003 BEGIN(SC_ORDERED_INCLUDE);
1004 } else {
1005 return EOF;
1006 }
1007 }
1008 }
1009}
1010
1011%%
1012
1013static void update_buffer()
1014{
1015 if (whether_update_buffer()) {
1016 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, yytext);
1017 cfg->config_read_buffer = mputc (cfg->config_read_buffer, ' ');
1018 }
1019}
1020
1021static boolean whether_update_buffer()
1022{
1023 switch (YY_START) {
1024 case SC_MODULE_PARAMETERS:
1025 case SC_LOGGING:
1026 case SC_TESTPORT_PARAMETERS:
1027 case SC_EXTERNAL_COMMANDS:
a38c6d4c 1028 case SC_PROFILER:
970ed795
EL
1029 return TRUE;
1030 default:
1031 return FALSE;
1032 } /* switch */
1033}
1034
1035void config_read_reset(const char* current_filename_) {
1036 if (!include_chain) {
1037 include_chain = new std::deque<IncludeElem<YY_BUFFER_STATE> >();
1038 }
1039
1040 include_chain->clear();
1041 include_chain->push_back(
1042 IncludeElem<YY_BUFFER_STATE>(std::string(current_filename_), config_read_in));
1043}
1044
1045void config_read_close() {
1046 delete include_chain;
1047 include_chain = NULL;
1048}
1049
This page took 0.067392 seconds and 5 git commands to generate.