public CompilerContext(CompilerSettings settings, ReportPrinter reportPrinter) { this.settings = settings; this.report = new Report(this, reportPrinter); this.builtin_types = new BuiltinTypes(); this.TimeReporter = DisabledTimeReporter; }
// // Prints collected messages, common messages have a priority // public bool Merge(ReportPrinter dest) { var messages_to_print = merged_messages; if (common_messages != null && common_messages.Count > 0) { messages_to_print = common_messages; } if (messages_to_print == null) { return(false); } bool error_msg = false; foreach (AbstractMessage msg in messages_to_print) { dest.Print(msg, showFullPaths); error_msg |= !msg.IsWarning; } if (reported_missing_definitions != null) { foreach (var missing in reported_missing_definitions) { dest.MissingTypeReported(missing); } } return(error_msg); }
public ReportPrinter SetPrinter(ReportPrinter printer) { ReportPrinter old = this.printer; this.printer = printer; return(old); }
public Report (CompilerContext context, ReportPrinter printer) { if (context == null) throw new ArgumentNullException ("settings"); if (printer == null) throw new ArgumentNullException ("printer"); this.settings = context.Settings; this.printer = printer; }
public Report(CompilerContext context, ReportPrinter printer) { if (context == null) { throw new ArgumentNullException("settings"); } if (printer == null) { throw new ArgumentNullException("printer"); } this.settings = context.Settings; this.printer = printer; }
// // Parses the string @input and returns a CSharpParser if succeeful. // // if @silent is set to true then no errors are // reported to the user. This is used to do various calls to the // parser and check if the expression is parsable. // // @partial_input: if @silent is true, then it returns whether the // parsed expression was partial, and more data is needed // CSharpParser ParseString(ParseMode mode, string input, out bool partial_input) { partial_input = false; Reset(); var enc = ctx.Settings.Encoding; var s = new MemoryStream(enc.GetBytes(input)); SeekableStreamReader seekable = new SeekableStreamReader(s, enc); InputKind kind = ToplevelOrStatement(seekable); if (kind == InputKind.Error) { if (mode == ParseMode.ReportErrors) { ctx.Report.Error(-25, "Detection Parsing Error"); } partial_input = false; return(null); } if (kind == InputKind.EOF) { if (mode == ParseMode.ReportErrors) { Console.Error.WriteLine("Internal error: EOF condition should have been detected in a previous call with silent=true"); } partial_input = true; return(null); } seekable.Position = 0; source_file.DeclarationFound = false; CSharpParser parser = new CSharpParser(seekable, source_file, new ParserSession()); if (kind == InputKind.StatementOrExpression) { parser.Lexer.putback_char = Tokenizer.EvalStatementParserCharacter; parser.Lexer.parsing_block++; ctx.Settings.StatementMode = true; } else { parser.Lexer.putback_char = Tokenizer.EvalCompilationUnitParserCharacter; ctx.Settings.StatementMode = false; } if (mode == ParseMode.GetCompletions) { parser.Lexer.CompleteOnEOF = true; } ReportPrinter old_printer = null; if ((mode == ParseMode.Silent || mode == ParseMode.GetCompletions)) { old_printer = ctx.Report.SetPrinter(new StreamReportPrinter(TextWriter.Null)); } try { parser.parse(); } finally { if (ctx.Report.Errors != 0) { if (mode != ParseMode.ReportErrors && parser.UnexpectedEOF) { partial_input = true; } if (parser.undo != null) { parser.undo.ExecuteUndo(); } parser = null; } if (old_printer != null) { ctx.Report.SetPrinter(old_printer); } } return(parser); }
public CompilerContext (CompilerSettings settings, ReportPrinter reportPrinter) { this.settings = settings; this.report = new Report (this, reportPrinter); this.builtin_types = new BuiltinTypes (); this.TimeReporter = DisabledTimeReporter; }
// // Prints collected messages, common messages have a priority // public bool Merge (ReportPrinter dest) { var messages_to_print = merged_messages; if (common_messages != null && common_messages.Count > 0) { messages_to_print = common_messages; } if (messages_to_print == null) return false; bool error_msg = false; foreach (AbstractMessage msg in messages_to_print) { dest.Print (msg, showFullPaths); error_msg |= !msg.IsWarning; } if (reported_missing_definitions != null) { foreach (var missing in reported_missing_definitions) dest.MissingTypeReported (missing); } return error_msg; }
public ReportPrinter SetPrinter (ReportPrinter printer) { ReportPrinter old = this.printer; this.printer = printer; return old; }