Example #1
0
        public override Object VisitIf([NotNull] MFSHParser.IfContext context)
        {
            const String fcn = "VisitIf";

            this.TraceMsg(context, fcn);
            ConditionalBlock conditionalBlock = new ConditionalBlock(this.SourceName,
                                                                     context.Start.Line);

            this.PushState(conditionalBlock);
            MIConditional.Condition condition = new MIConditional.Condition();
            condition.State = (MIConditional.CState) this.Visit(context.condition());
            conditionalBlock.AddCondition(condition);
            return(null);
        }
Example #2
0
        public override Object VisitElse([NotNull] MFSHParser.ElseContext context)
        {
            const String fcn = "VisitElse";

            this.TraceMsg(context, fcn);
            ConditionalBlock conditionalBlock = this.Current as ConditionalBlock;

            if (conditionalBlock == null)
            {
                this.Error(fcn,
                           context.Start.Line.ToString(),
                           $"Error '#else' found with no starting '#if'");
            }
            MIConditional.Condition condition = new MIConditional.Condition();
            condition.State = new MIConditional.CStateTrue();
            conditionalBlock.AddCondition(condition);
            return(null);
        }