1. Jesse McGrew
  2. rellor

Commits

Jesse McGrew  committed c673343

RellorPad: Improved message display, layout, and output trees

  • Participants
  • Parent commits 5327a8d
  • Branches default

Comments (0)

Files changed (2)

File RellorPad/MainForm.Designer.cs

View file
         private void InitializeComponent()
         {
             this.splitContainer1 = new System.Windows.Forms.SplitContainer();
-            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
-            this.txtSourceCode = new System.Windows.Forms.TextBox();
-            this.btnAST = new System.Windows.Forms.Button();
-            this.lvMessages = new System.Windows.Forms.ListView();
-            this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
-            this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
-            this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
             this.tabControl1 = new System.Windows.Forms.TabControl();
             this.astPage = new System.Windows.Forms.TabPage();
             this.tvAST = new System.Windows.Forms.TreeView();
+            this.tabPage1 = new System.Windows.Forms.TabPage();
+            this.tvGlobalScope = new System.Windows.Forms.TreeView();
             this.menuStrip1 = new System.Windows.Forms.MenuStrip();
             this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.samplesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
-            this.tabPage1 = new System.Windows.Forms.TabPage();
-            this.tvGlobalScope = new System.Windows.Forms.TreeView();
+            this.splitContainer2 = new System.Windows.Forms.SplitContainer();
+            this.lvMessages = new System.Windows.Forms.ListView();
+            this.colFile = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+            this.colLine = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+            this.colPos = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+            this.colLevel = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+            this.colCode = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+            this.colMessage = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
+            this.txtSourceCode = new System.Windows.Forms.TextBox();
+            this.btnAnalyze = new System.Windows.Forms.Button();
             ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
             this.splitContainer1.Panel1.SuspendLayout();
             this.splitContainer1.Panel2.SuspendLayout();
             this.splitContainer1.SuspendLayout();
-            this.tableLayoutPanel1.SuspendLayout();
             this.tabControl1.SuspendLayout();
             this.astPage.SuspendLayout();
+            this.tabPage1.SuspendLayout();
             this.menuStrip1.SuspendLayout();
-            this.tabPage1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
+            this.splitContainer2.Panel1.SuspendLayout();
+            this.splitContainer2.Panel2.SuspendLayout();
+            this.splitContainer2.SuspendLayout();
+            this.tableLayoutPanel1.SuspendLayout();
             this.SuspendLayout();
             // 
             // splitContainer1
             // 
             // splitContainer1.Panel1
             // 
-            this.splitContainer1.Panel1.Controls.Add(this.tableLayoutPanel1);
+            this.splitContainer1.Panel1.Controls.Add(this.splitContainer2);
             // 
             // splitContainer1.Panel2
             // 
             this.splitContainer1.Panel2.Controls.Add(this.tabControl1);
-            this.splitContainer1.Size = new System.Drawing.Size(720, 355);
-            this.splitContainer1.SplitterDistance = 421;
+            this.splitContainer1.Size = new System.Drawing.Size(723, 400);
+            this.splitContainer1.SplitterDistance = 422;
             this.splitContainer1.TabIndex = 0;
             // 
-            // tableLayoutPanel1
-            // 
-            this.tableLayoutPanel1.ColumnCount = 1;
-            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
-            this.tableLayoutPanel1.Controls.Add(this.txtSourceCode, 0, 0);
-            this.tableLayoutPanel1.Controls.Add(this.btnAST, 0, 1);
-            this.tableLayoutPanel1.Controls.Add(this.lvMessages, 0, 2);
-            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
-            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
-            this.tableLayoutPanel1.RowCount = 3;
-            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
-            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
-            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 82F));
-            this.tableLayoutPanel1.Size = new System.Drawing.Size(421, 355);
-            this.tableLayoutPanel1.TabIndex = 0;
-            // 
-            // txtSourceCode
-            // 
-            this.txtSourceCode.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.txtSourceCode.Location = new System.Drawing.Point(3, 3);
-            this.txtSourceCode.Multiline = true;
-            this.txtSourceCode.Name = "txtSourceCode";
-            this.txtSourceCode.Size = new System.Drawing.Size(415, 238);
-            this.txtSourceCode.TabIndex = 0;
-            // 
-            // btnAST
-            // 
-            this.btnAST.Anchor = System.Windows.Forms.AnchorStyles.None;
-            this.btnAST.Location = new System.Drawing.Point(173, 247);
-            this.btnAST.Name = "btnAST";
-            this.btnAST.Size = new System.Drawing.Size(75, 23);
-            this.btnAST.TabIndex = 1;
-            this.btnAST.Text = "AST";
-            this.btnAST.UseVisualStyleBackColor = true;
-            this.btnAST.Click += new System.EventHandler(this.btnAST_Click);
-            // 
-            // lvMessages
-            // 
-            this.lvMessages.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
-            this.columnHeader1,
-            this.columnHeader2,
-            this.columnHeader3});
-            this.lvMessages.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.lvMessages.Location = new System.Drawing.Point(3, 276);
-            this.lvMessages.Name = "lvMessages";
-            this.lvMessages.Size = new System.Drawing.Size(415, 76);
-            this.lvMessages.TabIndex = 2;
-            this.lvMessages.UseCompatibleStateImageBehavior = false;
-            this.lvMessages.View = System.Windows.Forms.View.Details;
-            // 
             // tabControl1
             // 
             this.tabControl1.Controls.Add(this.astPage);
             this.tabControl1.Location = new System.Drawing.Point(0, 0);
             this.tabControl1.Name = "tabControl1";
             this.tabControl1.SelectedIndex = 0;
