Extremely light/primitive parser
Beispiel #1
0
        public CompilerResults CompileAssemblyFromFileBatch(CompilerParameters options, string[] fileNames)
        {
            string        tempFile;
            ArrayList     classlessFiles = new ArrayList();
            ArrayList     files          = new ArrayList();
            int           count          = 0;
            CCSharpParser ccs;

            foreach (string file in fileNames)
            {
                ccs = new CCSharpParser(file);
                if (!ccs.isClassless)
                {
                    files.Add(file);
                }
                else
                {
                    tempFile = ccs.ToTempFile(count > 0);
                    classlessFiles.Add(tempFile);
                    files.Add(tempFile);
                }
                count++;
            }

            Microsoft.CSharp.CSharpCodeProvider provider;

            if (options.ToString() == "" || options == null)
            {
                return(new Microsoft.CSharp.CSharpCodeProvider().CreateCompiler().CompileAssemblyFromFileBatch(options, fileNames));
            }
            else
            {
                return(new Microsoft.CSharp.CSharpCodeProvider(new Dictionary <string, string>()
                {
                    { "CompilerVersion", options.ToString() }
                }).CreateCompiler().CompileAssemblyFromFileBatch(options, fileNames));
            }

            CompilerResults retval;

            retval = provider.CreateCompiler().CompileAssemblyFromFileBatch(options, (string[])files.ToArray(typeof(string)));


            if (!retval.Errors.HasErrors)
            {
                foreach (string file in classlessFiles)
                {
                    try
                    {
                        File.Delete(file);
                    }
                    catch {}
                }
            }

            return(retval);
        }
Beispiel #2
0
        static void i_Main()
        {
            CCSharpParser ccs = new CCSharpParser(@"C:\cs-script\Dev\CC#\using.ccs");

            if (ccs.isClassless)
            {
                Console.WriteLine("CC#");
                Console.WriteLine(ccs.CSharpCode);
            }
            else
            {
                Console.WriteLine("C#");
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            string[] files = new[] { @"E:\cs-script\Samples\hello.cpp" };

            var cParams = new CompilerParameters();
            cParams.OutputAssembly = @"C:\Users\osh\AppData\Local\Temp\CSSCRIPT\Cache\-727015236\hello.cpp.dll";
            cParams.ReferencedAssemblies.Add(@"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll");
            cParams.ReferencedAssemblies.Add(@"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Linq\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Linq.dll");
            cParams.ReferencedAssemblies.Add(@"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll");

            var compiler = new CPPCompiler();
            compiler.CompileAssemblyFromFileBatch(cParams, files);


            var parser = new CCSharpParser(@"E:\cs-script\engine\CSSCodeProvider.v3.5\Script.cs");
            parser.ToTempFile(false);
        }
Beispiel #4
0
		public CompilerResults CompileAssemblyFromFileBatch(CompilerParameters options, string[] fileNames)
		{
			string tempFile;
			ArrayList classlessFiles = new ArrayList(); 
			ArrayList files = new ArrayList();
			int count = 0;
			CCSharpParser ccs;
			foreach (string file in fileNames)
			{
				ccs = new CCSharpParser(file);
				if (!ccs.isClassless)
				{
					files.Add(file);
				}
				else
				{
					tempFile = ccs.ToTempFile(count > 0 );
					classlessFiles.Add(tempFile);
					files.Add(tempFile);
				}
				count++;
			}
			
            Microsoft.CSharp.CSharpCodeProvider provider;

            if (options.ToString() == "" || options == null)
                return new Microsoft.CSharp.CSharpCodeProvider().CreateCompiler().CompileAssemblyFromFileBatch(options, fileNames);
            else
                return new Microsoft.CSharp.CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", options.ToString() } }).CreateCompiler().CompileAssemblyFromFileBatch(options, fileNames);

            CompilerResults retval;
            retval = provider.CreateCompiler().CompileAssemblyFromFileBatch(options, (string[])files.ToArray(typeof(string)));
			
			
			if (!retval.Errors.HasErrors)
				foreach (string file in classlessFiles)
					try
					{ 
						File.Delete(file);
					} 
					catch{}

			return retval;
		}
Beispiel #5
0
		public CompilerResults CompileAssemblyFromFileBatch(CompilerParameters options, string[] fileNames)
		{
			string tempFile;
			ArrayList classlessFiles = new ArrayList(); 
			ArrayList files = new ArrayList();
			int count = 0;
			CCSharpParser ccs;
			foreach (string file in fileNames)
			{
				ccs = new CCSharpParser(file);
				if (!ccs.isClassless)
				{
					files.Add(file);
				}
				else
				{
					tempFile = ccs.ToTempFile(count > 0 );
					classlessFiles.Add(tempFile);
					files.Add(tempFile);
				}
				count++;
			}

			
				
			CompilerResults retval;

			retval = (new Microsoft.CSharp.CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromFileBatch(options, (string[])files.ToArray(typeof(string)));
			
			
			if (!retval.Errors.HasErrors)
				foreach (string file in classlessFiles)
					try
					{ 
						File.Delete(file);
					} 
					catch{}

			return retval;
		}
Beispiel #6
0
		static void i_Main()
		{
			CCSharpParser ccs = new CCSharpParser(@"C:\cs-script\Dev\CC#\using.ccs");
			if (ccs.isClassless)
			{
				Console.WriteLine("CC#");
				Console.WriteLine(ccs.CSharpCode);
			}
			else
				Console.WriteLine("C#");
		}
Beispiel #7
0
 static void Main(string[] args)
 {
     var parser = new CCSharpParser(@"E:\cs-script\engine\CSSCodeProvider.v3.5\Script.cs");
     parser.ToTempFile(false);
 }