コード例 #1
0
ファイル: Program.cs プロジェクト: yongweisun/SharpVk
        static void Main(string[] args)
        {
            var xmlCache  = new VkXmlCache(".\\VkTemplates");
            var jsonCache = new SpirvJsonCache(".\\VkTemplates");

            var parser    = new SpecParser(xmlCache, ".\\VkTemplates");
            var generator = new TypeGenerator();

            var types = generator.Generate(parser.Run());

            var fileGenerator = new FileGenerator("..\\..\\..\\SharpVk");

            foreach (var modelGenerator in new ModelGenerator <TypeSet>[]
            {
                new VkCommandsGenerator(),
                new VkHandleGenerator(),
                new VkDelegateGenerator(),
                new VkEnumGenerator(),
                new VkStructsGenerator(),
                new VkUnionsGenerator(),
                new VkExceptionGenerator(),
                new VkConstantGenerator(),
                new VkInteropStructsGenerator()
            })
            {
                modelGenerator.Run(types, fileGenerator);
            }

            new SpirvEnumGenerator().Run(jsonCache.GetSpirvModel(), fileGenerator);

            var grammarModel = jsonCache.GetSpirvGrammar();

            new SpirvOpCodeGenerator().Run(grammarModel, fileGenerator);
            new SpirvOperandKindGenerator().Run(grammarModel, fileGenerator);
        }
コード例 #2
0
ファイル: TextParser.cs プロジェクト: storyteller/Storyteller
        public static Specification Parse(string text)
        {
            var parser = new SpecParser();
            text.ReadLines(x => parser.Read(x.Trim()));

            return parser.Specification;
        }
コード例 #3
0
        public static Specification Parse(string text)
        {
            var parser = new SpecParser();

            text.ReadLines(x => parser.Read(x.Trim()));

            return(parser.Specification);
        }
コード例 #4
0
 /// <summary>
 /// "Load" and parse flags specification from a string.
 /// </summary>
 private static TristateBitArray LoadFlags(Specification spec, string flags)
 {
     try {
         return(SpecParser.ParseFlags(spec, flags));
     } catch (System.Data.SyntaxErrorException e) {
         Console.WriteLine(e.Message);
         Environment.Exit(1);
         throw;  // unreachable
     }
 }
コード例 #5
0
        protected void messageReceived(ConnectionEventArgs a)
        {
            PUC.Communication.Message msg = a.GetMessage();

            if (msg is DeviceSpec)
            {
                DeviceSpec dmsg = (DeviceSpec)msg;

                Appliance appl = new Appliance(this);

#if POCKETPC
                Globals.AddFrameMapping(appl, PUCFrame.DEFAULT_FRAME);
#endif
#if SMARTPHONE
                Globals.AddFrameMapping(appl, PhonePUC.PUCFrame.DEFAULT_FRAME);
#endif
#if DESKTOP && !DEBUGSVR
                // TODO: Make DesktopPUC use multiple windows, like Debug Server
                Globals.AddFrameMapping(appl, DesktopPUC.PUCFrame.DEFAULT_FRAME);
#endif

                try
                {
                    SpecParser.Parse(new StringReader(dmsg.GetSpec()), appl);

                    MenuItem mi = new MenuItem();
                    mi.Text = appl.Name;
                    appl.SetMenuItem(mi);

                    _server.ActivateAppliance(this, appl);

                    Cursor.Current = Cursors.Default;

                    _connection.MessageReceivedEvent    -= new Connection.MessageReceivedHandler(this.messageReceived);
                    _connection.ConnectionRegainedEvent -= new Connection.ConnectionRegainedHandler(this.connectionRegained);
                    _connection.ConnectionLostEvent     += new Connection.ConnectionLostHandler(appl.ConnectionLost);
                    _connection.MessageReceivedEvent    += new Connection.MessageReceivedHandler(appl.MessageReceived);
                    _connection.ConnectionRegainedEvent += new Connection.ConnectionRegainedHandler(appl.ConnectionRegained);

                    FullStateRequest fsrMsg = new FullStateRequest();
                    _connection.Send(fsrMsg);
                }
                catch (Exception e)
                {
                    Globals.GetFrame(appl).AddLogLine(e.ToString());
                    Cursor.Current = Cursors.Default;
                }
            }
        }
コード例 #6
0
        static void Main(string[] args)
        {
            try
            {
                var    specParser = new SpecParser();
                var    errorCount = 0;
                string outputFile = args[1] + ".output.csv";
                using (var sr = new StreamReader(args[0]))
                    using (var data = new FileStream(args[1], FileMode.Open, FileAccess.Read))
                        using (var output = new StreamWriter(args[1] + ".output.csv"))
                        {
                            var importer = new Importer(specParser.Parse(sr));
                            var listener = new CsvOutputListener(output);
                            importer.Import(data, listener);
                            listener.Task.Wait();
                            errorCount = listener.Errors;
                        }
                if (errorCount > 0)
                {
                    File.Delete(outputFile);
                    WriteLine("No output created.");
                }
                else
                {
                    WriteLine($"Output in in \"{outputFile}\"");
                }
            }
            catch (Exception ex)
            {
                WriteLine($"Error: {ex.Message}");
            }
#if DEBUG
            WriteLine("Press any key to continue");
            ReadKey();
#endif
        }