Inference match result of the rule. Can be: -1: negative result, always fails 0: neutral result, may be fail, may be match 1: positive result, always match
497091
function inferenceMatchResult( ast, session ) {

    let inference;
    function sometimesMatch( node ) {

        node.match = 0;

        return node.match;

    }
    function alwaysMatch( node ) {

        inference( node.expression );

        node.match = 1;

        return node.match;

    }

    function inferenceExpression( node ) {

        node.match = inference( node.expression );

        return node.match;

    }
    function inferenceElements( elements, forChoice ) {

        const length = elements.length;
        let always = 0;
        let never = 0;

        for ( let i = 0; i < length; ++i ) {

            const result = inference( elements[ i ] );

            if ( result > 0 ) {

                ++always;

            }
            if ( result < 0 ) {

                ++never;

            }

        }

        if ( always === length ) {

            return 1;

        }
        if ( forChoice ) {

            return never === length ? -1 : 0;

        }

        return never > 0 ? -1 : 0;

    }

    inference = session.buildVisitor( {
        rule( node ) {

            let oldResult;
            let count = 0;

            if ( typeof node.match === "undefined" ) {

                node.match = 0;
                do {

                    oldResult = node.match;
                    node.match = inference( node.expression );
                    // 6 == 3! -- permutations count for all transitions from one match
                    // state to another.
                    // After 6 iterations the cycle with guarantee begins
                    // istanbul ignore next
                    if ( ++count > 6 ) {

                        session.error(
                            "Infinity cycle detected when trying to evaluate node match result",
                            node.location
                        );

                    }

                } while ( oldResult !== node.match );

            }

            return node.match;

        },
        named:        inferenceExpression,
        choice( node ) {

            node.match = inferenceElements( node.alternatives, true );

            return node.match;

        },
        action:       inferenceExpression,
        sequence( node ) {

            node.match = inferenceElements( node.elements, false );

            return node.match;

        },
        labeled:      inferenceExpression,
        text:         inferenceExpression,
        simple_and:   inferenceExpression,
        simple_not( node ) {

            node.match = -inference( node.expression );

            return node.match;

        },
        optional:     alwaysMatch,
        zero_or_more: alwaysMatch,
        one_or_more:  inferenceExpression,
        group:        inferenceExpression,
        semantic_and: sometimesMatch,
        semantic_not: sometimesMatch,
        rule_ref( node ) {

            const rule = ast.findRule( node.name );
            node.match = inference( rule );

            return node.match;

        },
        literal( node ) {

            // Empty literal always match on any input
            node.match = node.value.length === 0 ? 1 : 0;

            return node.match;

        },
        class( node ) {

            // Empty character class never match on any input
            node.match = node.parts.length === 0 ? -1 : 0;

            return node.match;

        },
        // |any| not match on empty input
        any:          sometimesMatch
    } );

    inference( ast );

}
14047
def infer_bool(node, context=None):
    """"""
    if len(node.args) > 1:
        # Invalid bool call.
        raise UseInferenceDefault

    if not node.args:
        return nodes.Const(False)

    argument = node.args[0]
    try:
        inferred = next(argument.infer(context=context))
    except InferenceError:
        return util.Uninferable
    if inferred is util.Uninferable:
        return util.Uninferable

    bool_value = inferred.bool_value()
    if bool_value is util.Uninferable:
        return util.Uninferable
    return nodes.Const(bool_value)
1053835
def field_match(self, node_field, pattern_field):
        
        is_good_list = (isinstance(pattern_field, list) and
                        self.check_list(node_field, pattern_field))
        is_good_node = (isinstance(pattern_field, AST) and
                        Check(node_field,
                              self.placeholders).visit(pattern_field))

        def strict_eq(f0, f1):
            try:
                return f0 == f1 or (isnan(f0) and isnan(f1))
            except TypeError:
                return f0 == f1

        is_same = strict_eq(pattern_field, node_field)
        return is_good_list or is_good_node or is_same
601245
def parse(self, rule: str):
        

        # Empty rule means always accept
        if not rule:
            return checks.TrueCheck()

        for token, value in self._parse_tokenize(rule):
            self._shift(token, value)

        try:
            return self.result
        except ValueError:
            LOG.exception('Failed to understand rule %r', rule)
            # Fail closed
            return checks.FalseCheck()
232525
private boolean matches(EvaluationContext ctx, Object[] params, DTDecisionRule rule) {
        for( int i = 0; i < params.length; i++ ) {
            CompiledExpression compiledInput = inputs.get(i).getCompiledInput();
            if ( compiledInput instanceof CompiledFEELExpression) {
                ctx.setValue("?", ((CompiledFEELExpression) compiledInput).apply(ctx));
            }
            if( ! satisfies( ctx, params[i], rule.getInputEntry().get( i ) ) ) {
                return false;
            }
        }
        return true;
    }
314253
def result(self, result):
        
        if result is None:
            raise ValueError("Invalid value for `result`, must not be `None`")  # noqa: E501
        allowed_values = ["OK", "ERROR"]  # noqa: E501
        if result not in allowed_values:
            raise ValueError(
                "Invalid value for `result` ({0}), must be one of {1}"  # noqa: E501
                .format(result, allowed_values)
            )

        self._result = result
