public override ParsedDocument Parse(ProjectDom dom, string fileName, string content)
{
var document = new ParsedDocument (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;
}