public Compiler getCompiler(ProgrammingLanguageEnum languageEnum) { Compiler comp = null; if (languageEnum == ProgrammingLanguageEnum.Cpp89) { comp = new CPPCompiler(GPP_COMPILER_PATH, "-std=c++98"); } else if (languageEnum == ProgrammingLanguageEnum.Cpp11) { comp = new CPPCompiler(GPP_COMPILER_PATH, "-std=c++11"); } else if (languageEnum == ProgrammingLanguageEnum.C) { comp = new CPPCompiler(GCC_COMPILER_PATH); } else if (languageEnum == ProgrammingLanguageEnum.Python3) { comp = new PythonCompiler(PYTHON_INTERPRETER_PATH); } else { comp = null; throw new Exception("Invalid programming languageEnum enum: " + languageEnum); } return(comp); }
public void DoCompile() { PythonCompiler pc = new PythonCompiler(files, outAsm, new CodeDomCompilerSink(this)); pc.IncludeDebugInformation = debugInfo; pc.TargetKind = peKind; pc.AutoImportAll = true; foreach (string s in refs) { pc.ReferencedAssemblies.Add(s); } try { pc.Compile(); try { compAssm = Assembly.LoadFrom(outAsm); } catch { errorCnt = 1; } } catch (CompilerException ex) { // errors occured during compilation errorCnt = Errors.Count; Errors.Add(new CompilerError("unknown", 0, 0, "unknown", ex.ToString())); } catch (Exception ex) { errorCnt++; Errors.Add(new CompilerError("unknown", 0, 0, "unknown", ex.ToString())); } }
public override string Render() { executableCode += ((PythonParser)parser).Parse(codeTemplate, variables, values); using (compiler = new PythonCompiler()) { compiler.Compile(executableCode); } return(compiler.Result); }
public void NoMainSpecifiedForLibraryThrowsNoError() { PythonCompiler compiler = new PythonCompiler(); compiler.TargetKind = PEFileKinds.Dll; compiler.OutputAssembly = "test.dll"; compiler.SourceFiles = new string[0]; compiler.MainFile = null; compiler.VerifyParameters(); }
public static void Main(string[] args) { var parser = new MoccaParser("../../../Example/middle_lang.mocca", CompileMode.FILE_PASS); var tree = parser.Parse(); var eval = tree.Eval(); Console.WriteLine(tree.PrintTree()); var compiler = new PythonCompiler(eval); Console.WriteLine(compiler.Compile()); }
public void NoMainFileSpecifiedForWindowsApplication() { try { PythonCompiler compiler = new PythonCompiler(); compiler.TargetKind = PEFileKinds.WindowApplication; compiler.OutputAssembly = "test.exe"; compiler.SourceFiles = new string[0]; compiler.MainFile = null; compiler.Compile(); Assert.Fail("Expected PythonCompilerException."); } catch (PythonCompilerException ex) { Assert.AreEqual(Resources.NoMainFileSpecified, ex.Message); } }