Exemplo n.º 1
0
 internal void HandleSingleQuotes()
 {
     this.m_ExpressionUsedSingleQuotes = false;
     if (this.m_Exp.GetType() == typeof(MDXStringConstNode))
     {
         MDXStringConstNode exp = (MDXStringConstNode)this.m_Exp;
         if (exp.SingleQuote)
         {
             string mdx = exp.GetString().Replace("''", "'");
             Source src = exp.Source.Clone();
             src.StartLocation = exp.Locator;
             Locator startLocation = src.StartLocation;
             startLocation.Position++;
             Locator locator2 = src.StartLocation;
             locator2.Column++;
             MDXParser parser = new MDXParser(mdx, src, null);
             parser.ParseExpression();
             this.m_Exp = parser.GetNode().GetExpNode();
             if (this.m_Exp == null)
             {
                 throw new Exception(string.Format("Error parsing MDX: {0}: MDX expression expected", exp.GetString()));
             }
             this.m_Exp.Locator.Adjust(src.StartLocation);
             this.m_ExpressionUsedSingleQuotes = true;
         }
     }
 }
Exemplo n.º 2
0
        public void ParseAndFormat()
        {
            int pos = SelectionStart;

            tbs.ClearWigglyLines();

            MDXParser     p  = new MDXParser(Text, tbs, new CubeInfo());
            FormatOptions fo = new FormatOptions();

            fo.Indent = 3;
            fo.Output = OutputFormat.RTF;
            try
            {
                p.Parse();
                string s = p.FormatMDX(fo);
                s   = s.Substring(0, s.IndexOf("\\par")) + s.Substring(s.IndexOf("\\par") + 4);
                Rtf = s;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                try
                {
                    p.Parse();
                    string s = p.FormatMDX(fo);
                    s   = s.Substring(0, s.IndexOf("\\par")) + s.Substring(s.IndexOf("\\par") + 4);
                    Rtf = s;
                }
                catch (MDXParserException mdxex)
                {
                    System.Diagnostics.Debug.WriteLine(mdxex.Message);
                    try
                    {
                        p.Parse();
                        string s = p.FormatMDX(fo);
                        s   = s.Substring(0, s.IndexOf("\\par")) + s.Substring(s.IndexOf("\\par") + 4);
                        Rtf = s;
                    }
                    catch (MDXParserException mdxex2)
                    {
                        Select(pos, 0);
                        System.Diagnostics.Debug.WriteLine(mdxex2.Message);
                    }
                    catch (Exception ex3)
                    {
                        Select(pos, 0);
                        System.Diagnostics.Debug.WriteLine(ex3.Message);
                    }
                }
                catch (Exception ex2)
                {
                    System.Diagnostics.Debug.WriteLine(ex2.Message);
                    try
                    {
                        p.Parse();
                        string s = p.FormatMDX(fo);
                        s   = s.Substring(0, s.IndexOf("\\par")) + s.Substring(s.IndexOf("\\par") + 4);
                        Rtf = s;
                    }
                    catch (MDXParserException mdxex2)
                    {
                        Select(pos, 0);
                        System.Diagnostics.Debug.WriteLine(mdxex2.Message);
                    }
                    catch (Exception ex3)
                    {
                        Select(pos, 0);
                        System.Diagnostics.Debug.WriteLine(ex3.Message);
                    }
                }
            }

            Select(pos, 0);
        }