Ejemplo n.º 1
0
        static int Main(string[] args)
        {
            var p = Parser.Default.ParseArguments <Options>(args);

            if (p is NotParsed <Options> )
            {
                return(1);
            }

            var opts = ((Parsed <Options>)p).Value;

            var text = File.ReadAllText(opts.Input);
            var ast  = AstParser.Parse(text);

            if (opts.CppOutput != null)
            {
                File.WriteAllText(opts.CppOutput, CppGen.GenerateCpp(ast));
            }
            if (opts.CSharpOutput != null)
            {
                File.WriteAllText(opts.CSharpOutput, new CSharpGen(ast).Generate());
            }

            return(0);
        }
Ejemplo n.º 2
0
        static int Main(string[] args)
        {
            var p = Parser.Default.ParseArguments <Options>(args);

            if (p is NotParsed <Options> )
            {
                return(1);
            }

            var opts = ((Parsed <Options>)p).Value;

            var text = File.ReadAllText(opts.Input);
            var ast  = AstParser.Parse(text);

            if (opts.CppOutput != null)
            {
                File.WriteAllText(opts.CppOutput, CppGen.GenerateCpp(ast));
            }

            if (opts.CSharpOutput != null)
            {
                File.WriteAllText(opts.CSharpOutput, new CSharpGen(ast).Generate());

                // HACK: Can't work out how to get the VS project system's fast up-to-date checks
                // to ignore the generated code, so as a workaround set the write time to that of
                // the input.
                File.SetLastWriteTime(opts.CSharpOutput, File.GetLastWriteTime(opts.Input));
            }

            return(0);
        }