-            this.tabControl1.Size = new System.Drawing.Size(295, 355);
+            this.tabControl1.Size = new System.Drawing.Size(297, 400);
             this.tabControl1.TabIndex = 0;
             // 
             // astPage
             this.astPage.Location = new System.Drawing.Point(4, 22);
             this.astPage.Name = "astPage";
             this.astPage.Padding = new System.Windows.Forms.Padding(3);
-            this.astPage.Size = new System.Drawing.Size(287, 329);
+            this.astPage.Size = new System.Drawing.Size(289, 374);
             this.astPage.TabIndex = 0;
             this.astPage.Text = "AST";
             this.astPage.UseVisualStyleBackColor = true;
             this.tvAST.Dock = System.Windows.Forms.DockStyle.Fill;
             this.tvAST.Location = new System.Drawing.Point(3, 3);
             this.tvAST.Name = "tvAST";
-            this.tvAST.Size = new System.Drawing.Size(281, 323);
+            this.tvAST.Size = new System.Drawing.Size(283, 368);
             this.tvAST.TabIndex = 0;
             // 
-            // menuStrip1
-            // 
-            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
-            this.fileToolStripMenuItem,
-            this.samplesToolStripMenuItem});
-            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
-            this.menuStrip1.Name = "menuStrip1";
-            this.menuStrip1.Size = new System.Drawing.Size(720, 24);
-            this.menuStrip1.TabIndex = 1;
-            this.menuStrip1.Text = "menuStrip1";
-            // 
-            // fileToolStripMenuItem
-            // 
-            this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
-            this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
-            this.fileToolStripMenuItem.Text = "&File";
-            // 
-            // samplesToolStripMenuItem
-            // 
-            this.samplesToolStripMenuItem.Name = "samplesToolStripMenuItem";
-            this.samplesToolStripMenuItem.Size = new System.Drawing.Size(63, 20);
-            this.samplesToolStripMenuItem.Text = "&Samples";
-            // 
             // tabPage1
             // 
             this.tabPage1.Controls.Add(this.tvGlobalScope);
             this.tvGlobalScope.Size = new System.Drawing.Size(281, 323);
             this.tvGlobalScope.TabIndex = 0;
             // 
