This function creates a rule
172639
public void createRule(Instance inst) {
		int remainder = (int)Double.MAX_VALUE;
		int numInstanciaObservers = (int)this.observedClassDistribution.sumOfValues();
		if (numInstanciaObservers != 0 && this.gracePeriodOption.getValue() != 0) {
			remainder = (numInstanciaObservers) % (this.gracePeriodOption.getValue());
			}
		if (remainder == 0) {
			this.saveBestValGlobalEntropy = new ArrayList<ArrayList<Double>>();
			this.saveBestGlobalEntropy = new DoubleVector();
			this.saveTheBest = new ArrayList<Double>();
			this.minEntropyTemp = Double.MAX_VALUE;
			this.minEntropyNominalAttrib = Double.MAX_VALUE;
			theBestAttributes(inst, this.attributeObservers);
            boolean HB = checkBestAttrib(numInstanciaObservers, this.attributeObservers, this.observedClassDistribution);
            if (HB == true) {
            //	System.out.print("this.saveTheBest"+this.saveTheBest+"\n");
            	double attributeValue = this.saveTheBest.get(3);
    			double symbol = this.saveTheBest.get(2);		// =, <=, > : (0.0, -1.0, 1.0).
    			double value = this.saveTheBest.get(0);		// Value of the attribute
    			this.pred = new Predicates(attributeValue, symbol, value);
    			RuleClassification Rl = new RuleClassification();		// Create RuleClassification.
    			Rl.predicateSet.add(pred);
    			this.ruleSet.add(Rl);
    			if (Rl.predicateSet.get(0).getSymbol() == -1.0 ||Rl.predicateSet.get(0).getSymbol() == 1.0) {
    				double posClassDouble = this.saveTheBest.get(4);
    				this.ruleClassIndex.setValue(this.ruleSet.size()-1, posClassDouble);	
    				}else{
    						this.ruleClassIndex.setValue(ruleSet.size()-1, 0.0);
    						}
					this.observedClassDistribution = new DoubleVector();
					this.attributeObservers = new AutoExpandVector<AttributeClassObserver>(); 
					this.attributeObserversGauss = new AutoExpandVector<AttributeClassObserver>();
			   	}
            }
	}
901112
public function setupRules()
    {
        $this->rules->addMany([
            'call.symbol' => new Rule(new RegexMatcher('/(\\\[a-z@]+)/si'), [
                'context' => ['!delimiter.environment'],
                'priority' => -1
            ]),

            'expression.math' => [
                new Rule(new RegexMatcher('/((\${1,2}).*?\2)/s')),
                new Rule(new RegexMatcher('/(\\\\\(.*?\\\\\))/s')),
                new Rule(new RegexMatcher('/(\\\\\[.*?\\\\\])/s')),
                new Rule(
                    new RegexMatcher(
                        '/\\\begin{((?:' . implode('|', self::$mathEnvironments) . ')\*?)}(.*?)\\\end{\1}/s',
                        [2 => Token::NAME]
                    )
                )
            ],

            'delimiter.math' => new Rule(new WordMatcher(['$', '\[', '\]', '\(', '\)'], ['separated' => false]), [
                'context' => ['expression.math']
            ]),

            'symbol.annotation'    => new Rule(new RegexMatcher('/\[(.*?)\]/')), // make argument parsing?
            'symbol.environment' => new Rule(new RegexMatcher('/(\\\(?:begin|end)){(.*?)}/', [
                1 => 'delimiter.environment',
                2 => Token::NAME
            ]), ['context' => Validator::everywhere()]),

            'symbol.label' => new Rule(new RegexMatcher('/\\\(?:label|ref){(.*?)}/')),

            'operator' => [
                new Rule(new WordMatcher(['*', '&', '@', '\\\\'], ['separated' => false]), ['context' => Validator::everywhere()]),
                new Rule(new WordMatcher(['=', '-', '+', '/', '^', '_'], ['separated' => false]), [
                    'context'  => ['expression.math'],
                    'priority' => -1
                ]),
                'punctuation.brackets' => new Rule(new WordMatcher(['{', '}', '[', ']', '(', ')'], ['separated' => false]), [
                    'context' => ['expression.math']
                ]),
                'escape' => new Rule(new RegexMatcher('/(\\\[%@&])/si'), ['context' => Validator::everywhere(), 'priority' => -1])

            ],
            'comment' => new Rule(new CommentMatcher(['%'], [])),

            'format.bold' => new Rule(new RegexMatcher('/\\\textbf({((?>[^{}]+|(?1))+)})/si', [
                2 => Token::NAME
            ])),
            'format.italics' => new Rule(new RegexMatcher('/\\\textit({((?>[^{}]+|(?1))+)})/si', [
                2 => Token::NAME
            ])),

            'variable' => new Rule(new RegexMatcher('/(#\d+)/')),

            # math mode
            'number' => new Rule(new RegexMatcher('/(-?(?:0[0-7]+|0[xX][0-9a-fA-F]+|0b[01]+|[\d,.]+))/'), [
                'context'  => ['expression.math'],
                'priority' => -2
            ]),
        ]);
    }
