public void GenerateMdx(MdxObject mdx)
		{
			if (null == mdx)
			{
				Write("!ERROR while parsing MDX!");
				LastNeedNewLine = true;
				return;
			}
			mdx = tryReduceIIF(mdx);
			int curShiftSave = this.curShift;
			string curShiftStrSave = this.curShiftStr;
			try
			{
				if (mdx.ChildTokens != null)
				{
					bool NeedNewLine = (mdx._Length + curShift) > 80;
					foreach (MdxObject mdxChild in mdx.ChildTokens)
						if (MdxObject.IncShift == mdxChild)
							inc();
						else if (MdxObject.DecShift == mdxChild)
							dec();
						else if (mdxChild == MdxObject.NewLine)
						{
							if (NeedNewLine)
								LastNeedNewLine = true;
						}
						else GenerateMdx(mdxChild);
				}
				else if (mdx.SelfToken != null)
				{
					if (mdx.SelfToken.Length > 0)
					{
						if (LastNeedNewLine)
						{
							tw.WriteLine();
							tw.Write(curShiftStr);
						}
						else if (!NoSpaceBefore)
						{
							if (mdx.SelfToken != ".")
							{
								tw.Write(" ");
							}
						}
						Write(mdx.SelfToken);
						if (mdx.SelfToken == ".")
							NoSpaceBefore = true;
						else
							NoSpaceBefore = false;

						LastNeedNewLine = false;
						//LastNeedSpace = mdx.NeedSpaceAfter;
					}
				}
				else
				{
					tw.WriteLine();
					tw.Write(curShiftStr);
					Write("?Unknown token=" + mdx.ToString() + "?");
					LastNeedNewLine = true;
				}
			}
			finally
			{
				this.curShift = curShiftSave;
				this.curShiftStr = curShiftStrSave;
			}
		}
Esempio n. 2
0
        public void GenerateMdx(MdxObject mdx)
        {
            if (null == mdx)
            {
                Write("!ERROR while parsing MDX!");
                LastNeedNewLine = true;
                return;
            }
            mdx = tryReduceIIF(mdx);
            int    curShiftSave    = this.curShift;
            string curShiftStrSave = this.curShiftStr;

            try
            {
                if (mdx.ChildTokens != null)
                {
                    bool NeedNewLine = (mdx._Length + curShift) > 80;
                    foreach (MdxObject mdxChild in mdx.ChildTokens)
                    {
                        if (MdxObject.IncShift == mdxChild)
                        {
                            inc();
                        }
                        else if (MdxObject.DecShift == mdxChild)
                        {
                            dec();
                        }
                        else if (mdxChild == MdxObject.NewLine)
                        {
                            if (NeedNewLine)
                            {
                                LastNeedNewLine = true;
                            }
                        }
                        else
                        {
                            GenerateMdx(mdxChild);
                        }
                    }
                }
                else if (mdx.SelfToken != null)
                {
                    if (mdx.SelfToken.Length > 0)
                    {
                        if (LastNeedNewLine)
                        {
                            tw.WriteLine();
                            tw.Write(curShiftStr);
                        }
                        else if (!NoSpaceBefore)
                        {
                            if (mdx.SelfToken != ".")
                            {
                                tw.Write(" ");
                            }
                        }
                        Write(mdx.SelfToken);
                        if (mdx.SelfToken == ".")
                        {
                            NoSpaceBefore = true;
                        }
                        else
                        {
                            NoSpaceBefore = false;
                        }

                        LastNeedNewLine = false;
                        //LastNeedSpace = mdx.NeedSpaceAfter;
                    }
                }
                else
                {
                    tw.WriteLine();
                    tw.Write(curShiftStr);
                    Write("?Unknown token=" + mdx.ToString() + "?");
                    LastNeedNewLine = true;
                }
            }
            finally
            {
                this.curShift    = curShiftSave;
                this.curShiftStr = curShiftStrSave;
            }
        }