+            // menuStrip1
+            // 
+            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.fileToolStripMenuItem,
+            this.samplesToolStripMenuItem});
+            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
+            this.menuStrip1.Name = "menuStrip1";
+            this.menuStrip1.Size = new System.Drawing.Size(723, 24);
+            this.menuStrip1.TabIndex = 1;
+            this.menuStrip1.Text = "menuStrip1";
+            // 
+            // fileToolStripMenuItem
+            // 
+            this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
+            this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
+            this.fileToolStripMenuItem.Text = "&File";
+            // 
+            // samplesToolStripMenuItem
+            // 
+            this.samplesToolStripMenuItem.Name = "samplesToolStripMenuItem";
+            this.samplesToolStripMenuItem.Size = new System.Drawing.Size(63, 20);
+            this.samplesToolStripMenuItem.Text = "&Samples";
+            // 
+            // splitContainer2
+            // 
+            this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.splitContainer2.Location = new System.Drawing.Point(0, 0);
+            this.splitContainer2.Name = "splitContainer2";
+            this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
+            // 
+            // splitContainer2.Panel1
+            // 
+            this.splitContainer2.Panel1.Controls.Add(this.tableLayoutPanel1);
+            // 
+            // splitContainer2.Panel2
+            // 
+            this.splitContainer2.Panel2.Controls.Add(this.lvMessages);
+            this.splitContainer2.Size = new System.Drawing.Size(422, 400);
+            this.splitContainer2.SplitterDistance = 271;
+            this.splitContainer2.TabIndex = 4;
+            // 
+            // lvMessages
+            // 
+            this.lvMessages.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+            this.colFile,
+            this.colLine,
+            this.colPos,
+            this.colLevel,
+            this.colCode,
+            this.colMessage});
+            this.lvMessages.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.lvMessages.FullRowSelect = true;
+            this.lvMessages.Location = new System.Drawing.Point(0, 0);
+            this.lvMessages.Name = "lvMessages";
+            this.lvMessages.Size = new System.Drawing.Size(422, 125);
+            this.lvMessages.TabIndex = 4;
+            this.lvMessages.UseCompatibleStateImageBehavior = false;
+            this.lvMessages.View = System.Windows.Forms.View.Details;
+            // 
+            // colFile
+            // 
+            this.colFile.Text = "File";
+            this.colFile.Width = 50;
+            // 
+            // colLine
+            // 
+            this.colLine.Text = "Line";
+            this.colLine.Width = 25;
+            // 
+            // colPos
+            // 
+            this.colPos.Text = "Pos";
+            this.colPos.Width = 25;
+            // 
+            // colLevel
+            // 
+            this.colLevel.Text = "Level";
+            this.colLevel.Width = 50;
+            // 
+            // colCode
+            // 
+            this.colCode.Text = "Code";
+            // 
+            // colMessage
+            // 
+            this.colMessage.Text = "Message";
+            this.colMessage.Width = 300;
+            // 
+            // tableLayoutPanel1
+            // 
+            this.tableLayoutPanel1.ColumnCount = 1;
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
+            this.tableLayoutPanel1.Controls.Add(this.txtSourceCode, 0, 0);
+            this.tableLayoutPanel1.Controls.Add(this.btnAnalyze, 0, 1);
+            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
+            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
+            this.tableLayoutPanel1.RowCount = 2;
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
+            this.tableLayoutPanel1.Size = new System.Drawing.Size(422, 271);
+            this.tableLayoutPanel1.TabIndex = 1;
+            // 
+            // txtSourceCode
+            // 
+            this.txtSourceCode.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.txtSourceCode.Location = new System.Drawing.Point(3, 3);
+            this.txtSourceCode.Multiline = true;
+            this.txtSourceCode.Name = "txtSourceCode";
+            this.txtSourceCode.Size = new System.Drawing.Size(416, 236);
+            this.txtSourceCode.TabIndex = 0;
+            // 
+            // btnAnalyze
+            // 
+            this.btnAnalyze.Anchor = System.Windows.Forms.AnchorStyles.None;
+            this.btnAnalyze.Location = new System.Drawing.Point(173, 245);
+            this.btnAnalyze.Name = "btnAnalyze";
+            this.btnAnalyze.Size = new System.Drawing.Size(75, 23);
+            this.btnAnalyze.TabIndex = 1;
+            this.btnAnalyze.Text = "Analyze";
+            this.btnAnalyze.UseVisualStyleBackColor = true;
+            this.btnAnalyze.Click += new System.EventHandler(this.btnAnalyze_Click);
+            // 
             // MainForm
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(720, 379);
+            this.ClientSize = new System.Drawing.Size(723, 424);
             this.Controls.Add(this.splitContainer1);
             this.Controls.Add(this.menuStrip1);
             this.Name = "MainForm";
             this.splitContainer1.Panel2.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
             this.splitContainer1.ResumeLayout(false);