341773
public function setupRules()
    {
        $this->rules->addMany([
            'string' => CommonFeatures::strings(['single' => '\'', 'double' => '"'], [
                'context' => ['!operator.escape', '!comment', '!string', '!expression'],
            ]),

            'string.heredoc' => new Rule(new RegexMatcher('/<<<\s*(\w+)\R(?P<string>.*?)\R\1;/sm', ['string' => Token::NAME, 0 => 'keyword.heredoc']), ['context' => ['!comment']]),
            'string.nowdoc'  => new Rule(new RegexMatcher('/<<<\s*\'(\w+)\'\R(?P<string>.*?)\R\1;/sm', ['string' => Token::NAME, 0 => 'keyword.nowdoc']), ['context' => ['!comment']]),

            'variable' => new Rule(new RegexMatcher('/(?:[^\\\]|^)(\$[a-z_]\w*)/i'), [
                'context' => ['*comment.docblock', '!string.nowdoc', '!string.single', '!comment']
            ]),
            'variable.property' => new Rule(new RegexMatcher('/(?=(?:\w|\)|\])\s*->([a-z_]\w*))/i'), [
                'priority' => -2,
                'context' => ['*comment.docblock', '!string.nowdoc', '!string.single', '!comment']
            ]),

            'symbol.function' => new Rule(new RegexMatcher('/function\s+([a-z_]\w+)\s*\(/i')),
            'symbol.class'    => [
                new Rule(new RegexMatcher('/(?:class|new|use|extends)\s+([\w\\\]+)/i')),
                new Rule(new RegexMatcher('/([\w\\\]+)::/i')),
                new Rule(new RegexMatcher('/@(?:var|property(?:-read|-write)?)(?:\s+|\s+\$\w+\s+)([^$][\w\\\]+)/i'), ['context' => ['comment.docblock']]),
            ],
            
            'expression.in-string' => new Rule(new RegexMatcher('/(?=(\{\$((?>[^${}]+|(?1))+)\}))/x'), [
                'context' => ['string'],
                'factory' => new TokenFactory(LanguageToken::class),
                'inject'  => $this
            ]),

            'symbol.class.interface' => [
                new Rule(new RegexMatcher('/interface\s+([\w\\\]+)/i')),
                new Rule(new DelegateRegexMatcher(
                    '/implements\s+((?:[\w\\\]+)(?:,\s*([\w\\\]+))+)/i',
                    function($match, TokenFactoryInterface $factory) {
                        foreach (preg_split('/,\s*/', $match[1][0], 0, PREG_SPLIT_OFFSET_CAPTURE) as $interface) {
                            yield $factory->create(Token::NAME, [
                                'pos' => $match[1][1] + $interface[1],
                                'length' => strlen($interface[0])]
                            );
                        }
                    }
                )),
            ],

            'symbol.namespace' => [
                /*new Rule(new RegexMatcher('/(\\\{0,2}(?:\w+\\\{1,2})+)\w+/i'), [
                    'context' => ['*symbol', '*none']
                ]),*/

                new Rule(new RegexMatcher('/namespace\s*(\\\{0,2}(?:\w+\\\{1,2})+\w+);/i'), [
                    'context' => ['*symbol', '*none']
                ]),
            ],

            'operator.escape' => [
                new Rule(new RegexMatcher('/(\\\(?:x[0-9a-fA-F]{1,2}|u\{[0-9a-fA-F]{1,6}\}|[0-7]{1,3}|[^\'\\\]))/i'), [
                    'context' => ['string.double', '!operator.escape']
                ]),
                new Rule(new RegexMatcher('/(\\\[\'\\\])/i'), [
                    'context' => ['string', '!operator.escape']
                ]),
            ],

            'comment' => new Rule(new CommentMatcher(['//', '#'], [
                '$.docblock' => ['/**', '*/'],
                ['/*', '*/']
            ]), ['priority' => 4]),

            'symbol.annotation' => new Rule(new RegexMatcher('/[\s]+(@[\w-]+)/i'), [
                'context' => ['comment.docblock']
            ]),

            'call' => new Rule(new RegexMatcher('/([a-z_]\w*)\s*\(/i'), ['priority' => -1]),

            'constant' => new Rule(new WordMatcher(array_merge([
                '__CLASS__', '__DIR__', '__FILE__', '__FUNCTION__',
                '__LINE__', '__METHOD__', '__NAMESPACE__', '__TRAIT__',
            ], array_keys(get_defined_constants(true)["Core"]))), ['priority' => -2]),
            'constant.static' => new Rule(new RegexMatcher('/(?:[\w\\\]+::|const\s+)(\w+)/i'), ['priority' => -2]),

            'keyword' => new Rule(new WordMatcher([
                '__halt_compiler', 'abstract', 'and', 'array',
                'as', 'break', 'callable', 'case', 'catch',
                'class', 'clone', 'const', 'continue', 'declare',
                'default', 'die', 'do', 'echo', 'else', 'elseif',
                'empty', 'enddeclare', 'endfor', 'endforeach', 'endif',
                'endswitch', 'endwhile', 'eval', 'exit', 'extends',
                'final', 'finally', 'for', 'foreach', 'function',
                'global', 'goto', 'if', 'implements', 'include', 'include_once',
                'instanceof', 'insteadof', 'interface', 'isset', 'list',
                'namespace', 'new', 'or', 'print', 'private', 'protected',
                'public', 'require', 'require_once', 'return', 'static',
                'switch', 'throw', 'trait', 'try', 'unset', 'parent', 'self',
                'use', 'var', 'while', 'xor', 'yield'
            ]), ['context' => ['!string', '!variable', '!comment']]),

            'keyword.cast' => new Rule(
                new RegexMatcher('/(\((?:int|integer|bool|boolean|float|double|real|string|array|object|unset)\))/')
            ),

            'delimiter' => new Rule(new RegexMatcher('/(<\?php|<\?=|\?>)/')),
            'number'    => new Rule(new RegexMatcher('/(-?(?:0[0-7]+|0[xX][0-9a-fA-F]+|0b[01]+|\d+))/')),

            'operator.punctuation' => new Rule(new WordMatcher([',', ';'], ['separated' => false]), ['priority' => 0]),
        ]);
    }
