Exemplo n.º 1
0
 private void CopyMessages(LogMessageList parserMessages, LogMessageList messages, SourceLocation baseLocation, string v)
 {
     foreach (var other in parserMessages)
     {
         messages.Add(new LogMessage(other.Level, baseLocation + other.Location, v + other.Message, other.ParserState));
     }
 }
Exemplo n.º 2
0
        internal static string GetLogsAsText(LogMessageList messages)
        {
            StringBuilder sb = new StringBuilder();

            List <ProgramLog> errors = new List <ProgramLog>();

            foreach (LogMessage log in messages)
            {
                int line = log.Location.Line + 1;
                int col  = log.Location.Column + 1;

                string message = log.Message;
                string level   = log.Level.ToString();

                string type = log.Level == ErrorLevel.Info ? "LOG" : log.Level == ErrorLevel.Warning ? "ADVERTENCIA" : "ERROR";

                if (message.Contains("Syntax error"))
                {
                    level = "Sintactico";
                }

                ProgramLog error = new ProgramLog(line, col, message, type);

                sb.Append(error + Environment.NewLine);
            }

            return(sb.ToString());
        }
Exemplo n.º 3
0
 private void CopyMessages(LogMessageList fromList, LogMessageList toList, SourceLocation baseLocation, string messagePrefix)
 {
     foreach (var other in fromList)
     {
         toList.Add(new LogMessage(other.Level, baseLocation + other.Location, messagePrefix + other.Message, other.ParserState));
     }
 }//
Exemplo n.º 4
0
        public static string ParserMessageHTML(LogMessageList Tokens)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<!DOCTYPE html>").AppendLine("<html lang=\"es-GT\" xmlns=\"http://www.w3.org/1999/xhtml\">");
            sb.AppendFormat("<head>{0}{1}</head>", "<meta charset=\"utf-8\">", String.Format("<title>{0}</title>", "Reporte de errores")).AppendLine();
            sb.AppendLine("<style type=\"text/css\"> .tg  {border-collapse:collapse;border-spacing:0;border-color:#aabcfe;margin:0px auto;} .tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#aabcfe;color:#669;background-color:#e8edff;} .tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#aabcfe;color:#039;background-color:#b9c9fe;} .tg .tg-bf8s{background-color:#ffffff;color:#000000;border-color:#330001;text-align:left;vertical-align:top} .tg .tg-hlej{background-color:#c0c0c0;color:#000000;border-color:#330001;text-align:center;vertical-align:top} .tg .tg-pjo9{background-color:#9b9b9b;font-weight:bold;color:#000000;border-color:#330001;text-align:left;vertical-align:top} .tg .tg-qlpz{background-color:#ffffff;color:#000000;border-color:#330001;text-align:right;vertical-align:top} .tg .tg-ujlt{background-color:#ffffff;color:#000000;border-color:#330001;text-align:left;vertical-align:top} .tg .tg-q2qy{background-color:#ffffff;color:#000000;border-color:#330001;text-align:right;vertical-align:top} </style>");
            sb.AppendLine("<body>");
            sb.AppendLine("<div>");
            sb.AppendLine("<table class=\"tg\">");
            sb.AppendLine("<tr>");
            sb.AppendLine("<td class=\"tg-hlej\" colspan=\"4\">Mensajes del analizador</td>");
            sb.AppendLine("</tr>");
            sb.AppendLine("<tr>");
            sb.AppendLine("<th class=\"tg-pjo9\">Tipo</th><th td class=\"tg-pjo9\">Mensaje</th><th td class=\"tg-pjo9\">Fila</th><th td class=\"tg-pjo9\">Columna</th>");
            sb.AppendLine("</tr>");
            foreach (var token in Tokens)
            {
                sb.AppendLine("<tr>");
                sb.AppendFormat("<td class=\"tg-bf8s\">{0}</td><td class=\"tg-bf8s\">{1}</td><td class=\"tg-bf8s\">{2}</td><td class=\"tg-bf8s\">{3}</td>", token.Level, token.Message, token.Location.Line + 1, token.Location.Column + 1);
                sb.AppendLine("</tr>");
            }
            sb.AppendLine("</table><br><br><br>");
            sb.AppendLine("<table class=\"tg\">>");
            sb.AppendLine("<tr>");
            sb.AppendLine("<th class=\"tg-hlej\" >Mensajes del compilador</th>");
            sb.AppendLine("</tr>");
            sb.AppendLine(Log);
            sb.AppendLine("</table>");
            sb.AppendLine("</div>");
            sb.AppendLine("</body>");
            sb.AppendLine("</html>");
            return(sb.ToString());
        }
