コード例 #1
0
        public void MgrMacroParametersTest()
        {
            MIPreFsh b = ParseTest("MgrMacroParametersTest.mfsh", out MFsh mfsh);

            Assert.True(mfsh.MacroMgr.TryGetItem(null, "Macro1", out MIApplicable item1));
            MIMacro macro1 = (MIMacro)item1;

            Assert.True(macro1.Parameters.Count == 3);
            Assert.True(macro1.Parameters[0] == "Param1");
            Assert.True(macro1.Parameters[1] == "Param2");
            Assert.True(macro1.Parameters[2] == "Param3");
        }
コード例 #2
0
        public void MgrMacroRedirectTest()
        {
            MIPreFsh b = ParseTest("MgrMacroRedirectTest.mfsh", out MFsh mfsh);

            if (mfsh.MacroMgr.TryGetItem(null, "Macro1", out MIApplicable item1) == false)
            {
                Assert.True(false);
                throw new NotImplementedException();
            }
            MIMacro macro1 = (MIMacro)item1;

            Assert.True(macro1.Redirect == @"A\B.txt");
            Assert.True(macro1.OnceFlag == true);
        }
コード例 #3
0
        public override object VisitMacro(MFSHParser.MacroContext context)
        {
            const String fcn = "VisitMacro";

            this.TraceMsg(context, fcn);
            String[] names = context
                             .NAME()
                             .Select((a) => a.GetText())
                             .ToArray();
            MIMacro    macro      = new MIMacro(this.SourceName, context.Start.Line, names[0], names.Skip(1));
            MacroBlock macroBlock = new MacroBlock("macro", macro);

            this.PushState(macroBlock);

            var redirectContext = context.redirect();

            if (redirectContext != null)
            {
                macro.Redirect = (String)(this.Visit(redirectContext.singleString()));
            }
            macro.OnceFlag = context.ONCE() != null;

            return(null);
        }