1225425
def matches_all_rules(self, target_filename):
        

        for rule in self.match_rules:
            if rule.test(target_filename) is False:
                return False

        self.logger.debug('{0}: {1} - {2}'.format(self.name,
                                                  os.path.basename(target_filename),
                                                  'Match'))
        return True
194276
def _parse_check(self, rule):
        """"""

        # Handle the special constant-type checks
        for check_cls in (checks.FalseCheck, checks.TrueCheck):
            check = check_cls()
            if rule == str(check):
                return check

        try:
            kind, match = rule.split(':', 1)
        except Exception:
            if self.raise_error:
                raise InvalidRuleException(rule)
            else:
                LOG.exception('Failed to understand rule %r', rule)
                # If the rule is invalid, we'll fail closed
                return checks.FalseCheck()

        if kind in checks.registered_checks:
            return checks.registered_checks[kind](kind, match)
        elif None in checks.registered_checks:
            return checks.registered_checks[None](kind, match)
        elif self.raise_error:
            raise InvalidRuleException(rule)
        else:
            LOG.error('No handler for matches of kind %r', kind)
            # If the rule is invalid, we'll fail closed
            return checks.FalseCheck()
349431
def p_conditional_expr(self, p):
        
        if len(p) == 2:
            p[0] = p[1]
        else:
            p[0] = ast.Conditional(
                predicate=p[1], consequent=p[3], alternative=p[5])
967252
def safe_infer(node, context=None):
    
    try:
        inferit = node.infer(context=context)
        value = next(inferit)
    except exceptions.InferenceError:
        return None
    try:
        next(inferit)
        return None  # None if there is ambiguity on the inferred node
    except exceptions.InferenceError:
        return None  # there is some kind of ambiguity
    except StopIteration:
        return value
986189
def match(self, *args, **kwargs):
        
        return self._any_args or \
            self._arguments_rule.validate(*args, **kwargs)
689637
def to_bool(s, fallback=None):
    
    if not s:
        return fallback
    s = s.lower()
    if s in ["1", "true", "yes", "y"]:
        return True
    if s in ["0", "false", "no", "n"]:
        return False
    return fallback
465389
def check_positive(value, strict=False):
    
    if not strict and value < 0:
        raise ValueError("Value must be positive or zero, not %s" % str(value))
    if strict and value <= 0:
        raise ValueError("Value must be positive, not %s" % str(value))
649327
function MatchResult(
    matcher,
    input,
    startExpr,
    cst,
    cstOffset,
    rightmostFailurePosition,
    optRecordedFailures) {

  this.matcher = matcher;
  this.input = input;
  this.startExpr = startExpr;
  this._cst = cst;
  this._cstOffset = cstOffset;
  this._rightmostFailurePosition = rightmostFailurePosition;
  this._rightmostFailures = optRecordedFailures;

  if (this.failed()) {
    common.defineLazyProperty(this, 'message', function() {
      var detail = 'Expected ' + this.getExpectedText();
      return util.getLineAndColumnMessage(this.input, this.getRightmostFailurePosition()) + detail;
    });
    common.defineLazyProperty(this, 'shortMessage', function() {
      var detail = 'expected ' + this.getExpectedText();
      var errorInfo = util.getLineAndColumn(this.input, this.getRightmostFailurePosition());
      return 'Line ' + errorInfo.lineNum + ', col ' + errorInfo.colNum + ': ' + detail;
    });
  }
}
461178
def matches(self, other):
        
        if not isinstance(other, Failure):
            return False
        if self.exc_info is None or other.exc_info is None:
            return self._matches(other)
        else:
            return self == other
1198708
def _infer_boolop(self, context=None):
    
    values = self.values
    if self.op == "or":
        predicate = operator.truth
    else:
        predicate = operator.not_

    try:
        values = [value.infer(context=context) for value in values]
    except exceptions.InferenceError:
        yield util.Uninferable
        return None

    for pair in itertools.product(*values):
        if any(item is util.Uninferable for item in pair):
            # Can't infer the final result, just yield Uninferable.
            yield util.Uninferable
            continue

        bool_values = [item.bool_value() for item in pair]
        if any(item is util.Uninferable for item in bool_values):
            # Can't infer the final result, just yield Uninferable.
            yield util.Uninferable
            continue

        # Since the boolean operations are short circuited operations,
        # this code yields the first value for which the predicate is True
        # and if no value respected the predicate, then the last value will
        # be returned (or Uninferable if there was no last value).
        # This is conforming to the semantics of `and` and `or`:
        #   1 and 0 -> 1
        #   0 and 1 -> 0
        #   1 or 0 -> 1
        #   0 or 1 -> 1
        value = util.Uninferable
        for value, bool_value in zip(pair, bool_values):
            if predicate(bool_value):
                yield value
                break
        else:
            yield value

    return dict(node=self, context=context)
505866
def boolean(v):
    """"""
    if nodesetp(v):
        return len(v) > 0
    elif numberp(v):
        if v == 0 or v != v:
            return False
        return True
    elif stringp(v):
        return v != ''
    return v