private static Parser CreateParserWorker(CompilerContext context, PythonOptions options, bool verbatim) {
ContractUtils.RequiresNotNull(context, "context");
ContractUtils.RequiresNotNull(options, "options");
PythonCompilerOptions compilerOptions = context.Options as PythonCompilerOptions;
if (options == null) {
throw new ValueErrorException(Resources.PythonContextRequired);
}
SourceCodeReader reader;
try {
reader = context.SourceUnit.GetReader();
if (compilerOptions.SkipFirstLine) {
reader.ReadLine();
}
} catch (IOException e) {
context.Errors.Add(context.SourceUnit, e.Message, SourceSpan.Invalid, 0, Severity.Error);
throw;
}
Tokenizer tokenizer = new Tokenizer(context.Errors, compilerOptions, verbatim);
tokenizer.Initialize(null, reader, context.SourceUnit, SourceLocation.MinValue);
tokenizer.IndentationInconsistencySeverity = options.IndentationInconsistencySeverity;
Parser result = new Parser(context, tokenizer, context.Errors, context.ParserSink, compilerOptions.Module);
result._sourceReader = reader;
return result;
}