+            this.tabControl1.ResumeLayout(false);
+            this.astPage.ResumeLayout(false);
+            this.tabPage1.ResumeLayout(false);
+            this.menuStrip1.ResumeLayout(false);
+            this.menuStrip1.PerformLayout();
+            this.splitContainer2.Panel1.ResumeLayout(false);
+            this.splitContainer2.Panel2.ResumeLayout(false);
+            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
+            this.splitContainer2.ResumeLayout(false);
             this.tableLayoutPanel1.ResumeLayout(false);
             this.tableLayoutPanel1.PerformLayout();
-            this.tabControl1.ResumeLayout(false);
-            this.astPage.ResumeLayout(false);
-            this.menuStrip1.ResumeLayout(false);
-            this.menuStrip1.PerformLayout();
-            this.tabPage1.ResumeLayout(false);
             this.ResumeLayout(false);
             this.PerformLayout();
 
         private System.Windows.Forms.TabPage astPage;
         private System.Windows.Forms.TreeView tvAST;
         private System.Windows.Forms.MenuStrip menuStrip1;
+        private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem samplesToolStripMenuItem;
+        private System.Windows.Forms.TabPage tabPage1;
+        private System.Windows.Forms.TreeView tvGlobalScope;
+        private System.Windows.Forms.SplitContainer splitContainer2;
         private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
         private System.Windows.Forms.TextBox txtSourceCode;
-        private System.Windows.Forms.Button btnAST;
-        private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
-        private System.Windows.Forms.ToolStripMenuItem samplesToolStripMenuItem;
+        private System.Windows.Forms.Button btnAnalyze;
         private System.Windows.Forms.ListView lvMessages;
-        private System.Windows.Forms.ColumnHeader columnHeader1;
-        private System.Windows.Forms.ColumnHeader columnHeader2;
-        private System.Windows.Forms.ColumnHeader columnHeader3;
-        private System.Windows.Forms.TabPage tabPage1;
-        private System.Windows.Forms.TreeView tvGlobalScope;
+        private System.Windows.Forms.ColumnHeader colFile;
+        private System.Windows.Forms.ColumnHeader colLine;
+        private System.Windows.Forms.ColumnHeader colPos;
+        private System.Windows.Forms.ColumnHeader colLevel;
+        private System.Windows.Forms.ColumnHeader colCode;
+        private System.Windows.Forms.ColumnHeader colMessage;
     }
 }
 

File RellorPad/MainForm.cs

View file
 using Antlr.Runtime.Tree;
 using Rellor.Core.Tree;
 using System.Diagnostics.Contracts;
+using System.Text.RegularExpressions;
 
 namespace RellorPad
 {
             Properties.Settings.Default.Save();
         }
 
-        private void btnAST_Click(object sender, EventArgs e)
+        private void btnAnalyze_Click(object sender, EventArgs e)
         {
             SaveText();
             lvMessages.Items.Clear();
                 nodeLabel = "<null>";
                 recurse = false;
             }