532175
public function setupRules()
    {
        $standard = new Validator(['!string', '!comment']);

        $this->rules->addMany([
            'keyword' => new Rule(new WordMatcher([
                'and', 'del', 'from', 'not', 'while', 'as', 'elif', 'global', 'or', 'with', 'assert', 'else', 'if',
                'pass', 'yield', 'break', 'except', 'import', 'print', 'class', 'exec', 'in', 'raise', 'continue',
                'finally', 'is', 'return', 'def', 'for', 'lambda', 'try',
            ])),

            'operator' => new Rule(
                new RegexMatcher('/([-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~])|\b(or|and|not)\b/'), [
                    'priority' => -1
                ]
            ),

            'expression' => new Rule(new RegexMatcher('/\{(\S+)\}/'), [
                'context' => ['string']
            ]),

            'variable' => [
                new Rule(new RegexMatcher('/[^\w.]([a-z_]\w*)\.\w/i')),
                'property' => new Rule(new RegexMatcher('/(?=(?:\w|\)|\])\s*\.([a-z_]\w*))/i'), [
                    'priority' => -2,
                    'context' => ['*none', '*expression']
                ]),
            ],

            'symbol' => [
                new Rule(new RegexMatcher('/import\s+([a-z_][\w.]*)(?:\s*,\s*([a-z_][\w.]*))*/i', [
                    1 => Token::NAME,
                    2 => Token::NAME,
                ])),
                'library' => new Rule(new RegexMatcher('/from\s+([a-z_][\w.]*)\s+import/i', [
                    1 => Token::NAME,
                ]))
            ],

            'operator.escape' => new Rule(new RegexMatcher('/(\\\(?:\R|.|[0-7]{3}|x\x{2}))/s'), [
                'context' => Validator::everywhere()
            ]),

            'comment' => new Rule(new CommentMatcher(['#'])),
            'constant.special' => [
                new Rule(new WordMatcher(['True', 'False', 'NotImplemented', 'Ellipsis'], [
                    'case-sensitivity' => true
                ])),
                new Rule(new RegexMatcher('/\b(__\w+__)\b/'))
            ],
            'call' => new Rule(new RegexMatcher('/([a-z_]\w*)\s*\(/i'), ['priority' => 2]),

            'meta.newline' => new CloseRule(new RegexMatcher('/()\R/'), [
                'factory' => new TokenFactory(TerminatorToken::class),
                'context' => ['!operator.escape', 'string.single-line'],
                'closes'  => ['string.single-line.double', 'string.single-line.single']
            ]),

            'number' => new Rule(
                new RegexMatcher('/(-?\b(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?)\b/')
            ),

            'string' => [
                'single-line' => [
                    'double' => new Rule(new RegexMatcher('/(?:^|[^"])(")(?=[^"]|$)/'), [
                        'factory' => new TokenFactory(ContextualToken::class),
                        'context' => $standard,
                    ]),
                    'single' => new Rule(new RegexMatcher('/(?:^|[^\'])(\')(?=[^\']|$)/'), [
                        'factory' => new TokenFactory(ContextualToken::class),
                        'context' => $standard,
                    ]),
                ],
                'multi-line' => [
                    'double' => new Rule(new SubStringMatcher('"""'), [
                        'factory'  => new TokenFactory(ContextualToken::class),
                        'context'  => $standard,
                        'priority' => 2,
                    ]),
                    'single' => new Rule(new SubStringMatcher('\'\'\''), [
                        'factory'  => new TokenFactory(ContextualToken::class),
                        'context'  => $standard,
                        'priority' => 2,
                    ]),
                ]
            ],

            'symbol.function' => new Rule(new RegexMatcher('/def\s+([a-z_]\w+)\s*\(/i')),
            'symbol.class'    => new Rule(new RegexMatcher('/class\s+([a-z_]\w+)/i')),
        ]);
    }