Exemplo n.º 5
0
        private static string BuildParsingErrorMessage(LogMessageList messages)
        {
            var sb = new StringBuilder();

            sb.AppendLine("Parsing failed with the following errors:");
            messages.ForEach(msg => sb.AppendLine($"\t{msg.Message}"));
            return(sb.ToString());
        }
Exemplo n.º 6
0
 private void LogViewChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         if (_isAutoscroll ?? false)
         {
             int count = LogMessageList.Items.Count;
             if (count > 0)
             {
                 var last = LogMessageList.Items[count - 1];
                 LogMessageList.ScrollIntoView(last);
             }
         }
     }));
 }
Exemplo n.º 7
0
        private void OnNewParseTree(object sender, ParseTreeChangedEventArgs e)
        {
            _syntaxErrorTags.Clear();
            _syntaxErrorMessages = e.Tree.ParserMessages;
            foreach (LogMessage syntaxErrorMessage in _syntaxErrorMessages)
            {
                _syntaxErrorTags.Add(new TagSpan <ErrorTag>(new SnapshotSpan(_buffer.CurrentSnapshot, Math.Min(_buffer.CurrentSnapshot.Length, Math.Max(syntaxErrorMessage.Location.Position, 1)) - 1, 1),
                                                            new ErrorTag("syntax error", syntaxErrorMessage.Message)));
            }

            if (TagsChanged != null)
            {
                TagsChanged(this, new SnapshotSpanEventArgs(new SnapshotSpan(_buffer.CurrentSnapshot, new Span(0, _buffer.CurrentSnapshot.Length))));
            }
        }
Exemplo n.º 8
0
        private static void BuildErrors(ParseTree tree, ICollection<SqlParseError> errors, LogMessageList logMessages)
        {
            foreach (var logMessage in logMessages) {
                if (logMessage.Level == ErrorLevel.Error) {
                    var line = logMessage.Location.Line;
                    var column = logMessage.Location.Column;
                    var locationMessage = FormInfoMessage(tree, line, column);
                    var expected = logMessage.ParserState.ReportedExpectedSet.ToArray();
                    var infoMessage = String.Format("A parse error occurred near '{0}' in the source", locationMessage);
                    if (expected.Length > 0)
                        infoMessage = String.Format("{0}. Expected {1}", infoMessage, String.Join(", ", expected));

                    errors.Add(new SqlParseError(infoMessage, line, column));
                }
            }
        }
Exemplo n.º 9
0
 private static void CopyMessages(LogMessageList fromList, LogMessageList toList, SourceLocation baseLocation, string messagePrefix)
 {
     toList.AddRange(fromList.Select(other => new LogMessage(other.Level, baseLocation + other.Location, messagePrefix + other.Message, other.ParserState)));
 }
Exemplo n.º 10
0
 public ParserException(string designFile, ParseTreeStatus status, LogMessageList messages)
 {
     this.designFile = designFile;
     this.status     = status;
     this.messages   = messages;
 }
Exemplo n.º 11
0
 public Machine(LogMessageList messages)
 {
     IsRunning = false;
     Messages = messages;
 }
Exemplo n.º 12
0
 public ParsedSourceCode(bool hasErrors, ParseTreeNode treeRoot, LogMessageList errorList)
 {
     HasErrors = hasErrors;
     ParseTreeRoot = treeRoot;
     ErrorList = errorList;
 }
Exemplo n.º 13
0
        private static void BuildErrors(ParseTree tree, ICollection <SqlParseError> errors, LogMessageList logMessages)
        {
            foreach (var logMessage in logMessages)
            {
                if (logMessage.Level == ErrorLevel.Error)
                {
                    var line            = logMessage.Location.Line;
                    var column          = logMessage.Location.Column;
                    var locationMessage = FormInfoMessage(tree, line, column);
                    var expected        = logMessage.ParserState.ReportedExpectedSet.ToArray();
                    var infoMessage     = String.Format("A parse error occurred near '{0}' in the source", locationMessage);
                    if (expected.Length > 0)
                    {
                        infoMessage = String.Format("{0}. Expected {1}", infoMessage, String.Join(", ", expected));
                    }

                    errors.Add(new SqlParseError(infoMessage, line, column));
                }
            }
        }