public Translate ( IEnumerable |
||
statements | IEnumerable |
|
return | void |
private string XlatModule(string pyModule, string filename = "module.py") { var rdr = new StringReader(pyModule); var lex = new Lexer(filename, rdr); var par = new Parser(filename, lex); var stm = par.Parse().ToList(); var unt = new CodeCompileUnit(); var gen = new CodeGenerator(unt, "test", Path.GetFileNameWithoutExtension(filename)); var opt = new Dictionary <string, object> { { "quiet", true } }; var ana = new AnalyzerImpl(fs, logger, opt, DateTime.Now); var mod = new Module( "module", new SuiteStatement(stm, filename, 0, 0), filename, 0, 0); ana.LoadModule(mod); var types = new TypeReferenceTranslator(ana.BuildTypeDictionary()); var xlt = new ModuleTranslator(types, gen); xlt.Translate(stm); var pvd = new CSharpCodeProvider(); var writer = new StringWriter(); pvd.GenerateCodeFromCompileUnit(unt, writer, new CodeGeneratorOptions { }); return(writer.ToString()); }
public void Translate(string filename, TextReader input, TextWriter output) { Debug.Print("Translating module {0} in namespace {1}", moduleName, nmspace); var lex = new Lexer(filename, input); var par = new Parser(filename, lex); var stm = par.Parse(); var unt = new CodeCompileUnit(); var gen = new CodeGenerator(unt, nmspace, Path.GetFileNameWithoutExtension(moduleName)); var xlt = new ModuleTranslator(gen); xlt.Translate(stm); var pvd = new CSharpCodeProvider(); pvd.GenerateCodeFromCompileUnit(unt, output, new CodeGeneratorOptions { }); }
private string XlatModule(string pyModule, string filename = "module.py") { var rdr = new StringReader(pyModule); var lex = new Syntax.Lexer(filename, rdr); var par = new Syntax.Parser(filename, lex); var stm = par.Parse(); var unt = new CodeCompileUnit(); var gen = new CodeGenerator(unt, "test", Path.GetFileNameWithoutExtension(filename)); var xlt = new ModuleTranslator(scope, gen); xlt.Translate(stm); var pvd = new CSharpCodeProvider(); var writer = new StringWriter(); pvd.GenerateCodeFromCompileUnit(unt, writer, new CodeGeneratorOptions { }); return(writer.ToString()); }
private string XlatModule(string pyModule) { var rdr = new StringReader(pyModule); var lex = new Syntax.Lexer("foo.py", rdr); var par = new Syntax.Parser("foo.py", lex); var stm = par.Parse(); ; var unt = new CodeCompileUnit(); var gen = new CodeGenerator(unt, "test", "testModule"); var xlt = new ModuleTranslator(gen); xlt.Translate(stm); var pvd = new CSharpCodeProvider(); var writer = new StringWriter(); pvd.GenerateCodeFromCompileUnit( unt, writer, new CodeGeneratorOptions { }); return writer.ToString(); }