예제 #1
0
        public void TestParserCreation()
        {
            Assert.IsNotNull(Pie.Parser.Create());

            try
            {
                PieCodeProvider provider = new PieCodeProvider();
                provider.CreateGenerator();
                Assert.Fail();
            }
            catch(NotImplementedException e)
            {
                // Just to get rid of the "variable is never used" warning
                Console.WriteLine(e.StackTrace);
            }

            try
            {
                PieCodeProvider provider = new PieCodeProvider();
                provider.CreateCompiler();
                Assert.Fail();
            }
            catch (NotImplementedException e)
            {
                // Just to get rid of the "variable is never used" warning
                Console.WriteLine(e.StackTrace);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            var file = new System.IO.StreamReader("PieCSource/Program.pie");

            string code = file.ReadToEnd();
            file.Close();

            CompilerParameters parameters = new CompilerParameters();
            parameters.ReferencedAssemblies.Add("Pie.dll");
            parameters.ReferencedAssemblies.Add("System.dll");
            parameters.GenerateInMemory = false;
            parameters.OutputAssembly = "piec.exe";
            parameters.GenerateExecutable = true;

            var provider = new PieCodeProvider();
            var results = provider.CompileAssemblyFromSource(parameters, code);

            foreach (CompilerError e in results.Errors)
            {
                Console.WriteLine(e.ErrorNumber + ", " + e.Line + ", " + e.Column + ": " + e.ErrorText);
            }

            if (results.Errors.Count == 0)
            {
                Type program = results.CompiledAssembly.GetType("Program");
                var main = program.GetMethod("Main");

                string[] strings = new string[] { "/out:test.exe", "TestCode/Program.pie", "TestCode/Hello.pie" };
                main.Invoke(null, new object[] { strings });
            }

            Console.ReadKey();
        }
예제 #3
0
        static void Main(string[] args)
        {
            var file = new System.IO.StreamReader("Source/Fibonacci.pie");

            string code = file.ReadToEnd();
            file.Close();

            CompilerParameters parameters = new CompilerParameters();
            parameters.GenerateInMemory = false;
            parameters.GenerateExecutable = true;
            parameters.OutputAssembly = "Fibonacci.exe";

            var provider = new PieCodeProvider();
            var results = provider.CompileAssemblyFromSource(parameters, code);

            foreach (CompilerError e in results.Errors)
                Console.WriteLine(e.ErrorText);

            Console.ReadKey();
        }