def exitPropTestLike(self,
                      ctx: STIXPatternParser.PropTestLikeContext) -> None:
     logger.debug("{} {} {}".format("PropTestLike", ctx, ctx.getText()))
     value = self.pop()
     object_path = self.pop()
     negated = ctx.NOT()
     self.push(
         ComparisonExpression(object_path,
                              value,
                              ComparisonComparators.Like,
                              negated=negated))
 def exitPropTestRegex(self,
                       ctx: STIXPatternParser.PropTestRegexContext) -> None:
     logger.debug("{} {} {}".format("PropTestRegex", ctx, ctx.getText()))
     logger.debug("stack={}".format(self._stack))
     value = self.pop()
     object_path = self.pop()
     negated = ctx.NOT()
     self.push(
         ComparisonExpression(object_path,
                              value,
                              ComparisonComparators.Matches,
                              negated=negated))
 def exitPropTestIsSubset(
         self, ctx: STIXPatternParser.PropTestIsSubsetContext) -> None:
     logger.debug("{} {} {}".format("exitPropTestIsSubset", ctx,
                                    ctx.getText()))
     value = self.pop()
     print(value)
     object_path = self.pop()
     negated = ctx.NOT()
     self.push(
         ComparisonExpression(object_path,
                              value,
                              ComparisonComparators.IsSubSet,
                              negated=negated))
    def exitPropTestSet(self,
                        ctx: STIXPatternParser.PropTestSetContext) -> None:
        logger.debug("{} {} {} | stack={}".format("PropTestSet", ctx,
                                                  ctx.getText(), self._stack))
        vals = self.pop()
        object_path = self.pop()
        negated = str(ctx.NOT()) == "NOT"

        self.push(
            ComparisonExpression(object_path,
                                 vals,
                                 ComparisonComparators.In,
                                 negated=negated))
    def exitPropTestEqual(self,
                          ctx: STIXPatternParser.PropTestEqualContext) -> None:
        logger.debug("{} {} {} | stack={}".format("PropTestEqual", ctx,
                                                  ctx.getText(), self._stack))
        value = self.pop()
        object_path = self.pop()
        negated = ctx.NOT()

        if ctx.EQ():
            comparator = ComparisonComparators.Equal
        elif ctx.NEQ():
            comparator = ComparisonComparators.NotEqual
        else:
            raise RuntimeWarning("Unrecognized Equality Comparator")
        self.push(
            ComparisonExpression(object_path,
                                 value,
                                 comparator,
                                 negated=negated))
    def exitPropTestOrder(self,
                          ctx: STIXPatternParser.PropTestOrderContext) -> None:
        logger.debug("{} {} {} | stack={}".format("PropTestOrder", ctx,
                                                  ctx.getText(), self._stack))
        value = self.pop()
        object_path = self.pop()
        negated = str(ctx.NOT()) == "NOT"

        if ctx.GT():
            comparator = ComparisonComparators.GreaterThan
        elif ctx.LT():
            comparator = ComparisonComparators.LessThan
        elif ctx.GE():
            comparator = ComparisonComparators.GreaterThanOrEqual
        elif ctx.LE():
            comparator = ComparisonComparators.LessThanOrEqual
        else:
            raise RuntimeWarning("Unrecognized Ordering Comparator")

        self.push(
            ComparisonExpression(object_path,
                                 value,
                                 comparator=comparator,
                                 negated=negated))