1 module IBAListener;
2 
3 import RuleTranslatorBaseListener;
4 import RuleTranslatorParser: RuleTranslatorParser;
5 import RuleWriter: RuleWriter;
6 import antlr.v4.runtime.ParserRuleContext;
7 import antlr.v4.runtime.tree.ErrorNode;
8 import antlr.v4.runtime.tree.ParseTreeProperty;
9 import antlr.v4.runtime.tree.TerminalNode;
10 import debugMixin;
11 import std.format;
12 import std.json;
13 import std.stdio;
14 
15 alias Result = RuleWriter.Result;
16 
17 /**
18  * This class provides an implementation of {@link RuleTranslatorListener},
19  * which translate a rule in the corresponding XML document for
20  * wave based announcement devices (IBA).
21  */
22 public class IBAListener : RuleTranslatorBaseListener {
23 
24     debug
25     {
26         __gshared short counter;
27         File debugInfo;
28     }
29 
30     public JSONValue ibaConfig;
31 
32     private JSONValue ibaConfigStat;
33 
34     private JSONValue ibaConfigVar;
35 
36     private JSONValue ibaConfigCond;
37 
38     private ushort lastIndent = 0;
39 
40     public RuleWriter writer;
41 
42     private string language;
43 
44     public string[string] functionTemplates;
45 
46     auto ifTests = new ParseTreeProperty!string;
47 
48     struct IfCond {string name; string cond; string value;}
49 
50     auto ifConditions = new ParseTreeProperty!IfCond;
51 
52     auto values = new ParseTreeProperty!(Result[]);
53 
54     private string switchCondition(string ifdef) {
55         if (ifdef == "IFNDEF")
56             return  "IFDEF";
57         else
58             return "IFNDEF";
59     }
60 
61     /**
62      * Begin of generation
63      */
64     override public void enterFile_input(RuleTranslatorParser.File_inputContext ctx) {
65         auto header = `<?xml version='1.0' encoding='UTF-8'?>`;
66         Result[] results;
67         Result result;
68         result.text = header ~ "\n";
69         result.indent = 0;
70         results ~= result;
71         values.put(ctx, results);
72         ibaConfigStat = ibaConfig["stat"];
73         ibaConfigVar = ibaConfig["var"];
74         ibaConfigCond = ibaConfig["condition"];
75         debug {
76             debugInfo = File("/tmp/traceIBA", "w");
77         }
78         mixin(DebugEnter);
79     }
80     /**
81      * End of generation
82      * Collecting results and printing it
83      */
84     override public void exitFile_input(RuleTranslatorParser.File_inputContext ctx) {
85         mixin(DebugExit);
86         debug {
87             debugInfo.write(format("\tvalues --> %s\n", values.get(ctx.ruledef)));
88         }
89         writer.put(values.get(ctx));
90         writer.put(values.get(ctx.rule_setting));
91         writer.put(values.get(ctx.ruledef));
92         writer.put("    </ANSAGE>\n</PAKET>\n");
93         writer.print;
94         writer.clear;
95         debug
96             debugInfo.close;
97     }
98     /**
99      * {@inheritDoc}
100      *
101      * <p>The default implementation does nothing.</p>
102      */
103     override public void enterRuledef(RuleTranslatorParser.RuledefContext ctx) {
104         lastIndent = 2; // start value
105         Result[] results;
106         Result result;
107         result.text = "\n";
108         result.indent = lastIndent;
109         results ~= result;
110         values.put(ctx, results);
111     }
112     /**
113      * {@inheritDoc}
114      *
115      * <p>The default implementation does nothing.</p>
116      */
117     override public void exitRuledef(RuleTranslatorParser.RuledefContext ctx) {
118         Result[] results;
119         foreach (child; ctx.children)
120             {
121                 results ~= values.get(child);
122             }
123         lastIndent--;
124         values.put(ctx, results);
125     }
126     /**
127      * {@inheritDoc}
128      *
129      * <p>The default implementation does nothing.</p>
130      */
131     override public void enterImport_stmts(RuleTranslatorParser.Import_stmtsContext ctx) { }
132     /**
133      * {@inheritDoc}
134      *
135      * <p>The default implementation does nothing.</p>
136      */
137     override public void exitImport_stmts(RuleTranslatorParser.Import_stmtsContext ctx) { }
138 
139     /**
140      * {@inheritDoc}
141      *
142      * <p>The default implementation does nothing.</p>
143      */
144     override public void exitRule_setting(RuleTranslatorParser.Rule_settingContext ctx) {
145         Result[] results;
146         Result result;
147         result.text ~= format!"<PAKET magic=\"%s_%s\">\n"(ctx.rule_name.getText,
148                                                           ctx.language.getText);
149         result.text ~= format!"    <ANSAGE id=\"%s_%s\">\n"(ctx.rule_name.getText,
150                                                             ctx.language.getText);
151         language = ctx.language.getText;
152         result.indent = lastIndent;
153         results ~= result;
154         values.put(ctx, results);
155     }
156     /**
157      * {@inheritDoc}
158      *
159      * <p>The default implementation does nothing.</p>
160      */
161     override public void enterClass_name(RuleTranslatorParser.Class_nameContext ctx) { }
162     /**
163      * {@inheritDoc}
164      *
165      * <p>The default implementation does nothing.</p>
166      */
167     override public void exitClass_name(RuleTranslatorParser.Class_nameContext ctx) { }
168     /**
169      * {@inheritDoc}
170      *
171      * <p>The default implementation does nothing.</p>
172      */
173     override public void enterLanguage(RuleTranslatorParser.LanguageContext ctx) {
174         mixin(DebugEnter);
175     }
176     /**
177      * {@inheritDoc}
178      *
179      * <p>The default implementation does nothing.</p>
180      */
181     override public void exitLanguage(RuleTranslatorParser.LanguageContext ctx) {
182         mixin(DebugExit);
183     }
184     /**
185      * {@inheritDoc}
186      *
187      * <p>The default implementation does nothing.</p>
188      */
189     override public void enterImport_stmt(RuleTranslatorParser.Import_stmtContext ctx) { }
190     /**
191      * {@inheritDoc}
192      *
193      * <p>The default implementation does nothing.</p>
194      */
195     override public void exitImport_stmt(RuleTranslatorParser.Import_stmtContext ctx) { }
196     /**
197      * {@inheritDoc}
198      *
199      * <p>The default implementation does nothing.</p>
200      */
201     override public void enterBase_rules(RuleTranslatorParser.Base_rulesContext ctx) { }
202     /**
203      * {@inheritDoc}
204      *
205      * <p>The default implementation does nothing.</p>
206      */
207     override public void exitBase_rules(RuleTranslatorParser.Base_rulesContext ctx) { }
208     /**
209      * {@inheritDoc}
210      *
211      * <p>The default implementation does nothing.</p>
212      */
213     override public void enterFuncdef(RuleTranslatorParser.FuncdefContext ctx) {
214         mixin(DebugEnter);
215     }
216     /**
217      * {@inheritDoc}
218      *
219      * <p>The default implementation does nothing.</p>
220      */
221     override public void exitFuncdef(RuleTranslatorParser.FuncdefContext ctx) {
222         Result[] results;
223         Result result;
224         results ~= result;
225         values.put(ctx, results);  // empty
226         debug {
227             debugInfo.write(format("%s exitFuncdef:", counter++));
228             debugInfo.write(format("\n\tvalues --> %s", values.get(ctx)));
229             debugInfo.write(format("\n\tvalues suite --> %s\n", values.get(ctx.suite)));
230         }
231     }
232     /**
233      * {@inheritDoc}
234      *
235      * <p>The default implementation does nothing.</p>
236      */
237     override public void enterFunctionName(RuleTranslatorParser.FunctionNameContext ctx) { }
238     /**
239      * {@inheritDoc}
240      *
241      * <p>The default implementation does nothing.</p>
242      */
243     override public void exitFunctionName(RuleTranslatorParser.FunctionNameContext ctx) { }
244     /**
245      * {@inheritDoc}
246      *
247      * <p>The default implementation does nothing.</p>
248      */
249     override public void enterParameters(RuleTranslatorParser.ParametersContext ctx) { }
250     /**
251      * {@inheritDoc}
252      *
253      * <p>The default implementation does nothing.</p>
254      */
255     override public void exitParameters(RuleTranslatorParser.ParametersContext ctx) { }
256     /**
257      * {@inheritDoc}
258      *
259      * <p>The default implementation does nothing.</p>
260      */
261     override public void enterTypedargslist(RuleTranslatorParser.TypedargslistContext ctx) { }
262     /**
263      * {@inheritDoc}
264      *
265      * <p>The default implementation does nothing.</p>
266      */
267     override public void exitTypedargslist(RuleTranslatorParser.TypedargslistContext ctx) { }
268     /**
269      * {@inheritDoc}
270      *
271      * <p>The default implementation does nothing.</p>
272      */
273     override public void enterTfpdef_name(RuleTranslatorParser.Tfpdef_nameContext ctx) { }
274     /**
275      * {@inheritDoc}
276      *
277      * <p>The default implementation does nothing.</p>
278      */
279     override public void exitTfpdef_name(RuleTranslatorParser.Tfpdef_nameContext ctx) { }
280     /**
281      * {@inheritDoc}
282      *
283      * <p>The default implementation does nothing.</p>
284      */
285     override public void enterTfpdef_number(RuleTranslatorParser.Tfpdef_numberContext ctx) { }
286     /**
287      * {@inheritDoc}
288      *
289      * <p>The default implementation does nothing.</p>
290      */
291     override public void exitTfpdef_number(RuleTranslatorParser.Tfpdef_numberContext ctx) { }
292     /**
293      * {@inheritDoc}
294      *
295      * <p>The default implementation does nothing.</p>
296      */
297     override public void enterTfpdef_string(RuleTranslatorParser.Tfpdef_stringContext ctx) { }
298     /**
299      * {@inheritDoc}
300      *
301      * <p>The default implementation does nothing.</p>
302      */
303     override public void exitTfpdef_string(RuleTranslatorParser.Tfpdef_stringContext ctx) { }
304     /**
305      * {@inheritDoc}
306      *
307      * <p>The default implementation does nothing.</p>
308      */
309     override public void enterTfpdef_funct_stm(RuleTranslatorParser.Tfpdef_funct_stmContext ctx) { }
310     /**
311      * {@inheritDoc}
312      *
313      * <p>The default implementation does nothing.</p>
314      */
315     override public void exitTfpdef_funct_stm(RuleTranslatorParser.Tfpdef_funct_stmContext ctx) { }
316     /**
317      * {@inheritDoc}
318      *
319      * <p>The default implementation does nothing.</p>
320      */
321     override public void enterStmt(RuleTranslatorParser.StmtContext ctx) {
322     }
323     /**
324      * {@inheritDoc}
325      *
326      * <p>The default implementation does nothing.</p>
327      */
328     override public void exitStmt(RuleTranslatorParser.StmtContext ctx) {
329         Result[] results = values.get(ctx.children[0]); // only forward
330         values.put(ctx, results);
331     }
332     /**
333      * {@inheritDoc}
334      *
335      * <p>The default implementation does nothing.</p>
336      */
337     override public void enterSimple_stmt(RuleTranslatorParser.Simple_stmtContext ctx) { }
338     /**
339      * {@inheritDoc}
340      *
341      * <p>The default implementation does nothing.</p>
342      */
343     override public void exitSimple_stmt(RuleTranslatorParser.Simple_stmtContext ctx) {
344         Result[] results = values.get(ctx.children[0]); // only forward
345         values.put(ctx, results);
346     }
347     /**
348      * {@inheritDoc}
349      *
350      * <p>The default implementation does nothing.</p>
351      */
352     override public void enterSmall_stmt(RuleTranslatorParser.Small_stmtContext ctx) {
353         debug {
354             debugInfo.write(format("%s enterSmall_stmt:", counter++));
355             debugInfo.write(format("\n\t getText = %s\n", ctx.getText));
356         }
357     }
358     /**
359      * {@inheritDoc}
360      *
361      * <p>The default implementation does nothing.</p>
362      */
363     override public void exitSmall_stmt(RuleTranslatorParser.Small_stmtContext ctx) {
364         values.put(ctx, values.get(ctx.children[0])); // only forward
365         debug {
366             debugInfo.write(format("%s exitSmall_stmt:", counter++));
367             debugInfo.write(format("\n\tvalues --> %s\n", values.get(ctx)));
368         }
369     }
370     /**
371      * {@inheritDoc}
372      *
373      * <p>The default implementation does nothing.</p>
374      */
375     override public void enterString_stmt(RuleTranslatorParser.String_stmtContext ctx) {
376         debug {
377             debugInfo.write(format("%s enterString_stmt:", counter++));
378             debugInfo.write(format("\n\tlastIndent --> %s\n", lastIndent));
379         }
380     }
381     /**
382      * {@inheritDoc}
383      *
384      * <p>The default implementation does nothing.</p>
385      */
386     override public void exitString_stmt(RuleTranslatorParser.String_stmtContext ctx) {
387         Result[] results;
388         Result result;
389         string seachString = ctx.getText[1 .. $-1]; // remove "
390         // search for related configuration entry
391         if (seachString in ibaConfigStat && language in ibaConfigStat[seachString])
392             {
393                 auto statDef = ibaConfigStat[seachString][language];
394                 result.text ~= format!"<STAT kat=%s>%s</STAT>\n"(statDef["kat"],
395                                                                  statDef["ref"].str);
396             }
397         else
398             {
399                 // TODO send error message
400                 result.text = format("<<<<< undefined symbol \"%s\" in \"%s\" >>>>>\n",
401                                      ctx.getText, language);
402             }
403         result.indent = lastIndent;
404         results ~= result;
405         values.put(ctx, results);
406         debug {
407             debugInfo.write(format("%s exitString_stmt:", counter++));
408         }
409         mixin(DebugPrintValues);
410     }
411     /**
412      * {@inheritDoc}
413      *
414      * <p>The default implementation does nothing.</p>
415      */
416     override public void enterFunct_stmt(RuleTranslatorParser.Funct_stmtContext ctx) {
417         mixin(DebugEnter);
418     }
419     /**
420      * {@inheritDoc}
421      *
422      * <p>The default implementation does nothing.</p>
423      */
424     override public void exitFunct_stmt(RuleTranslatorParser.Funct_stmtContext ctx) {
425         Result[] results;
426         Result result;
427         result.text = ctx.getText ~ "\n";
428         result.indent = lastIndent;
429         results ~= result;
430         values.put(ctx, results);
431         mixin(DebugExit);
432         debug {
433             debugInfo.writefln(format("\tvalues --> %s", values.get(ctx)));
434         }
435         if (ctx.getText in functionTemplates) {
436             debug {
437                 debugInfo.writefln("\tctx.getText in functionTemplates --> %s", true);
438             }
439         }
440         else {
441             debug {
442                 debugInfo.writefln("\tctx.getText in functionTemplates --> %s", false);
443             }
444         }
445     }
446     /**
447      * {@inheritDoc}
448      *
449      * <p>The default implementation does nothing.</p>
450      */
451     override public void enterFunct_name(RuleTranslatorParser.Funct_nameContext ctx) {
452         mixin(DebugEnter);
453     }
454     /**
455      * {@inheritDoc}
456      *
457      * <p>The default implementation does nothing.</p>
458      */
459     override public void exitFunct_name(RuleTranslatorParser.Funct_nameContext ctx) {
460         mixin(DebugExit);
461     }
462     /**
463      * {@inheritDoc}
464      *
465      * <p>The default implementation does nothing.</p>
466      */
467     override public void enterDot_e(RuleTranslatorParser.Dot_eContext ctx) { }
468     /**
469      * {@inheritDoc}
470      *
471      * <p>The default implementation does nothing.</p>
472      */
473     override public void exitDot_e(RuleTranslatorParser.Dot_eContext ctx) { }
474     /**
475      * {@inheritDoc}
476      *
477      * <p>The default implementation does nothing.</p>
478      */
479     override public void enterFunct_parameters(RuleTranslatorParser.Funct_parametersContext ctx) { }
480     /**
481      * {@inheritDoc}
482      *
483      * <p>The default implementation does nothing.</p>
484      */
485     override public void exitFunct_parameters(RuleTranslatorParser.Funct_parametersContext ctx) { }
486     /**
487      * {@inheritDoc}
488      *
489      * <p>The default implementation does nothing.</p>
490      */
491     override public void enterVar_stmt(RuleTranslatorParser.Var_stmtContext ctx) {
492     }
493     /**
494      * {@inheritDoc}
495      *
496      * <p>The default implementation does nothing.</p>
497      */
498     override public void exitVar_stmt(RuleTranslatorParser.Var_stmtContext ctx) {
499         Result[] results;
500         Result result;
501         string seachString = ctx.getText;
502         // search for related configuration entry
503         if (seachString in ibaConfigVar && language in ibaConfigVar[seachString])
504             {
505                 auto varDef = ibaConfigVar[seachString][language];
506                 result.text ~= format!"<VAR kat=%s name=%s/>\n"(varDef["kat"],
507                                                                 varDef["name"]);
508             }
509         else
510             {
511                 // TODO send error message
512                 result.text = format("<<<<< undefined symbol \"%s\" in \"%s\" >>>>>\n",
513                                      ctx.getText, language);
514             }
515         result.indent = lastIndent;
516         results ~= result;
517         values.put(ctx, results);
518     }
519     /**
520      * {@inheritDoc}
521      *
522      * <p>The default implementation does nothing.</p>
523      */
524     override public void enterFlow_stmt(RuleTranslatorParser.Flow_stmtContext ctx) { }
525     /**
526      * {@inheritDoc}
527      *
528      * <p>The default implementation does nothing.</p>
529      */
530     override public void exitFlow_stmt(RuleTranslatorParser.Flow_stmtContext ctx) { }
531     /**
532      * {@inheritDoc}
533      *
534      * <p>The default implementation does nothing.</p>
535      */
536     override public void enterBreak_stmt(RuleTranslatorParser.Break_stmtContext ctx) { }
537     /**
538      * {@inheritDoc}
539      *
540      * <p>The default implementation does nothing.</p>
541      */
542     override public void exitBreak_stmt(RuleTranslatorParser.Break_stmtContext ctx) { }
543     /**
544      * {@inheritDoc}
545      *
546      * <p>The default implementation does nothing.</p>
547      */
548     override public void enterContinue_stmt(RuleTranslatorParser.Continue_stmtContext ctx) { }
549     /**
550      * {@inheritDoc}
551      *
552      * <p>The default implementation does nothing.</p>
553      */
554     override public void exitContinue_stmt(RuleTranslatorParser.Continue_stmtContext ctx) { }
555     /**
556      * {@inheritDoc}
557      *
558      * <p>The default implementation does nothing.</p>
559      */
560     override public void enterDotted_as_name(RuleTranslatorParser.Dotted_as_nameContext ctx) { }
561     /**
562      * {@inheritDoc}
563      *
564      * <p>The default implementation does nothing.</p>
565      */
566     override public void exitDotted_as_name(RuleTranslatorParser.Dotted_as_nameContext ctx) { }
567     /**
568      * {@inheritDoc}
569      *
570      * <p>The default implementation does nothing.</p>
571      */
572     override public void enterDotted_as_names(RuleTranslatorParser.Dotted_as_namesContext ctx) { }
573     /**
574      * {@inheritDoc}
575      *
576      * <p>The default implementation does nothing.</p>
577      */
578     override public void exitDotted_as_names(RuleTranslatorParser.Dotted_as_namesContext ctx) { }
579     /**
580      * {@inheritDoc}
581      *
582      * <p>The default implementation does nothing.</p>
583      */
584     override public void enterDotted_name(RuleTranslatorParser.Dotted_nameContext ctx) { }
585     /**
586      * {@inheritDoc}
587      *
588      * <p>The default implementation does nothing.</p>
589      */
590     override public void exitDotted_name(RuleTranslatorParser.Dotted_nameContext ctx) { }
591     /**
592      * {@inheritDoc}
593      *
594      * <p>The default implementation does nothing.</p>
595      */
596     override public void enterDotted_name_first_part(RuleTranslatorParser.Dotted_name_first_partContext ctx) { }
597     /**
598      * {@inheritDoc}
599      *
600      * <p>The default implementation does nothing.</p>
601      */
602     override public void exitDotted_name_first_part(RuleTranslatorParser.Dotted_name_first_partContext ctx) { }
603     /**
604      * {@inheritDoc}
605      *
606      * <p>The default implementation does nothing.</p>
607      */
608     override public void enterDotted_name_part(RuleTranslatorParser.Dotted_name_partContext ctx) { }
609     /**
610      * {@inheritDoc}
611      *
612      * <p>The default implementation does nothing.</p>
613      */
614     override public void exitDotted_name_part(RuleTranslatorParser.Dotted_name_partContext ctx) { }
615     /**
616      * {@inheritDoc}
617      *
618      * <p>The default implementation does nothing.</p>
619      */
620     override public void enterFirst_part_of_dotted_name(RuleTranslatorParser.First_part_of_dotted_nameContext ctx) { }
621     /**
622      * {@inheritDoc}
623      *
624      * <p>The default implementation does nothing.</p>
625      */
626     override public void exitFirst_part_of_dotted_name(RuleTranslatorParser.First_part_of_dotted_nameContext ctx) { }
627     /**
628      * {@inheritDoc}
629      *
630      * <p>The default implementation does nothing.</p>
631      */
632     override public void enterCompound_stmt(RuleTranslatorParser.Compound_stmtContext ctx) {
633         debug {
634             debugInfo.write(format("%s enterCompound_stmt:\n", counter++));
635         }
636     }
637     /**
638      * {@inheritDoc}
639      *
640      * <p>The default implementation does nothing.</p>
641      */
642     override public void exitCompound_stmt(RuleTranslatorParser.Compound_stmtContext ctx) {
643         values.put(ctx, values.get(ctx.children[0])); // only forward
644         debug {
645             debugInfo.write(format("%s exitCompound_stmt:", counter++));
646             debugInfo.write(format("\n\tvalues --> %s\n", values.get(ctx)));
647         }
648     }
649 
650     /**
651      * {@inheritDoc}
652      *
653      * <p>The default implementation does nothing.</p>
654      */
655     override public void enterIf_condition_and_suite(RuleTranslatorParser.If_condition_and_suiteContext ctx) {
656         mixin(DebugEnter);
657     }
658     /**
659      * {@inheritDoc}
660      *
661      * <p>The default implementation does nothing.</p>
662      */
663     override public void exitIf_condition_and_suite(RuleTranslatorParser.If_condition_and_suiteContext ctx) {
664         values.put(ctx, values.get(ctx.children[1]));
665         ifConditions.put(ctx, ifConditions.get(ctx.children[1]));
666         debug {
667             debugInfo.write(format("%s exitIf_condition_and_suite:", counter++));
668             debugInfo.write(format("\n\tvalues --> %s", values.get(ctx)));
669             debugInfo.write(format("\n\tifCondition --> %s\n", ifConditions.get(ctx.children[1])));
670         }
671     }
672 
673     /**
674      * {@inheritDoc}
675      *
676      * <p>The default implementation does nothing.</p>
677      */
678     override public void enterElif_condition_and_suite(RuleTranslatorParser.Elif_condition_and_suiteContext ctx) {
679         debug {
680             debugInfo.write(format("%s enterElif_condition_and_suite:", counter++));
681             debugInfo.write(format("\n\tchilds --> %s\n", ctx.children));
682         }
683     }
684     /**
685      * {@inheritDoc}
686      *
687      * <p>The default implementation does nothing.</p>
688      */
689     override public void exitElif_condition_and_suite(RuleTranslatorParser.Elif_condition_and_suiteContext ctx) {
690         Result[] results;
691         Result resultE;
692         resultE.text = "<ELSE>\n";
693         resultE.indent = lastIndent;
694         results ~= resultE;
695         values.put(ctx, results ~ values.get(ctx.children[1]));
696         ifConditions.put(ctx, ifConditions.get(ctx.children[1]));
697         mixin(DebugExit);
698         mixin(DebugPrintValues);
699     }
700     /**
701      * {@inheritDoc}
702      *
703      * <p>The default implementation does nothing.</p>
704      */
705     override public void enterElse_and_suite(RuleTranslatorParser.Else_and_suiteContext ctx) {
706         debug {
707             debugInfo.write(format("%s enterElse_and_suite:", counter++));
708             debugInfo.write(format("\n\tchilds --> %s\n", ctx.children));
709         }
710     }
711     /**
712      * {@inheritDoc}
713      *
714      * <p>The default implementation does nothing.</p>
715      */
716     override public void exitElse_and_suite(RuleTranslatorParser.Else_and_suiteContext ctx) {
717         IfCond ifCond;
718         ifCond.cond = "ELSE";
719         ifConditions.put(ctx, ifCond);  // special context ELSE
720 
721         Result[] results;
722         Result resultE;
723         resultE.text = "<ELSE>\n";
724         resultE.indent = lastIndent;
725         results ~= resultE;
726 
727         Result result;
728         result.indent = ++lastIndent;
729         results ~= result;
730         results ~= values.get(ctx.children[2]);
731         values.put(ctx, results);
732         lastIndent--;
733         debug {
734             debugInfo.write(format("%s exitElse_and_suite:", counter++));
735             debugInfo.write(format("\n\tvalues --> %s\n", values.get(ctx)));
736         }
737     }
738 
739     /**
740      * {@inheritDoc}
741      *
742      * <p>The default implementation does nothing.</p>
743      */
744     override public void enterIf_stmt(RuleTranslatorParser.If_stmtContext ctx) {
745         mixin(DebugEnter);
746     }
747     /**
748      * {@inheritDoc}
749      *
750      * <p>The default implementation does nothing.</p>
751      */
752     override public void exitIf_stmt(RuleTranslatorParser.If_stmtContext ctx) {
753         Result[] resultsCloseIf;
754         Result[] resultsChilds;
755         foreach (child; ctx.children) {
756             debug {
757                 debugInfo.write(format("%s exitIf_stmtxx:", counter++));
758                 debugInfo.write(format("\n\tvalues --> %s\n", values.get(child)));
759             }
760             resultsChilds ~= values.get(child);
761             IfCond ifCond = ifConditions.get(child);
762             if (ifCond.cond != "ELSE") {
763                 Result closeIf;
764                 closeIf.text = format!"</%s>\n"(ifCond.cond);
765                 closeIf.indent = lastIndent;
766                 resultsCloseIf ~= closeIf;
767             }
768         }
769         import std.algorithm.mutation;
770         resultsCloseIf.reverse;
771         values.put(ctx, resultsChilds ~ resultsCloseIf);
772 
773         debug {
774             debugInfo.write(format("%s exitIf_stmt:", counter++));
775             debugInfo.write(format("\n\tvalues --> %s\n", values.get(ctx)));
776         }
777     }
778 
779     /**
780      * {@inheritDoc}
781      *
782      * <p>The default implementation does nothing.</p>
783      */
784     override public void enterCondition_and_suite(RuleTranslatorParser.Condition_and_suiteContext ctx) {
785         lastIndent++;
786         mixin(DebugEnter);
787     }
788     /**
789      * {@inheritDoc}
790      *
791      * <p>The default implementation does nothing.</p>
792      */
793     override public void exitCondition_and_suite(RuleTranslatorParser.Condition_and_suiteContext ctx) {
794         lastIndent--;
795         IfCond ifCond = ifConditions.get(ctx.children[0]);
796         ifConditions.put(ctx, ifCond);  // forward
797         Result[] results;  // suite container
798         Result result;
799         // search for related configuration entry
800         if (ifCond.name in ibaConfigCond && language in ibaConfigCond[ifCond.name])
801             {
802                 auto varDef = ibaConfigCond[ifCond.name][language];
803                 // no condition
804                 if (ifCond.value == "")
805                     {
806                         result.text ~= format!"<%s name=%s>\n"(ifCond.cond,
807                                                                varDef["name"]);
808                     }
809                 else {
810                     result.text ~= format!"<%s name=%s wert=%s>\n"(ifCond.cond,
811                                                                    varDef["name"],
812                                                                    ifCond.value
813                                                                    );
814                 }
815             }
816         else
817             {
818                 // TODO send error message
819                 result.text = format("<<<<< undefined condition name=\"%s\" language=\"%s\" >>>>>\n",
820                                      ifCond.name, language);
821             }
822         result.indent = lastIndent;
823         results ~= result;
824         results ~= values.get(ctx.children[2]);
825         values.put(ctx, results);
826         debug {
827             debugInfo.write(format("%s exitCondition_and_suite:", counter++));
828             debugInfo.write(format("\n\tchilds --> %s", ctx.children));
829             debugInfo.write(format("\n\tifCond --> %s", ifCond));
830             debugInfo.write(format("\n\tresults --> %s", results));
831             debugInfo.write(format("\n\tlastIndent --> %s\n", lastIndent));
832         }
833 
834     }
835 
836     /**
837      * {@inheritDoc}
838      *
839      * <p>The default implementation does nothing.</p>
840      */
841     override public void enterCondition_with_value(RuleTranslatorParser.Condition_with_valueContext ctx) {
842         string ifTest = "";
843         ifTests.put(ctx, ifTest);
844         mixin(DebugEnter);
845     }
846     /**
847      * {@inheritDoc}
848      *
849      * <p>The default implementation does nothing.</p>
850      */
851     override public void exitCondition_with_value(RuleTranslatorParser.Condition_with_valueContext ctx) {
852         IfCond ifCond;
853         ifCond.name = ifTests.get(ctx.children[1]);  // ['(' , text ')']
854         ifCond.value = ctx.atom.getText;
855         if (ifCond.value[0] != '"')
856             ifCond.value = '"' ~ ifCond.value ~ '"';
857         ifCond.cond = "IFDEF";
858         if (ctx.reduced_comperator.getText == "<>" ||
859             ctx.reduced_comperator.getText == "!=") {
860             ifCond.cond = switchCondition(ifCond.cond);
861         }
862         ifConditions.put(ctx, ifCond);
863 
864         debug {
865             debugInfo.write(format("%s exitCondition_with_value:\n", counter++));
866             debugInfo.write(format("\tname -> %s\n", ifTests.get(ctx.children[1])));
867             debugInfo.write(format("\treduced_comperator -> %s\n", ctx.reduced_comperator.getText));
868             debugInfo.write(format("\tatom -> %s\n", ctx.atom.getText));
869         }
870     }
871 
872     /**
873      * {@inheritDoc}
874      *
875      * <p>The default implementation does nothing.</p>
876      */
877     override public void enterCondition_without_value(RuleTranslatorParser.Condition_without_valueContext ctx) {
878         string ifTest = "";
879         ifTests.put(ctx, ifTest);
880         debug {
881             debugInfo.write(format("%s enterCondition_without_value:\n", counter++));
882         }
883     }
884     /**
885      * {@inheritDoc}
886      *
887      * <p>The default implementation does nothing.</p>
888      */
889     override public void exitCondition_without_value(RuleTranslatorParser.Condition_without_valueContext ctx) {
890         IfCond ifCond;
891         if (ctx.children[0].getText == "not")
892             {
893                 ifCond.cond = "IFNDEF";
894                 ifCond.name = ifTests.get(ctx.children[2]);  // 'not' ['(' , text ')']
895             }
896         else
897             {
898                 ifCond.cond = "IFDEF";
899                 ifCond.name = ifTests.get(ctx.children[1]);  // ['(' , text ')']
900             }
901         ifConditions.put(ctx, ifCond);
902 
903         debug {
904             debugInfo.write(format("%s exitCondition_without_value:\n", counter++));
905             debugInfo.write(format("\tifConditions.parent -> %s\n", ifConditions.get(ctx)));
906             debugInfo.write(format("\tifTest -> %s\n", ifTests.get(ctx)));
907             debugInfo.write(format("\tchilds -> %s\n", ctx.children));
908         }
909     }
910 
911     /**
912      * {@inheritDoc}
913      *
914      * <p>The default implementation does nothing.</p>
915      */
916     override public void enterElif_e(RuleTranslatorParser.Elif_eContext ctx) { }
917     /**
918      * {@inheritDoc}
919      *
920      * <p>The default implementation does nothing.</p>
921      */
922     override public void exitElif_e(RuleTranslatorParser.Elif_eContext ctx) { }
923     /**
924      * {@inheritDoc}
925      *
926      * <p>The default implementation does nothing.</p>
927      */
928     override public void enterElse_e(RuleTranslatorParser.Else_eContext ctx) { }
929     /**
930      * {@inheritDoc}
931      *
932      * <p>The default implementation does nothing.</p>
933      */
934     override public void exitElse_e(RuleTranslatorParser.Else_eContext ctx) { }
935     /**
936      * {@inheritDoc}
937      *
938      * <p>The default implementation does nothing.</p>
939      */
940     override public void enterFor_stmt(RuleTranslatorParser.For_stmtContext ctx) { }
941     /**
942      * {@inheritDoc}
943      *
944      * <p>The default implementation does nothing.</p>
945      */
946     override public void exitFor_stmt(RuleTranslatorParser.For_stmtContext ctx) { }
947     /**
948      * {@inheritDoc}
949      *
950      * <p>The default implementation does nothing.</p>
951      */
952     override public void enterFor_testlist(RuleTranslatorParser.For_testlistContext ctx) { }
953     /**
954      * {@inheritDoc}
955      *
956      * <p>The default implementation does nothing.</p>
957      */
958     override public void exitFor_testlist(RuleTranslatorParser.For_testlistContext ctx) { }
959     /**
960      * {@inheritDoc}
961      *
962      * <p>The default implementation does nothing.</p>
963      */
964     override public void enterFor_exprlist(RuleTranslatorParser.For_exprlistContext ctx) { }
965     /**
966      * {@inheritDoc}
967      *
968      * <p>The default implementation does nothing.</p>
969      */
970     override public void exitFor_exprlist(RuleTranslatorParser.For_exprlistContext ctx) { }
971     /**
972      * {@inheritDoc}
973      *
974      * <p>The default implementation does nothing.</p>
975      */
976     override public void enterBlock_stmt(RuleTranslatorParser.Block_stmtContext ctx) { }
977     /**
978      * {@inheritDoc}
979      *
980      * <p>The default implementation does nothing.</p>
981      */
982     override public void exitBlock_stmt(RuleTranslatorParser.Block_stmtContext ctx) { }
983     /**
984      * {@inheritDoc}
985      *
986      * <p>The default implementation does nothing.</p>
987      */
988     override public void enterBlock_suite(RuleTranslatorParser.Block_suiteContext ctx) { }
989     /**
990      * {@inheritDoc}
991      *
992      * <p>The default implementation does nothing.</p>
993      */
994     override public void exitBlock_suite(RuleTranslatorParser.Block_suiteContext ctx) { }
995     /**
996      * {@inheritDoc}
997      *
998      * <p>The default implementation does nothing.</p>
999      */
1000     override public void enterWith_stmt(RuleTranslatorParser.With_stmtContext ctx) { }
1001     /**
1002      * {@inheritDoc}
1003      *
1004      * <p>The default implementation does nothing.</p>
1005      */
1006     override public void exitWith_stmt(RuleTranslatorParser.With_stmtContext ctx) { }
1007     /**
1008      * {@inheritDoc}
1009      *
1010      * <p>The default implementation does nothing.</p>
1011      */
1012     override public void enterWith_item(RuleTranslatorParser.With_itemContext ctx) { }
1013     /**
1014      * {@inheritDoc}
1015      *
1016      * <p>The default implementation does nothing.</p>
1017      */
1018     override public void exitWith_item(RuleTranslatorParser.With_itemContext ctx) { }
1019     /**
1020      * {@inheritDoc}
1021      *
1022      * <p>The default implementation does nothing.</p>
1023      */
1024     override public void enterSuite(RuleTranslatorParser.SuiteContext ctx) {
1025         Result[] results;
1026         Result result;
1027         result.text = "\n";
1028         result.indent = lastIndent;
1029         results ~= result;
1030         values.put(ctx, results);
1031         debug {
1032             debugInfo.write(format("%s enterSuite:", counter++));
1033             debugInfo.write(format("\n\tvalues --> %s\n", values.get(ctx)));
1034         }
1035     }
1036     /**
1037      * {@inheritDoc}
1038      *
1039      * <p>The default implementation does nothing.</p>
1040      */
1041     override public void exitSuite(RuleTranslatorParser.SuiteContext ctx) {
1042         Result[] results = values.get(ctx.stmt[0]); // only forward
1043         values.put(ctx, results);
1044         mixin(DebugExit);
1045         mixin(DebugPrintValues);
1046     }
1047     /**
1048      * {@inheritDoc}
1049      *
1050      * <p>The default implementation does nothing.</p>
1051      */
1052     override public void enterTest(RuleTranslatorParser.TestContext ctx) {
1053         auto ifTest = ifTests.get(ctx.getParent);
1054         ifTests.put(ctx, ifTest);
1055         debug {
1056             debugInfo.write(format("%s enterTest:\n", counter++));
1057         }
1058     }
1059     /**
1060      * {@inheritDoc}
1061      *
1062      * <p>The default implementation does nothing.</p>
1063      */
1064     override public void exitTest(RuleTranslatorParser.TestContext ctx) {
1065         Result[] results;
1066         Result result;
1067         string[] append;
1068         foreach (i, child; ctx.children) {
1069             append ~= ifTests.get(child);
1070         }
1071         import std.array : join;
1072         ifTests.put(ctx, join(append, ' '));
1073         result.text ~= join(append, ' ');
1074         results ~= result;
1075         values.put(ctx, results);
1076         debug {
1077             debugInfo.write(format("%s exitTest:\n", counter++));
1078             debugInfo.write(format("\tifTests -> \"%s\"\n", ifTests.get(ctx)));
1079             debugInfo.write(format("\tctx.children -> %s\n", ctx.children));
1080         }
1081 
1082     }
1083 
1084     /**
1085      * {@inheritDoc}
1086      *
1087      * <p>The default implementation does nothing.</p>
1088      */
1089     override public void enterR_equals(RuleTranslatorParser.R_equalsContext ctx) {
1090         debug {
1091             debugInfo.write(format("%s enterR_equals:\n", counter++));
1092         }
1093     }
1094     /**
1095      * {@inheritDoc}
1096      *
1097      * <p>The default implementation does nothing.</p>
1098      */
1099     override public void exitR_equals(RuleTranslatorParser.R_equalsContext ctx) {
1100         Result result;
1101         result.text = "==";
1102         Result[] results;
1103         results ~= result;
1104         values.put(ctx, results);
1105         debug {
1106             debugInfo.write(format("%s exitR_equals:\n", counter++));
1107         }
1108     }
1109     /**
1110      * {@inheritDoc}
1111      *
1112      * <p>The default implementation does nothing.</p>
1113      */
1114     override public void enterR_not_equal(RuleTranslatorParser.R_not_equalContext ctx) { }
1115     /**
1116      * {@inheritDoc}
1117      *
1118      * <p>The default implementation does nothing.</p>
1119      */
1120     override public void exitR_not_equal(RuleTranslatorParser.R_not_equalContext ctx) {
1121         Result result;
1122         result.text = "!=";
1123         Result[] results;
1124         results ~= result;
1125         values.put(ctx, results);
1126     }
1127 
1128     /**
1129      * {@inheritDoc}
1130      *
1131      * <p>The default implementation does nothing.</p>
1132      */
1133     override public void enterOr_e(RuleTranslatorParser.Or_eContext ctx) { }
1134     /**
1135      * {@inheritDoc}
1136      *
1137      * <p>The default implementation does nothing.</p>
1138      */
1139     override public void exitOr_e(RuleTranslatorParser.Or_eContext ctx) { }
1140     /**
1141      * {@inheritDoc}
1142      *
1143      * <p>The default implementation does nothing.</p>
1144      */
1145     override public void enterAnd_test(RuleTranslatorParser.And_testContext ctx) {
1146         auto ifTest = ifTests.get(ctx.getParent);
1147         ifTests.put(ctx, ifTest);
1148         mixin(DebugEnter);
1149     }
1150     /**
1151      * {@inheritDoc}
1152      *
1153      * <p>The default implementation does nothing.</p>
1154      */
1155     override public void exitAnd_test(RuleTranslatorParser.And_testContext ctx) {
1156         Result[] results;
1157         Result result;
1158         string[] append;
1159         foreach (i, child; ctx.children) {
1160             append ~= ifTests.get(child);
1161         }
1162         import std.array : join;
1163         ifTests.put(ctx, join(append, ' '));
1164         result.text ~= join(append, ' ');
1165         results ~= result;
1166         values.put(ctx, results);
1167         debug {
1168             debugInfo.write(format("%s exitAnd_test:\n", counter++));
1169             debugInfo.write(format("\tifTests -> \"%s\"\n", ifTests.get(ctx)));
1170             debugInfo.write(format("\tctx.children -> %s\n", ctx.children));
1171         }
1172     }
1173     /**
1174      * {@inheritDoc}
1175      *
1176      * <p>The default implementation does nothing.</p>
1177      */
1178     override public void enterAnd_e(RuleTranslatorParser.And_eContext ctx) {
1179         debug {
1180             debugInfo.write(format("%s enterAnd_test:\n", counter++));
1181         }
1182     }
1183     /**
1184      * {@inheritDoc}
1185      *
1186      * <p>The default implementation does nothing.</p>
1187      */
1188     override public void exitAnd_e(RuleTranslatorParser.And_eContext ctx) {
1189         mixin(DebugExit);
1190     }
1191     /**
1192      * {@inheritDoc}
1193      *
1194      * <p>The default implementation does nothing.</p>
1195      */
1196     override public void enterNot_test(RuleTranslatorParser.Not_testContext ctx) {
1197         auto ifTest = "";
1198         ifTests.put(ctx, ifTest);
1199         debug {
1200             debugInfo.write(format("%s enterNot_test:\n", counter++));
1201         }
1202     }
1203     /**
1204      * {@inheritDoc}
1205      *
1206      * <p>The default implementation does nothing.</p>
1207      */
1208     override public void exitNot_test(RuleTranslatorParser.Not_testContext ctx) {
1209         string[] append;
1210 
1211         debug {
1212             debugInfo.write(format("%s exitNot_test:\n", counter++));
1213             debugInfo.write(format("\tctx.children -> %s\n", ctx.children));
1214         }
1215         foreach (i, child; ctx.children) {
1216             debug debugInfo.write(format("\t%s: ctx.child -> %s\n", i, ifTests.get(child)));
1217             append ~= ifTests.get(child);
1218         }
1219         import std.array : join;
1220         ifTests.put(ctx, join(append, ' '));
1221 
1222         debug {
1223             debugInfo.write(format("\tifTest -> \"%s\"\n", ifTests.get(ctx)));
1224         }
1225     }
1226     /**
1227      * {@inheritDoc}
1228      *
1229      * <p>The default implementation does nothing.</p>
1230      */
1231     override public void enterNot(RuleTranslatorParser.NotContext ctx) {
1232         auto ifTest = "";
1233         ifTests.put(ctx, ifTest);
1234         debug {
1235             debugInfo.write(format("%s enterNot:\n", counter++));
1236         }
1237         mixin(DebugEnter);
1238     }
1239     /**
1240      * {@inheritDoc}
1241      *
1242      * <p>The default implementation does nothing.</p>
1243      */
1244     override public void exitNot(RuleTranslatorParser.NotContext ctx) {
1245         auto ifTest = ifTests.get(ctx);
1246         ifTests.put(ctx, ifTest ~ "not");
1247         mixin(DebugExit);
1248     }
1249     /**
1250      * {@inheritDoc}
1251      *
1252      * <p>The default implementation does nothing.</p>
1253      */
1254     override public void enterComparison(RuleTranslatorParser.ComparisonContext ctx) {
1255     }
1256     /**
1257      * {@inheritDoc}
1258      *
1259      * <p>The default implementation does nothing.</p>
1260      */
1261     override public void exitComparison(RuleTranslatorParser.ComparisonContext ctx) {
1262         Result[] results;
1263         Result result;
1264         string[] append;
1265         foreach (i, child; ctx.children) {
1266             append ~= child.getText;
1267         }
1268         import std.array : join;
1269         ifTests.put(ctx.getParent, join(append, '.'));
1270         result.text ~= join(append, '.');
1271         results ~= result;
1272         values.put(ctx, results);
1273         debug {
1274             debugInfo.write(format("%s exitComparison:\n", counter++));
1275             debugInfo.write(format("\tifTests -> %s\n", ifTests.get(ctx.parent)));
1276             debugInfo.write(format("\tctx.children -> %s\n", ctx.children));
1277             debugInfo.write(format("\tresults -> %s\n", results));
1278         }
1279     }
1280     /**
1281      * {@inheritDoc}
1282      *
1283      * <p>The default implementation does nothing.</p>
1284      */
1285     override public void enterLess_than(RuleTranslatorParser.Less_thanContext ctx) { }
1286     /**
1287      * {@inheritDoc}
1288      *
1289      * <p>The default implementation does nothing.</p>
1290      */
1291     override public void exitLess_than(RuleTranslatorParser.Less_thanContext ctx) { }
1292     /**
1293      * {@inheritDoc}
1294      *
1295      * <p>The default implementation does nothing.</p>
1296      */
1297     override public void enterGreater_than(RuleTranslatorParser.Greater_thanContext ctx) { }
1298     /**
1299      * {@inheritDoc}
1300      *
1301      * <p>The default implementation does nothing.</p>
1302      */
1303     override public void exitGreater_than(RuleTranslatorParser.Greater_thanContext ctx) { }
1304     /**
1305      * {@inheritDoc}
1306      *
1307      * <p>The default implementation does nothing.</p>
1308      */
1309     override public void enterEquals(RuleTranslatorParser.EqualsContext ctx) { }
1310     /**
1311      * {@inheritDoc}
1312      *
1313      * <p>The default implementation does nothing.</p>
1314      */
1315     override public void exitEquals(RuleTranslatorParser.EqualsContext ctx) { }
1316     /**
1317      * {@inheritDoc}
1318      *
1319      * <p>The default implementation does nothing.</p>
1320      */
1321     override public void enterGreater_equal(RuleTranslatorParser.Greater_equalContext ctx) { }
1322     /**
1323      * {@inheritDoc}
1324      *
1325      * <p>The default implementation does nothing.</p>
1326      */
1327     override public void exitGreater_equal(RuleTranslatorParser.Greater_equalContext ctx) { }
1328     /**
1329      * {@inheritDoc}
1330      *
1331      * <p>The default implementation does nothing.</p>
1332      */
1333     override public void enterLess_equal(RuleTranslatorParser.Less_equalContext ctx) { }
1334     /**
1335      * {@inheritDoc}
1336      *
1337      * <p>The default implementation does nothing.</p>
1338      */
1339     override public void exitLess_equal(RuleTranslatorParser.Less_equalContext ctx) { }
1340     /**
1341      * {@inheritDoc}
1342      *
1343      * <p>The default implementation does nothing.</p>
1344      */
1345     override public void enterNot_equal(RuleTranslatorParser.Not_equalContext ctx) { }
1346     /**
1347      * {@inheritDoc}
1348      *
1349      * <p>The default implementation does nothing.</p>
1350      */
1351     override public void exitNot_equal(RuleTranslatorParser.Not_equalContext ctx) { }
1352     /**
1353      * {@inheritDoc}
1354      *
1355      * <p>The default implementation does nothing.</p>
1356      */
1357     override public void enterExpr(RuleTranslatorParser.ExprContext ctx) {
1358         debug {
1359             debugInfo.write(format("%s enterExpr:\n", counter++));
1360         }
1361     }
1362     /**
1363      * {@inheritDoc}
1364      *
1365      * <p>The default implementation does nothing.</p>
1366      */
1367     override public void exitExpr(RuleTranslatorParser.ExprContext ctx) {
1368         Result[] results;
1369         Result result;
1370         string[] append;
1371         foreach (i, child; ctx.children) {
1372             append ~= child.getText;
1373         }
1374         import std.array : join;
1375         ifTests.put(ctx.getParent, join(append, '.'));
1376         result.text ~= join(append, '.');
1377         results ~= result;
1378         values.put(ctx, results);
1379         debug {
1380             debugInfo.write(format("%s exitExpr:\n", counter++));
1381             debugInfo.write(format("\tifTests -> %s\n", ifTests.get(ctx.parent)));
1382             debugInfo.write(format("\tctx.children -> %s\n", ctx.children));
1383             debugInfo.write(format("\tresults -> %s\n", results));
1384         }
1385     }
1386     /**
1387      * {@inheritDoc}
1388      *
1389      * <p>The default implementation does nothing.</p>
1390      */
1391     override public void enterXor_expr(RuleTranslatorParser.Xor_exprContext ctx) {
1392         debug {
1393             debugInfo.write(format("%s enterXor_expr:\n", counter++));
1394         }
1395     }
1396     /**
1397      * {@inheritDoc}
1398      *
1399      * <p>The default implementation does nothing.</p>
1400      */
1401     override public void exitXor_expr(RuleTranslatorParser.Xor_exprContext ctx) {
1402         Result[] results;
1403         Result result;
1404         string[] append;
1405         foreach (i, child; ctx.children) {
1406             append ~= child.getText;
1407         }
1408         import std.array : join;
1409         ifTests.put(ctx.getParent, join(append, '.'));
1410         result.text ~= join(append, '.');
1411         results ~= result;
1412         values.put(ctx, results);
1413         debug {
1414             debugInfo.write(format("%s exitXor_expr:\n", counter++));
1415             debugInfo.write(format("\tifTests -> %s\n", ifTests.get(ctx.parent)));
1416             debugInfo.write(format("\tctx.children -> %s\n", ctx.children));
1417             debugInfo.write(format("\tresults -> %s\n", results));
1418         }
1419     }
1420     /**
1421      * {@inheritDoc}
1422      *
1423      * <p>The default implementation does nothing.</p>
1424      */
1425     override public void enterAnd_expr(RuleTranslatorParser.And_exprContext ctx) {
1426         debug {
1427             debugInfo.write(format("%s enterAnd_expr:\n", counter++));
1428         }
1429     }
1430     /**
1431      * {@inheritDoc}
1432      *
1433      * <p>The default implementation does nothing.</p>
1434      */
1435     override public void exitAnd_expr(RuleTranslatorParser.And_exprContext ctx) {
1436         Result[] results;
1437         Result result;
1438         string[] append;
1439         foreach (i, child; ctx.children) {
1440             append ~= child.getText;
1441         }
1442         import std.array : join;
1443         ifTests.put(ctx.getParent, join(append, '.'));
1444         result.text ~= join(append, '.');
1445         results ~= result;
1446         values.put(ctx, results);
1447         debug {
1448             debugInfo.write(format("%s exitAnd_expr:\n", counter++));
1449             debugInfo.write(format("\tifTests -> %s\n", ifTests.get(ctx.parent)));
1450             debugInfo.write(format("\tctx.children -> %s\n", ctx.children));
1451             debugInfo.write(format("\tresults -> %s\n", results));
1452         }
1453     }
1454 
1455     /**
1456      * {@inheritDoc}
1457      *
1458      * <p>The default implementation does nothing.</p>
1459      */
1460     override public void enterArith_expr(RuleTranslatorParser.Arith_exprContext ctx) {
1461         debug {
1462             debugInfo.write(format("%s enterArith_expr:\n", counter++));
1463         }
1464     }
1465     /**
1466      * {@inheritDoc}
1467      *
1468      * <p>The default implementation does nothing.</p>
1469      */
1470     override public void exitArith_expr(RuleTranslatorParser.Arith_exprContext ctx) {
1471         Result[] results;
1472         Result result;
1473         string[] append;
1474         foreach (i, child; ctx.children) {
1475             append ~= child.getText;
1476         }
1477         import std.array : join;
1478         ifTests.put(ctx.getParent, join(append, '.'));
1479         result.text ~= join(append, '.');
1480         results ~= result;
1481         values.put(ctx, results);
1482         debug {
1483             debugInfo.write(format("%s exitArith_expr:\n", counter++));
1484             debugInfo.write(format("\tifTests -> %s\n", ifTests.get(ctx.parent)));
1485             debugInfo.write(format("\tctx.children -> %s\n", ctx.children));
1486             debugInfo.write(format("\tresults -> %s\n", results));
1487         }
1488     }
1489 
1490     /**
1491      * {@inheritDoc}
1492      *
1493      * <p>The default implementation does nothing.</p>
1494      */
1495     override public void enterTerm(RuleTranslatorParser.TermContext ctx) {
1496         debug {
1497             debugInfo.write(format("%s enterTerm:\n", counter++));
1498         }
1499     }
1500     /**
1501      * {@inheritDoc}
1502      *
1503      * <p>The default implementation does nothing.</p>
1504      */
1505     override public void exitTerm(RuleTranslatorParser.TermContext ctx) {
1506         Result[] results;
1507         Result result;
1508         string[] append;
1509         foreach (i, child; ctx.children) {
1510             append ~= child.getText;
1511         }
1512         import std.array : join;
1513         ifTests.put(ctx.getParent, join(append, '.'));
1514         result.text ~= join(append, '.');
1515         results ~= result;
1516         values.put(ctx, results);
1517         debug {
1518             debugInfo.write(format("%s exitTerm:\n", counter++));
1519             debugInfo.write(format("\tifTests -> %s\n", ifTests.get(ctx.parent)));
1520             debugInfo.write(format("\tctx.children -> %s\n", ctx.children));
1521             debugInfo.write(format("\tresults -> %s\n", results));
1522         }
1523     }
1524     /**
1525      * {@inheritDoc}
1526      *
1527      * <p>The default implementation does nothing.</p>
1528      */
1529     override public void enterFactor(RuleTranslatorParser.FactorContext ctx) {
1530         debug {
1531             debugInfo.write(format("%s enterFactor:\n", counter++));
1532         }
1533     }
1534     /**
1535      * {@inheritDoc}
1536      *
1537      * <p>The default implementation does nothing.</p>
1538      */
1539     override public void exitFactor(RuleTranslatorParser.FactorContext ctx) {
1540         Result[] results;
1541         Result result;
1542         string[] append;
1543         foreach (i, child; ctx.children) {
1544             debug debugInfo.write(format("\t%s: ctx.child -> %s\n", i, child.getText));
1545             append ~= child.getText;
1546         }
1547         import std.array : join;
1548         ifTests.put(ctx.getParent, join(append, '.'));
1549         result.text ~= join(append, '.');
1550         results ~= result;
1551         values.put(ctx, results);
1552         debug {
1553             debugInfo.write(format("%s exitFactor:\n", counter++));
1554             debugInfo.write(format("\tifTests -> %s\n", ifTests.get(ctx.parent)));
1555             debugInfo.write(format("\tctx.children -> %s\n", ctx.children));
1556             debugInfo.write(format("\tresults -> %s\n", results));
1557         }
1558     }
1559     /**
1560      * {@inheritDoc}
1561      *
1562      * <p>The default implementation does nothing.</p>
1563      */
1564     override public void enterAtom_dotted_name(RuleTranslatorParser.Atom_dotted_nameContext ctx) {
1565         debug {
1566             debugInfo.write(format("%s enterAtom_dotted_name:\n", counter++));
1567         }
1568     }
1569     /**
1570      * {@inheritDoc}
1571      *
1572      * <p>The default implementation does nothing.</p>
1573      */
1574     override public void exitAtom_dotted_name(RuleTranslatorParser.Atom_dotted_nameContext ctx) {
1575         Result[] results;
1576         Result result;
1577         string[] append;
1578         foreach (i, child; ctx.children) {
1579             debug debugInfo.write(format("\t%s: ctx.child -> %s\n", i, child.getText));
1580             append ~= child.getText;
1581         }
1582         import std.array : join;
1583         ifTests.put(ctx.getParent, join(append, '.'));
1584         result.text ~= join(append, '.');
1585         results ~= result;
1586         values.put(ctx, results);
1587         debug {
1588             debugInfo.write(format("%s exitAtom_dotted_name:\n", counter++));
1589             debugInfo.write(format("\tgetText -> %s\n", ctx.getText));
1590             debugInfo.write(format("\tctx.children) -> %s\n", ctx.children));
1591             debugInfo.write(format("\tifTest -> %s\n", ifTests.get(ctx.getParent)));
1592         }
1593     }
1594     /**
1595      * {@inheritDoc}
1596      *
1597      * <p>The default implementation does nothing.</p>
1598      */
1599     override public void enterAtom_funct_stmt(RuleTranslatorParser.Atom_funct_stmtContext ctx) { }
1600     /**
1601      * {@inheritDoc}
1602      *
1603      * <p>The default implementation does nothing.</p>
1604      */
1605     override public void exitAtom_funct_stmt(RuleTranslatorParser.Atom_funct_stmtContext ctx) { }
1606     /**
1607      * {@inheritDoc}
1608      *
1609      * <p>The default implementation does nothing.</p>
1610      */
1611     override public void enterNumber_e(RuleTranslatorParser.Number_eContext ctx) { }
1612     /**
1613      * {@inheritDoc}
1614      *
1615      * <p>The default implementation does nothing.</p>
1616      */
1617     override public void exitNumber_e(RuleTranslatorParser.Number_eContext ctx) { }
1618     /**
1619      * {@inheritDoc}
1620      *
1621      * <p>The default implementation does nothing.</p>
1622      */
1623     override public void enterString_e(RuleTranslatorParser.String_eContext ctx) { }
1624     /**
1625      * {@inheritDoc}
1626      *
1627      * <p>The default implementation does nothing.</p>
1628      */
1629     override public void exitString_e(RuleTranslatorParser.String_eContext ctx) { }
1630     /**
1631      * {@inheritDoc}
1632      *
1633      * <p>The default implementation does nothing.</p>
1634      */
1635     override public void enterTrue_e(RuleTranslatorParser.True_eContext ctx) { }
1636     /**
1637      * {@inheritDoc}
1638      *
1639      * <p>The default implementation does nothing.</p>
1640      */
1641     override public void exitTrue_e(RuleTranslatorParser.True_eContext ctx) { }
1642     /**
1643      * {@inheritDoc}
1644      *
1645      * <p>The default implementation does nothing.</p>
1646      */
1647     override public void enterFalse_e(RuleTranslatorParser.False_eContext ctx) { }
1648     /**
1649      * {@inheritDoc}
1650      *
1651      * <p>The default implementation does nothing.</p>
1652      */
1653     override public void exitFalse_e(RuleTranslatorParser.False_eContext ctx) { }
1654     /**
1655      * {@inheritDoc}
1656      *
1657      * <p>The default implementation does nothing.</p>
1658      */
1659     override public void enterLast_e(RuleTranslatorParser.Last_eContext ctx) { }
1660     /**
1661      * {@inheritDoc}
1662      *
1663      * <p>The default implementation does nothing.</p>
1664      */
1665     override public void exitLast_e(RuleTranslatorParser.Last_eContext ctx) { }
1666     /**
1667      * {@inheritDoc}
1668      *
1669      * <p>The default implementation does nothing.</p>
1670      */
1671     override public void enterFirst_e(RuleTranslatorParser.First_eContext ctx) { }
1672     /**
1673      * {@inheritDoc}
1674      *
1675      * <p>The default implementation does nothing.</p>
1676      */
1677     override public void exitFirst_e(RuleTranslatorParser.First_eContext ctx) { }
1678     /**
1679      * {@inheritDoc}
1680      *
1681      * <p>The default implementation does nothing.</p>
1682      */
1683     override public void enterTestlist_comp(RuleTranslatorParser.Testlist_compContext ctx) { }
1684     /**
1685      * {@inheritDoc}
1686      *
1687      * <p>The default implementation does nothing.</p>
1688      */
1689     override public void exitTestlist_comp(RuleTranslatorParser.Testlist_compContext ctx) { }
1690     /**
1691      * {@inheritDoc}
1692      *
1693      * <p>The default implementation does nothing.</p>
1694      */
1695     override public void enterTrailer(RuleTranslatorParser.TrailerContext ctx) { }
1696     /**
1697      * {@inheritDoc}
1698      *
1699      * <p>The default implementation does nothing.</p>
1700      */
1701     override public void exitTrailer(RuleTranslatorParser.TrailerContext ctx) { }
1702     /**
1703      * {@inheritDoc}
1704      *
1705      * <p>The default implementation does nothing.</p>
1706      */
1707     override public void enterSubscriptlist(RuleTranslatorParser.SubscriptlistContext ctx) { }
1708     /**
1709      * {@inheritDoc}
1710      *
1711      * <p>The default implementation does nothing.</p>
1712      */
1713     override public void exitSubscriptlist(RuleTranslatorParser.SubscriptlistContext ctx) { }
1714     /**
1715      * {@inheritDoc}
1716      *
1717      * <p>The default implementation does nothing.</p>
1718      */
1719     override public void enterSubscript(RuleTranslatorParser.SubscriptContext ctx) { }
1720     /**
1721      * {@inheritDoc}
1722      *
1723      * <p>The default implementation does nothing.</p>
1724      */
1725     override public void exitSubscript(RuleTranslatorParser.SubscriptContext ctx) { }
1726     /**
1727      * {@inheritDoc}
1728      *
1729      * <p>The default implementation does nothing.</p>
1730      */
1731     override public void enterSliceop(RuleTranslatorParser.SliceopContext ctx) { }
1732     /**
1733      * {@inheritDoc}
1734      *
1735      * <p>The default implementation does nothing.</p>
1736      */
1737     override public void exitSliceop(RuleTranslatorParser.SliceopContext ctx) { }
1738     /**
1739      * {@inheritDoc}
1740      *
1741      * <p>The default implementation does nothing.</p>
1742      */
1743     override public void enterExprlist(RuleTranslatorParser.ExprlistContext ctx) { }
1744     /**
1745      * {@inheritDoc}
1746      *
1747      * <p>The default implementation does nothing.</p>
1748      */
1749     override public void exitExprlist(RuleTranslatorParser.ExprlistContext ctx) { }
1750     /**
1751      * {@inheritDoc}
1752      *
1753      * <p>The default implementation does nothing.</p>
1754      */
1755     override public void enterTestlist(RuleTranslatorParser.TestlistContext ctx) { }
1756     /**
1757      * {@inheritDoc}
1758      *
1759      * <p>The default implementation does nothing.</p>
1760      */
1761     override public void exitTestlist(RuleTranslatorParser.TestlistContext ctx) { }
1762     /**
1763      * {@inheritDoc}
1764      *
1765      * <p>The default implementation does nothing.</p>
1766      */
1767     override public void enterDictorsetmaker(RuleTranslatorParser.DictorsetmakerContext ctx) { }
1768     /**
1769      * {@inheritDoc}
1770      *
1771      * <p>The default implementation does nothing.</p>
1772      */
1773     override public void exitDictorsetmaker(RuleTranslatorParser.DictorsetmakerContext ctx) { }
1774     /**
1775      * {@inheritDoc}
1776      *
1777      * <p>The default implementation does nothing.</p>
1778      */
1779     override public void enterArglist(RuleTranslatorParser.ArglistContext ctx) { }
1780     /**
1781      * {@inheritDoc}
1782      *
1783      * <p>The default implementation does nothing.</p>
1784      */
1785     override public void exitArglist(RuleTranslatorParser.ArglistContext ctx) { }
1786     /**
1787      * {@inheritDoc}
1788      *
1789      * <p>The default implementation does nothing.</p>
1790      */
1791     override public void enterArgument(RuleTranslatorParser.ArgumentContext ctx) { }
1792     /**
1793      * {@inheritDoc}
1794      *
1795      * <p>The default implementation does nothing.</p>
1796      */
1797     override public void exitArgument(RuleTranslatorParser.ArgumentContext ctx) { }
1798 
1799     /**
1800      * {@inheritDoc}
1801      *
1802      * <p>The default implementation does nothing.</p>
1803      */
1804     override public void enterEveryRule(ParserRuleContext ctx) { }
1805     /**
1806      * {@inheritDoc}
1807      *
1808      * <p>The default implementation does nothing.</p>
1809      */
1810     override public void exitEveryRule(ParserRuleContext ctx) { }
1811     /**
1812      * {@inheritDoc}
1813      *
1814      * <p>The default implementation does nothing.</p>
1815      */
1816     override public void visitTerminal(TerminalNode node) { }
1817     /**
1818      * {@inheritDoc}
1819      *
1820      * <p>The default implementation does nothing.</p>
1821      */
1822     override public void visitErrorNode(ErrorNode node) { }
1823 }