Exemplo n.º 1
0
 //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);
     }
 }
Exemplo n.º 2
0
        //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);
            }
        }
Exemplo n.º 3
0
 private void _query()
 {
     _andTerm();
     if (next.GetType() == typeof(AndNotToken))
     {
         newSimpleTree(new Node(_tokens.getNextToken()), branchesStack.Pop());
         next = _tokens.PeekToken();
         _query();
     }
     else
     {
         return;
     }
 }