示例#1
0
        public override object VisitEnd(MFSHParser.EndContext context)
        {
            const String fcn = "VisitEnd";

            this.TraceMsg(context, fcn);

            ParseBlock s = this.PopState();

            switch (s)
            {
            case UseBlock useBlock:
                this.Usings.Remove(useBlock.Use);
                this.Current.Items.AddRange(useBlock.Items);
                break;

            case MacroBlock macroBlock:

                if (this.mfsh.MacroMgr.TryAddItem(macroBlock.Item.Name, macroBlock.Item) == false)
                {
                    this.Error(fcn,
                               context.Start.Line.ToString(),
                               $"Error adding macro '{macroBlock.Item.Name}'. Does macro already exist?");
                }
                break;

            case ConditionalBlock conditionalBlock:
                this.Current.Items.Add(conditionalBlock.Conditional);
                break;

            default:
                this.Error(fcn,
                           context.Start.Line.ToString(),
                           $"Unexpected '#end'");
                throw new Exception($"Unexpected '#end'");
            }
            return(null);
        }
示例#2
0
 void PushState(ParseBlock s) => this.state.Push(s);