private Property_SE FillSentenceGram()
        {
            if (this.varTable.GetItem(this.matchIndex).varType == ConstTable.VariableType.Identity)
            {
                this.matchIndex++;
            }
            string firstEntity = this.varTable.GetItem(this.matchIndex - 1).varValue;


            if (this.varTable.GetItem(this.matchIndex).varValue.Equals(":="))
            {
                this.matchIndex++;
            }
            string opString = this.varTable.GetItem(this.matchIndex - 1).varValue;

            Property_CalcuE CalcuE = CalcuExpGram();

            if (this.varTable.GetItem(this.matchIndex).varValue.Equals(";"))
            {
                this.matchIndex++;
            }

            Property_SE SE = new Property_SE();

            QuaternionItem item1 = new QuaternionItem(this.globalQuad, opString, CalcuE.VarValue, NullQuaternionElement, firstEntity, ConstTable.QuaternionType.FILLEXP);

            this.QuaternionTb.Add(item1);
            this.globalQuad++;

            return(SE);
        }
 /// <summary>
 /// 根据分析出的运行时表以及四元式,检测变量的使用错误
 /// </summary>
 public void CheckVar()
 {
     for (int i = 0; i < this.QuaternionTb.Count; i++)
     {
         QuaternionItem item        = QuaternionTb.GetItem(i);
         string         firstEntity = item.FirstEnity;
         if (isIdentity(firstEntity))
         {
             if (!RuntimeVarTb.isExists(firstEntity))
             {
                 System.Console.WriteLine("使用未声明的变量<{0}>", new object[] { firstEntity });
             }
         }
         string secondEntity = item.SecondEntity;
         if (isIdentity(secondEntity))
         {
             if (!RuntimeVarTb.isExists(secondEntity))
             {
                 System.Console.WriteLine("使用未声明的变量<{0}>", new object[] { secondEntity });
             }
         }
         if (item.OpString.Equals(":="))
         {
             string resultString = item.NextQuad.ToString();
             if (!RuntimeVarTb.isExists(resultString))
             {
                 System.Console.WriteLine("使用未声明的变量<{0}>", new object[] { secondEntity });
             }
         }
     }
 }
        /// <summary>
        /// Calculator_
        /// </summary>
        /// <param name="firstCalcuE"></param>
        /// <returns></returns>
        private Property_CalcuE Calculator_Gram(Property_CalcuE firstCalcuE)
        {
            if (this.varTable.GetItem(this.matchIndex).varValue.Equals("+"))
            {
                this.matchIndex++;
            }
            else
            {
                return(firstCalcuE);
            }

            string opString = this.varTable.GetItem(this.matchIndex - 1).varValue;

            Property_CalcuE secondCalcuE = CalcuExpGram();

            Property_CalcuE CalcuE = new Property_CalcuE("@T" + this.tempVarIndex++);

            QuaternionItem item1 = new QuaternionItem(this.globalQuad, opString, firstCalcuE.VarValue, secondCalcuE.VarValue, CalcuE.VarValue, ConstTable.QuaternionType.CALCUEXP);

            this.QuaternionTb.Add(item1);
            this.globalQuad++;


            return(Calculator_Gram(CalcuE));
        }
        /// <summary>
        /// XHSentence
        /// </summary>
        /// <returns></returns>
        private Property_SE XHSentenceGram()
        {
            if (this.varTable.GetItem(this.matchIndex).varValue.Equals("while"))
            {
                this.matchIndex++;
            }

            Property_ME ME1 = new Property_ME(this.globalQuad);

            Property_BoolE BoolE = BoolExpGram();

            if (this.varTable.GetItem(this.matchIndex).varValue.Equals("do"))
            {
                this.matchIndex++;
            }

            Property_ME ME2 = new Property_ME(this.globalQuad);


            Property_SE SE1 = new Property_SE();

            if (this.varTable.GetItem(this.matchIndex).varType == ConstTable.VariableType.Identity)
            {
                SE1 = FillSentenceGram();
            }
            else if (this.varTable.GetItem(this.matchIndex).varValue.Equals("if"))
            {
                SE1 = FZSentenceGram();
            }
            else if (this.varTable.GetItem(this.matchIndex).varValue.Equals("while"))
            {
                SE1 = XHSentenceGram();
            }
            else if (this.varTable.GetItem(this.matchIndex).varValue.Equals("begin"))
            {
                SE1 = ComplexSentenceGram();
            }

            Property_SE SE = new Property_SE();

            BackPatch(SE1.NextList, ME1.Quad);
            BackPatch(BoolE.TrueList, ME2.Quad);
            SE.NextList = BoolE.FalseList;

            QuaternionItem item1 = new QuaternionItem(this.globalQuad, NullQuaternionElement, NullQuaternionElement, NullQuaternionElement, ME1.Quad, ConstTable.QuaternionType.WHILEEXP);

            this.QuaternionTb.Add(item1);
            this.globalQuad++;

            return(SE);
        }
        /// <summary>
        /// 如果分析出比较语句,产生四元式,并且写出属性文法
        /// </summary>
        /// <returns></returns>
        private Property_BoolE CompareEGram()
        {
            bool   EntityResult = EntityGram();
            string firstEntity  = this.varTable.GetItem(this.matchIndex - 1).varValue;

            bool   BoolOptResult = BoolOptGram();
            string opString      = this.varTable.GetItem(this.matchIndex - 1).varValue;

            bool   EntityResult2 = EntityGram();
            string secondEntity  = this.varTable.GetItem(this.matchIndex - 1).varValue;


            Property_BoolE BoolE = new Property_BoolE();

            if (EntityResult && BoolOptResult && EntityResult2)
            {
                QuaternionItem item1 = new QuaternionItem(this.globalQuad, opString, firstEntity, secondEntity, 0, ConstTable.QuaternionType.BOOLEXP);
                this.globalQuad++;
                QuaternionItem item2 = new QuaternionItem(this.globalQuad, NullQuaternionElement, NullQuaternionElement, NullQuaternionElement, 0, ConstTable.QuaternionType.BOOLEXP);
                this.QuaternionTb.Add(item1);
                this.QuaternionTb.Add(item2);

                BoolE = new Property_BoolE();
                List <int> trueList = new List <int>();
                trueList.Add(this.globalQuad - 1);
                BoolE.TrueList = trueList;
                List <int> falseList = new List <int>();
                falseList.Add(this.globalQuad);
                BoolE.FalseList = falseList;

                this.globalQuad++;
            }


            return(BoolE);
        }
        /// <summary>
        /// FZSentence
        /// </summary>
        /// <returns></returns>
        private Property_SE FZSentenceGram()
        {
            if (this.varTable.GetItem(this.matchIndex).varValue.Equals("if"))
            {
                this.matchIndex++;
            }

            Property_BoolE BoolE = BoolExpGram();

            if (this.varTable.GetItem(this.matchIndex).varValue.Equals("then"))
            {
                this.matchIndex++;
            }

            Property_ME ME1 = new Property_ME(this.globalQuad);


            Property_SE SE1 = new Property_SE();

            if (this.varTable.GetItem(this.matchIndex).varType == ConstTable.VariableType.Identity)
            {
                SE1 = FillSentenceGram();
            }
            else if (this.varTable.GetItem(this.matchIndex).varValue.Equals("if"))
            {
                SE1 = FZSentenceGram();
            }
            else if (this.varTable.GetItem(this.matchIndex).varValue.Equals("while"))
            {
                SE1 = XHSentenceGram();
            }
            else if (this.varTable.GetItem(this.matchIndex).varValue.Equals("begin"))
            {
                SE1 = ComplexSentenceGram();
            }

            Property_SE SE = new Property_SE();

            if (this.varTable.GetItem(this.matchIndex).varValue.Equals("else"))
            {
                Property_NE NE       = new Property_NE();
                List <int>  nextList = new List <int>();
                nextList.Add(this.globalQuad);
                NE.NextList = nextList;

                QuaternionItem item1 = new QuaternionItem(this.globalQuad, NullQuaternionElement, NullQuaternionElement, NullQuaternionElement, 0, ConstTable.QuaternionType.NEXP);
                this.QuaternionTb.Add(item1);
                this.globalQuad++;

                if (this.varTable.GetItem(this.matchIndex).varValue.Equals("else"))
                {
                    this.matchIndex++;
                }

                Property_ME ME2 = new Property_ME(this.globalQuad);

                Property_SE SE2 = new Property_SE();
                if (this.varTable.GetItem(this.matchIndex).varType == ConstTable.VariableType.Identity)
                {
                    SE2 = FillSentenceGram();
                }
                else if (this.varTable.GetItem(this.matchIndex).varValue.Equals("if"))
                {
                    SE2 = FZSentenceGram();
                }
                else if (this.varTable.GetItem(this.matchIndex).varValue.Equals("while"))
                {
                    SE2 = XHSentenceGram();
                }
                else if (this.varTable.GetItem(this.matchIndex).varValue.Equals("begin"))
                {
                    SE2 = ComplexSentenceGram();
                }

                BackPatch(BoolE.TrueList, ME1.Quad);
                BackPatch(BoolE.FalseList, ME2.Quad);
                SE.NextList = Merge(Merge(SE1.NextList, NE.NextList), SE2.NextList);
            }
            else
            {
                BackPatch(BoolE.TrueList, ME1.Quad);
                SE.NextList = Merge(BoolE.FalseList, SE1.NextList);
            }

            return(SE);
        }
 /// <summary>
 /// 向表中插入一条
 /// </summary>
 /// <param name="item"></param>
 public void Add(QuaternionItem item)
 {
     table.Add(item);
 }