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> /// 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); }
private Property_SE ComplexSentenceGram() { if (this.varTable.GetItem(this.matchIndex).varValue.Equals("begin")) { this.matchIndex++; } Property_SE SE = SentenceGram(new Property_SE()); if (this.varTable.GetItem(this.matchIndex).varValue.Equals("end")) { this.matchIndex++; } return(SE); }
/// <summary> /// Sentence /// </summary> /// <returns></returns> private Property_SE SentenceGram(Property_SE firstSE) { Property_SE SE = new Property_SE(); Property_SE secondSE = new Property_SE(); if (this.varTable.GetItem(this.matchIndex).varType == ConstTable.VariableType.Identity) { Property_ME ME = new Property_ME(this.globalQuad); BackPatch(firstSE.NextList, ME.Quad); secondSE = FillSentenceGram(); SE.NextList = secondSE.NextList; return(SentenceGram(SE)); } else if (this.varTable.GetItem(this.matchIndex).varValue.Equals("if")) { Property_ME ME = new Property_ME(this.globalQuad); BackPatch(firstSE.NextList, ME.Quad); secondSE = FZSentenceGram(); SE.NextList = secondSE.NextList; return(SentenceGram(SE)); } else if (this.varTable.GetItem(this.matchIndex).varValue.Equals("while")) { Property_ME ME = new Property_ME(this.globalQuad); BackPatch(firstSE.NextList, ME.Quad); secondSE = XHSentenceGram(); SE.NextList = secondSE.NextList; return(SentenceGram(SE)); } else if (this.varTable.GetItem(this.matchIndex).varValue.Equals("begin")) { Property_ME ME = new Property_ME(this.globalQuad); BackPatch(firstSE.NextList, ME.Quad); secondSE = ComplexSentenceGram(); SE.NextList = secondSE.NextList; return(SentenceGram(SE)); } return(firstSE); }
/// <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); }