Пример #1
0
        void OnFileParsed(string file, ParserResult result)
        {
            switch (result.Kind)
            {
            case ParserResultKind.Success:
                Diagnostics.EmitMessage(DiagnosticId.ParseResult,
                                        "Parsed '{0}'", file);
                break;

            case ParserResultKind.Error:
                Diagnostics.EmitError(DiagnosticId.ParseResult,
                                      "Error parsing '{0}'", file);
                break;

            case ParserResultKind.FileNotFound:
                Diagnostics.EmitError(DiagnosticId.ParseResult,
                                      "File '{0}' was not found", file);
                break;
            }

            for (uint i = 0; i < result.DiagnosticsCount; ++i)
            {
                var diag = result.getDiagnostics(i);

                if (Options.IgnoreParseWarnings &&
                    diag.Level == ParserDiagnosticLevel.Warning)
                {
                    continue;
                }

                if (diag.Level == ParserDiagnosticLevel.Note)
                {
                    continue;
                }

                Diagnostics.EmitMessage(DiagnosticId.ParserDiagnostic,
                                        "{0}({1},{2}): {3}: {4}", diag.FileName, diag.LineNumber,
                                        diag.ColumnNumber, diag.Level.ToString().ToLower(),
                                        diag.Message);
            }
        }
Пример #2
0
        void OnFileParsed(IEnumerable <string> files, ParserResult result)
        {
            switch (result.Kind)
            {
            case ParserResultKind.Success:
                Diagnostics.Message("Parsed '{0}'", string.Join(", ", files));
                break;

            case ParserResultKind.Error:
                Diagnostics.Error("Error parsing '{0}'", string.Join(", ", files));
                hasParsingErrors = true;
                break;

            case ParserResultKind.FileNotFound:
                Diagnostics.Error("A file from '{0}' was not found", string.Join(",", files));
                break;
            }

            for (uint i = 0; i < result.DiagnosticsCount; ++i)
            {
                var diag = result.getDiagnostics(i);

                if (Options.IgnoreParseWarnings &&
                    diag.Level == ParserDiagnosticLevel.Warning)
                {
                    continue;
                }

                if (diag.Level == ParserDiagnosticLevel.Note)
                {
                    continue;
                }

                Diagnostics.Message("{0}({1},{2}): {3}: {4}",
                                    diag.FileName, diag.LineNumber, diag.ColumnNumber,
                                    diag.Level.ToString().ToLower(), diag.Message);
            }
        }