public void ApplyParseSyntaxColoring()
        {
            FixedRichTextBox rtf = SourceRTF;

            if (rtf == null)
            {
                return;
            }

            rtf.BeginUpdate();

            //Find the lengthiest type and select it as the default color
            //SyntaxType.eType lengthiest = SyntaxType.eType.Name;
            int max_length = 0;

// ReSharper disable LoopCanBeConvertedToQuery
            foreach (var ist in ParseSyntaxOccurences)
// ReSharper restore LoopCanBeConvertedToQuery
            {
                if (ist.Value.Occurences.Count > max_length)
                {
                    max_length = ist.Value.Occurences.Count;
                    //lengthiest = ist.Value.Type;
                }
            }

            rtf.SelectAll();
            //if (ParseSyntaxOccurences.ContainsKey(lengthiest))
            //    rtf.SelectionColor = ParseSyntaxOccurences[lengthiest].Color;//Color.Black;
            //else
            rtf.SelectionColor     = Color.Black;
            rtf.SelectionBackColor = Color.White;

            //Apply syntax
            foreach (var ist in ParseSyntaxOccurences)
            {
                var st = ist.Value;
                //if (st.Type != lengthiest)
                foreach (var tp in st.Occurences)
                {
                    tp.ToRTB(rtf);
// ReSharper disable RedundantCheckBeforeAssignment
                    if (rtf.SelectionColor != st.Color)
                    {
// ReSharper restore RedundantCheckBeforeAssignment
                        rtf.SelectionColor = st.Color;
                    }
                }
            }

            //Apply errors
            ApplyErrors(GrammarTree.ParseErrors);

            rtf.EndUpdate();
        }
        public void ApplyCompiledSyntaxColoring()
        {
            FixedRichTextBox rtf = CompiledRTF;

            if (rtf == null)
            {
                return;
            }

            rtf.BeginUpdate();

            //Find the lengthiest type and select it as the default color
            SyntaxType.eType lengthiest = SyntaxType.eType.Name;
            int max_length = 0;

            foreach (var ist in CompiledSyntaxOccurences)
            {
                if (ist.Value.Occurences.Count > max_length)
                {
                    max_length = ist.Value.Occurences.Count;
                    lengthiest = ist.Value.Type;
                }
            }

            //Apply the text
            rtf.Clear();
            if (CompiledSyntaxOccurences.ContainsKey(lengthiest))
            {
                rtf.ForeColor = CompiledSyntaxOccurences[lengthiest].Color;                //Color.Black;
            }
            else
            {
                rtf.ForeColor = Color.Black;
            }
            rtf.Text = AssemblyOutput;

            //Apply syntax
            foreach (var ist in CompiledSyntaxOccurences)
            {
                var st = ist.Value;
                if (st.Type != lengthiest)
                {
                    foreach (var tp in st.Occurences)
                    {
                        tp.ToRTB(rtf);
                        rtf.SelectionColor = st.Color;
                    }
                }
            }

            rtf.EndUpdate();

            //Apply errors
            rtf = SourceRTF;
            if (rtf == null)
            {
                return;
            }
            rtf.BeginUpdate();
            ApplyErrors(ExecutionTree.ParseErrors);
            rtf.EndUpdate();
        }