1097284
def make_eventrule(date_rule, time_rule, cal, half_days=True):
    
    _check_if_not_called(date_rule)
    _check_if_not_called(time_rule)

    if half_days:
        inner_rule = date_rule & time_rule
    else:
        inner_rule = date_rule & time_rule & NotHalfDay()

    opd = OncePerDay(rule=inner_rule)
    # This is where a scheduled function's rule is associated with a calendar.
    opd.cal = cal
    return opd
881485
function createFallbackRuleWithVariation(rule, variationName) {
  const selector = getSelectorName(rule, variationName, true);
  return postcss.rule({
    selector,
  });
}
1204503
def on_rule_prototype(node, compiled_grammar)
      name = process(node.children[0], compiled_grammar)

      return if compiled_grammar.has_rule?(name)

      rule = Rule.new(name, node.source_line)

      compiled_grammar.add_rule(rule)
    end
224620
function ruleEnd(e){

    var selectors ;

    if (e.old === 'ruleStart'){
      selectors = this.get('selectors');
      //delete the last selector
      selectors.pop();
      var lines = this.get('lines');
      lines.pop();

      this.attributes.nest.pop();

      return;
    } else if (e.old === 'valueStart') {
      this._addValue(e);
    }

    ruleEnd.recode = ruleEnd.recode || 0;
    ruleEnd.recode++;
    this.attributes.nest.pop();

    if (!this.attributes.nest.length){
      var num = this.getLen() - ruleEnd.recode;
      ruleEnd.recode = 0;
      var idList = this.get('idList');
      idList.push(num);
      this.fire(this.get('RULE_END_EVT'), this.getRule(num));
    }
  }
554129
def add_make_function_rule(self, rule, opname, attr, customize):
        
        if self.version >= 3.3:
            new_rule = rule % (('LOAD_CONST ') * 1)
        else:
            new_rule = rule % (('LOAD_CONST ') * 0)
        self.add_unique_rule(new_rule, opname, attr, customize)