+            else if (tree.IsNil)
+            {
+                for (int i = 0; i < tree.ChildCount; i++)
+                    DumpTree(tree.GetChild(i), tokenNames, parentCollection);
+
+                return;
+            }
             else
             {
                 int type = tree.Type;
                             break;
                     }
                 }
+            }
 
-                var node = new TreeNode(nodeLabel);
-                node.Tag = tree;
-                parentCollection.Add(node);
+            var node = new TreeNode(nodeLabel);
+            node.Tag = tree;
+            parentCollection.Add(node);
 
-                if (recurse)
-                {
-                    for (int i = 0; i < tree.ChildCount; i++)
-                        DumpTree(tree.GetChild(i), tokenNames, node.Nodes);
-                }
+            if (recurse)
+            {
+                for (int i = 0; i < tree.ChildCount; i++)
+                    DumpTree(tree.GetChild(i), tokenNames, node.Nodes);
             }
         }
 
                 var symbolsNode = tvGlobalScope.Nodes.Add("Symbols");
                 foreach (var pair in scope.AllSymbols())
                 {
-                    string text = DescribeSymbol(pair.Value);
-                    symbolsNode.Nodes.Add(text);
+                    var symbol = pair.Value;
+                    string text = DescribeSymbol(symbol);
+                    var thisNode = symbolsNode.Nodes.Add(text);
 
-                    switch (pair.Value.Type)
+                    switch (symbol.Type)
                     {
                         case SymbolType.Constant:
-
+                            thisNode.Nodes.Add(DescribeCTV(symbol.Value));
+                            break;
                     }
                 }
+
+                tvGlobalScope.ExpandAll();
             }
             finally
             {
             }
         }
 
+        private string DescribeCTV(CompileTimeValue ctv)
+        {
+            if (ctv == null)
+                return "<null value>";
+
+            var sb = new StringBuilder();
+
+            sb.Append(ctv.Type.Name);
+            sb.Append(": ");
+
+            if (ctv.NumericValue != null)
+            {
+                sb.Append(ctv.NumericValue);
+                sb.Append(' ');
+            }
+
+            sb.Append('[');
+            sb.Append(ctv.GenericValue.ToString());
+            sb.Append(']');
+
+            return sb.ToString();
+        }
+
         private static string DescribeSymbol(Symbol symbol)
         {
             var sb = new StringBuilder();
             sb.Append(" [");
             sb.Append(symbol.Defined ? 'D' : 'd');
             sb.Append(symbol.Referenced ? 'R' : 'r');
-            sb.Append(symbol.Future != null ? 'F' : 'f');
+            sb.Append(symbol.Value != null ? 'V' : 'v');
+            sb.Append(symbol.Value != null && symbol.Value.NeedsBackpatch ? 'B' : 'b');
             sb.Append("]");
 
             return sb.ToString();
 
         #region ILogSink Members
 
+        private static readonly Regex LogMsgRegex =
+            new Regex(@"^(?:(.*):(\d+):(\d+): )?([a-z]+) ([A-Z]+\d+): (.*)$");
+
         public void LogMessage(LogLevel level, string text, bool count = true)
         {
-            var item = new ListViewItem(text);
-            item.SubItems.Add(level.ToString());
+            var match = LogMsgRegex.Match(text);
+
+            string file, line, charPos, levelStr, code, msg;
+            if (match.Success)
+            {
+                file = match.Groups[1].Value;
+                line = match.Groups[2].Value;
+                charPos = match.Groups[3].Value;
+                levelStr = match.Groups[4].Value;
+                code = match.Groups[5].Value;
+                msg = match.Groups[6].Value;
+            }
+            else
+            {
+                file = line = charPos = code = "";
+                levelStr = level.ToString();
+                msg = text;
+            }
+
+            var item = new ListViewItem(file);
+            item.SubItems.Add(line);
+            item.SubItems.Add(charPos);
+            item.SubItems.Add(levelStr);
+            item.SubItems.Add(code);
+            item.SubItems.Add(msg);
 
             lvMessages.Items.Add(item);
         }