public ExecuteFilterExp(GetFieldExp getfieldExp, FilterExp exp) : base(Token.FilterOP) { this.GetfieldExp = getfieldExp; this.FilterExp = exp; }
static void CreateNode(Stack<ExpNode> expStack, Token token) { if (token.OpType == TokenType.DotOp) { var expRight = expStack.Pop(); var expLeft = expStack.Pop(); var expTemp = new GetFieldExp(token, expLeft, expRight); expStack.Push(expTemp); return; } if (token.OpType == TokenType.AND || token.OpType == TokenType.OR) { var expRight = expStack.Pop(); var expLeft = expStack.Pop(); var expTemp = new LogicExp(token, expLeft, expRight); expStack.Push(expTemp); return; } if (token.OpType == TokenType.EQ || token.OpType == TokenType.GE || token.OpType == TokenType.GT || token.OpType == TokenType.LL || token.OpType == TokenType.LE) { var expRight = expStack.Pop(); var expLeft = expStack.Pop(); var expTemp = new ComparrisonExp(token, expLeft, expRight); expStack.Push(expTemp); return; } if (token.OpType == TokenType.FilterOP) { var body = expStack.Pop(); var head = expStack.Pop(); expStack.Push(new FilterExp(body, head)); return; } if (token.OpType == TokenType.WITH) { var withStatement = expStack.Pop(); if (!(withStatement is ExecuteFilterExp)) throw new Exception(); if (expStack.Peek() is WithExp) { ((WithExp)expStack.Peek()).AddWith((ExecuteFilterExp)withStatement); } else { var mainExp = expStack.Pop(); if (mainExp is LogicExp) { expStack.Push(new WithExp((LogicExp)mainExp, (ExecuteFilterExp)withStatement)); } else if (mainExp is ComparrisonExp) { expStack.Push(new WithExp((ComparrisonExp)mainExp, (ExecuteFilterExp)withStatement)); } //当仅有with表达式,没有前置的对比和逻辑表达式的时候 else if (mainExp is FieldExp) { expStack.Push(mainExp); expStack.Push(new WithExp(null, (ExecuteFilterExp)withStatement)); } else { throw new Exception(); } /* if(!(mainExp is LogicExp) && !(mainExp is ComparrisonExp)) throw new Exception(); expStack.Push(new WithExp((LogicExp)mainExp, (ExecuteFilterExp)withStatement)); */ } return; } if (token.OpType == TokenType.LINK) { var withStatement = expStack.Pop(); if (!(withStatement is ExecuteFilterExp)) throw new Exception(); if (!(expStack.Peek() is WithExp)) { throw new Exception(); } ((WithExp)expStack.Peek()).AddWith((ExecuteFilterExp)withStatement); return; } throw new Exception(); }