Sha256: 49284f057210b4f3659f46f77f1a61ace6a8beed8353212e903fe86917a6abe4

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

//          Copyright Joakim Karlsson & Kim Gräsman 2010-2012.
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)

#ifndef IGLOO_NOTOPERATOR_H
#define IGLOO_NOTOPERATOR_H

namespace snowhouse {
  
  struct NotOperator : public ConstraintOperator
  {
    template <typename ConstraintListType, typename ActualType>
    void Evaluate(ConstraintListType& list, ResultStack& result, OperatorStack& operators, const ActualType& actual)
    {
      EvaluateOperatorsWithLessOrEqualPrecedence(*this, operators, result);

      operators.push(this);
      
      EvaluateConstraintList(list.m_tail, result, operators, actual);
    }
    
    void PerformOperation(ResultStack& result)
    {
      if(result.size() < 1)
      {
        throw InvalidExpressionException("The expression contains a not operator without any operand");
      }
      
      bool right = result.top();
      result.pop();
            
      result.push(!right);
    }
    
    int Precedence() const
    {
      return 2;
    }
  };
  
   template<>
   struct Stringizer<NotOperator>
   {
      static std::string ToString(const NotOperator&)
      {
         return "not";
      }
   };
}

#endif

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tree-sitter-0.1.0 ext/tree-sitter/tree-sitter/externals/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/notoperator.h
tree-sitter-0.0.1 ext/tree-sitter/tree-sitter/externals/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/notoperator.h