//the evaluater uses Reverse Polish Notation public void evaluate(Token token) { IEnumerable<string> newLinkSet = null; if (stack.Count >= 2) { if (token.GetType() == typeof(AndToken)) { newLinkSet = stack.Pop().Intersect(stack.Pop()); } if (token.GetType() == typeof(OrToken)) { newLinkSet = stack.Pop().Union(stack.Pop()); } if (token.GetType() == typeof(AndNotToken)) { var excluded = stack.Pop(); var included = stack.Pop(); newLinkSet = included.Except(excluded); } stack.Push(newLinkSet); } }
//the evaluater uses Reverse Polish Notation public void evaluate(Token token) { IEnumerable <string> newLinkSet = null; if (stack.Count >= 2) { if (token.GetType() == typeof(AndToken)) { newLinkSet = stack.Pop().Intersect(stack.Pop()); } if (token.GetType() == typeof(OrToken)) { newLinkSet = stack.Pop().Union(stack.Pop()); } if (token.GetType() == typeof(AndNotToken)) { var excluded = stack.Pop(); var included = stack.Pop(); newLinkSet = included.Except(excluded); } stack.Push(newLinkSet); } }
private void _query() { _andTerm(); if (next.GetType() == typeof(AndNotToken)) { newSimpleTree(new Node(_tokens.getNextToken()), branchesStack.Pop()); next = _tokens.PeekToken(); _query(); } else { return; } }