575586
function createRule(path, handler) {
  if ('*' !== path && 0 != path.indexOf(watch.__base)) {
    path = watch.__base + (path == '/' ? '' : path)
  }
  let rule = pathToRegExp(path)
  if (handler instanceof String) {
    let target = handler
    handler = function() {
      watch({
        url: target
      })
    }
  }
  rule.handler = handler

  return rule
}
890549
function createRuleListeners(rule, ruleContext) {
    try {
        return rule.create(ruleContext);
    } catch (ex) {
        ex.message = `Error while loading rule '${ruleContext.id}': ${ex.message}`;
        throw ex;
    }
}
891442
function applyRules(rules, stem) {

  for (let i = 0, l = rules.length; i < l; i++) {
    const [min, pattern, replacement = ''] = rules[i];

    if (stem.slice(-pattern.length) === pattern) {
      const newStem = stem.slice(0, -pattern.length) + replacement,
            m = computeM(newStem);

      if (m <= min)
        continue;

      return newStem;
    }
  }

  return stem;
}
1128665
function flattenRules(rules) {
  var out = {};

  rules.forEach(function(rule) {
    // Ignore anything that doesn't look like a CSS rule
    if (rule.type !== 'rule') return;
    rule.selectors.forEach(function(sel) {
      if (!out[sel]) out[sel] = {};

      rule.declarations.forEach(function(decl) {
        out[sel][decl.property] = decl.value;
      });
    });
  });

  return out;
}
837315
function createCondition(name, value) {
    // FIXME name?
    value = value.replace(r, function (w) {
        w = w.replace('{{', '').replace('}}', '');
        return 'item["' + w + '"]';
    });
    //console.log('createCondition', name, value);
    return function (item) {
        return eval(value);
    };
}
731366
function prepareRules(options, rules, defaultDir) {
  rules = u.findRules(options, rules, defaultDir);
  var anyStartRules = [];
  var anyEndRules = [];
  var typeToRules = {'': anyStartRules, 'end': anyEndRules};

  rules.forEach(function (rule) {
    var ruleTypes = rule.type || [];
    ruleTypes = Array.isArray(ruleTypes) ? ruleTypes : [ruleTypes];
    if (ruleTypes.length === 0) {
      ruleTypes.push('');
    }
    ruleTypes.forEach(function (ruleType) {
      if (ruleType === '') {
        anyStartRules.push(rule);
        // add this any rule to the end of any typed start rule lists
        Object.keys(typeToRules).forEach(function (key) {
          if (key !== '' && key !== 'end' && key.substring(0,4) !== 'end-') {
            typeToRules[key].push(rule);
          }
        });
      } else if (ruleType === 'end') {
        anyEndRules.push(rule);
        // add this any rule to the end of any typed end rule lists
        Object.keys(typeToRules).forEach(function (key) {
          if (key !== '' && key.substring(0,4) === 'end-') {
            typeToRules[key].push(rule);
          }
        });
      } else {
        if (!(ruleType in typeToRules)) {
          typeToRules[ruleType] = [];
          if (ruleType.substring(0,4) !== 'end-') {
            // put all preceding any start rules first
            typeToRules[ruleType] = [].concat(anyStartRules);
          } else {
            // put all preceding any end rules first
            typeToRules[ruleType] = [].concat(anyEndRules);
          }
        }
        typeToRules[ruleType].push(rule);
      }
    });
  });

  return typeToRules;
}
32536
function parentIsAllowedAtRule(rule) {
  return (
    rule.parent &&
    rule.parent.type === 'atrule' &&
    !/(?:media|supports|for)$/.test(rule.parent.name)
  )
}
677750
function(context) {
				var evaluate = function(rules, createRule) {
					var i;
					rules = rules || [];
					for (i = 0; i < rules.length; i++) {
						if (typeof(rules[i]) === "function") {
							if (rules[i](context)) {
								return defaultHandleToken("named-ident")(context);
							}
						} else if (createRule && createRule(rules[i])(context.tokens)) {
							return defaultHandleToken("named-ident")(context);
						}
					}

					return false;
				};

				return evaluate(context.language.namedIdentRules.custom)
					|| evaluate(context.language.namedIdentRules.follows, function(ruleData) { return createProceduralRule(context.index - 1, -1, ruleData, context.language.caseInsensitive); })
					|| evaluate(context.language.namedIdentRules.precedes, function(ruleData) { return createProceduralRule(context.index + 1, 1, ruleData, context.language.caseInsensitive); })
					|| evaluate(context.language.namedIdentRules.between, function(ruleData) { return createBetweenRule(context.index, ruleData.opener, ruleData.closer, context.language.caseInsensitive); })
					|| defaultHandleToken("ident")(context);
			}