示例#1
0
        public static void Main(string[] args)
        {
            // Create and register channel
            TcpChannel channel = new TcpChannel(PuppetMasterService.Constants.PUPPET_MASTER_PORT);

            ChannelServices.RegisterChannel(channel, false);

            IBasicVisitor interpreter = new Interpreter();

            try {
                if (args.Length == 1)
                {
                    Console.WriteLine("Reading file...");
                    Script script = Parser.Parse(System.IO.File.ReadAllLines(args[0]));
                    script.Accept(interpreter);
                }
            } catch (Exception ex) {
                if (ex is IncorrectCommandException)
                {
                    Console.WriteLine(ex.Message);
                }
                else
                {
                    throw;
                }
            }

            while (true)
            {
                try {
                    Console.Write(">>> ");
                    Parser.Parse(Console.ReadLine()).Accept(interpreter);
                } catch (Exception ex) {
                    if (ex is IncorrectCommandException)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
示例#2
0
 static void RunScript(Script script, IDidaVisitor visitor)
 {
     script.Accept(visitor);
 }
示例#3
0
 public void Accept(IProcessDefinitionVisitor visitor)
 {
     Script?.Accept(visitor);
     visitor.Visit(this);
 }