public static CreateParser ( CompilerContext context, PythonOptions options ) : |
||
context | CompilerContext | |
options | PythonOptions | |
Результат |
public DocumentationComment Parse(ProjectDom dom, string fileName, string content) { var document = new DocumentationComment(fileName); var compilationUnit = new PythonCompilationUnit(fileName); document.CompilationUnit = compilationUnit; if (String.IsNullOrEmpty(content)) { return(document); } var scriptSource = pythonEngine.CreateScriptSourceFromString(content, SourceCodeKind.File); var context = new CompilerContext(HostingHelpers.GetSourceUnit(scriptSource), compilerOptions, ErrorSink.Default); var parser = IronPythonParserEngine.CreateParser(context, langOptions); IronPythonAst ast = null; try { ast = parser.ParseFile(false); } catch (SyntaxErrorException exc) { // We could likely improve the error message document.Errors.Add(new Error(exc.Line, exc.Column, exc.Message)); return(document); } walker.Reset(); ast.Walk(walker); compilationUnit.Module = walker.Module; compilationUnit.Build(); return(document); }