------------------------------------------------------------------------------ Rule Definition ------------------------------------------------------------------------------
509535
function getBinaryExpressionStarts(binaryExpression, starts) {
  function getStartsFromOneSide(side, starts) {
    starts.push(side.loc.start);
    if (side.type === 'BinaryExpression') {
      starts = getBinaryExpressionStarts(side, starts);
    }
    return starts;
  }

  starts = getStartsFromOneSide(binaryExpression.left, starts);
  starts = getStartsFromOneSide(binaryExpression.right, starts);
  return starts;
}
175306
def p_rule(self, rule):
        ''''''
        if len(rule[1]) == 4:
            # This is a guideline
            rule[0] = Guideline(rule[1][1], rule[1][2], rule[1][3])
        else:
            # This is a regulation
            indentsize = rule[1][0]
            number = rule[1][1]
            text = rule[1][2]
            parent = None

            # If we just "un"nested, shrink the current rule to our level
            if self.prev_indent > indentsize:
                self.current_rule = self.current_rule[0:indentsize+1]

            # We just added a nested level, the parent is the list's last elem
            if self.prev_indent < indentsize:
                parent = self.current_rule[-1]
            # Else, if we are nested the parent is the one before the last elem
            elif len(self.current_rule) > 1:
                parent = self.current_rule[-2]
            # Else if we are not nested, then we are a root rule and parent is none
            # (do nothing as parent is initialized to none)

            # Create the regulation node
            reg = Regulation(number, text, parent)

            # Let our parent knows he has a new child, if we don't have a parent
            # let's create an item in the article rules list
            if parent:
                parent.add_child(reg)
            else:
                rule[0] = reg

            # Unless we nested, pop and replace the last rule by ourself
            # If we added a nesting level, we just need to add ourself
            if self.prev_indent >= indentsize:
                self.current_rule.pop()
            self.current_rule.append(reg)
            self.prev_indent = indentsize
1034183
function setRule (rule, isDefault) {
    // clear id for existing rules
    this.id = undefined
    // if this is default rule then add to list
    if (isDefault) {
        this.defaultRules.push(_.cloneDeep(rule))
    }
    // capture original rule as string for error logging
    var origRule = rule.join(',')
    // require array
    assert.ok(Array.isArray(rule), 'rule array required')
    // get roles array
    var roles = rule
    // get rule string from last element in array
    rule = roles.pop()
    // require rule to be a string
    assert.ok(typeof rule === 'string', 'invalid rule '+origRule)
    // require at least one role
    assert.ok(roles.length, 'one or more roles required '+origRule)
    // split rule on colon to separate into clauses
    var ruleClauses = rule.split(':')
    // first clause must identify type of resource
    var resourceType = ruleClauses.shift()
    // get index of last element in rule
    var lastIdx = ruleClauses.length - 1
    // final element in rule must be 1 or 0 to indicate allow or deny
    var allow = parseInt(ruleClauses[lastIdx])
    // validate
    assert.ok(allow === 0 || allow === 1, 'allow must be 0 or 1 '+origRule)
    // set value to boolean
    ruleClauses[lastIdx] = allow
    // deny rule only allowed on all role
    if (allow === 0) {
        assert.ok(roles.length === 1 && roles[0] === 'all', 'deny can only be set for all role '+origRule)
    }
    // require valid resource type
    assert.ok(resourceTypes[resourceType], 'invalid resource type '+origRule)
    // create entry from resource type if it does not exist
    if (!this.rules[resourceType]) {
        this.rules[resourceType] = {}
    }
    // call type specific method to set rule
    resourceTypes[resourceType](roles, ruleClauses, this.rules[resourceType], origRule)
}
209743
function(rule, callback){
        var res = [];
        callback = callback || function(){};
        this.each(function(item){
            var pass = true;
            if(pass && rule.group != undefined){
                pass = rule.group == item.parent;
            }
            if(pass && rule.type != undefined){
                pass = rule.type == item.type;
            }
            if(item.type == 'ip'){
                if(pass && rule.ip != undefined){
                    pass = rule.ip == item.ip;
                }
                if(pass && rule.domain != undefined){
                    pass = rule.domain == item.domain;
                }
                if(pass && rule.enable != undefined){
                    pass = rule.enable == item.enable;
                }
                if(pass && rule.comment != undefined){
                    pass = rule.comment == item.comment;
                }
            }else if(item.type == 'text'){
                if(pass && rule.text != undefined){
                    pass = rule.text == item.text;
                }
            }
            if(pass){
                callback.call(item, item);
                res.push(item);
            }
        });
        return res;
    }
995786
public function addRule($rule, $method = null, $params = [], $message = null)
    {

        // construction des paramètres
        array_unshift($params, $rule, $method);

        call_user_func_array([$this->getValidator(), 'addRule'], $params);

        if (!is_null($message)) {
            if(is_array($message)){
                foreach($message as $rule => $message){
                    $this->getValidator()->addMessage($rule, $message);
                }
            }else{
                $this->getValidator()->addMessage($rule, $message);
            }
        }

        return $this;
    }
546287
function defineRules($, t) {
  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-Block
  $.RULE("block", () => {
    $.CONSUME(t.LCurly);
    $.OPTION(() => {
      $.SUBRULE($.blockStatements);
    });
    $.CONSUME(t.RCurly);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-BlockStatements
  $.RULE("blockStatements", () => {
    $.SUBRULE($.blockStatement);
    $.MANY(() => {
      $.SUBRULE2($.blockStatement);
    });
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-BlockStatement
  $.RULE("blockStatement", () => {
    const isLocalVariableDeclaration = this.BACKTRACK_LOOKAHEAD(
      $.isLocalVariableDeclaration
    );
    $.OR([
      {
        GATE: () => isLocalVariableDeclaration,
        ALT: () => $.SUBRULE($.localVariableDeclarationStatement)
      },
      {
        ALT: () => $.SUBRULE($.classDeclaration)
      },
      { ALT: () => $.SUBRULE($.statement) }
    ]);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-LocalVariableDeclaration
  $.RULE("localVariableDeclarationStatement", () => {
    $.SUBRULE($.localVariableDeclaration);
    $.CONSUME(t.Semicolon);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-LocalVariableDeclaration
  $.RULE("localVariableDeclaration", () => {
    $.MANY(() => {
      $.SUBRULE($.variableModifier);
    });
    $.SUBRULE($.localVariableType);
    $.SUBRULE($.variableDeclaratorList);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-LocalVariableType
  $.RULE("localVariableType", () => {
    $.OR([
      { ALT: () => $.SUBRULE($.unannType) },
      { ALT: () => $.CONSUME(t.Var) }
    ]);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-Statement
  $.RULE("statement", () => {
    $.OR([
      { ALT: () => $.SUBRULE($.statementWithoutTrailingSubstatement) },
      { ALT: () => $.SUBRULE($.labeledStatement) },
      // Spec deviation: combined "IfThenStatement" and "IfThenElseStatement"
      { ALT: () => $.SUBRULE($.ifStatement) },
      { ALT: () => $.SUBRULE($.whileStatement) },
      { ALT: () => $.SUBRULE($.forStatement) }
    ]);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-StatementWithoutTrailingSubstatement
  $.RULE("statementWithoutTrailingSubstatement", () => {
    $.OR([
      { ALT: () => $.SUBRULE($.block) },
      { ALT: () => $.SUBRULE($.emptyStatement) },
      { ALT: () => $.SUBRULE($.expressionStatement) },
      { ALT: () => $.SUBRULE($.assertStatement) },
      { ALT: () => $.SUBRULE($.switchStatement) },
      { ALT: () => $.SUBRULE($.doStatement) },
      { ALT: () => $.SUBRULE($.breakStatement) },
      { ALT: () => $.SUBRULE($.continueStatement) },
      { ALT: () => $.SUBRULE($.returnStatement) },
      { ALT: () => $.SUBRULE($.synchronizedStatement) },
      { ALT: () => $.SUBRULE($.throwStatement) },
      { ALT: () => $.SUBRULE($.tryStatement) }
    ]);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-EmptyStatement
  $.RULE("emptyStatement", () => {
    $.CONSUME(t.Semicolon);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-LabeledStatement
  $.RULE("labeledStatement", () => {
    $.CONSUME(t.Identifier);
    $.CONSUME(t.Colon);
    $.SUBRULE($.statement);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-ExpressionStatement
  $.RULE("expressionStatement", () => {
    $.SUBRULE($.statementExpression);
    $.CONSUME(t.Semicolon);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-StatementExpression
  $.RULE("statementExpression", () => {
    // Spec deviation: The many alternatives here were replaced with
    //                 the "expression" rule as it contains them all,
    //                 and distinguishing between the alternatives cannot be done
    //                 using a fixed lookahead.
    // TODO: verify the resulting expression is one of the valid alternatives?
    $.SUBRULE($.expression);
  });

  // Spec deviation: combined "IfThenStatement" and "IfThenElseStatement"
  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-IfThenStatement
  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-IfThenElseStatement
  $.RULE("ifStatement", () => {
    $.CONSUME(t.If);
    $.CONSUME(t.LBrace);
    $.SUBRULE($.expression);
    $.CONSUME(t.RBrace);
    $.SUBRULE($.statement);
    $.OPTION(() => {
      $.CONSUME(t.Else);
      $.SUBRULE2($.statement);
    });
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-AssertStatement
  $.RULE("assertStatement", () => {
    $.CONSUME(t.Assert);
    $.SUBRULE($.expression);
    $.OPTION(() => {
      $.CONSUME(t.Colon);
      $.SUBRULE2($.expression);
    });
    $.CONSUME(t.Semicolon);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-SwitchStatement
  $.RULE("switchStatement", () => {
    $.CONSUME(t.Switch);
    $.CONSUME(t.LBrace);
    $.SUBRULE($.expression);
    $.CONSUME(t.RBrace);
    $.SUBRULE($.switchBlock);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-SwitchBlock
  $.RULE("switchBlock", () => {
    $.CONSUME(t.LCurly);
    $.MANY(() => {
      // Spec Deviation: refactored "switchBlock" for easy post-processing
      //                 each case and block together in the same rule.
      $.SUBRULE($.switchCase);
    });
    $.CONSUME(t.RCurly);
  });

  $.RULE("switchCase", () => {
    $.SUBRULE($.switchLabel);
    $.OPTION(() => {
      $.SUBRULE($.blockStatements);
    });
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-SwitchLabel
  $.RULE("switchLabel", () => {
    $.OR([
      {
        ALT: () => {
          $.CONSUME(t.Case);
          $.SUBRULE($.constantExpression);
          $.CONSUME(t.Colon);
        }
      },
      // SPEC Deviation: the variant with "enumConstantName" was removed
      // as it can be matched by the "constantExpression" variant
      // the distinction is semantic not syntactic.
      {
        ALT: () => {
          $.CONSUME(t.Default);
          $.CONSUME3(t.Colon);
        }
      }
    ]);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-EnumConstantName
  $.RULE("enumConstantName", () => {
    $.CONSUME(t.Identifier);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-WhileStatement
  $.RULE("whileStatement", () => {
    $.CONSUME(t.While);
    $.CONSUME(t.LBrace);
    $.SUBRULE($.expression);
    $.CONSUME(t.RBrace);
    $.SUBRULE($.statement);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-DoStatement
  $.RULE("doStatement", () => {
    $.CONSUME(t.Do);
    $.SUBRULE($.statement);
    $.CONSUME(t.While);
    $.CONSUME(t.LBrace);
    $.SUBRULE($.expression);
    $.CONSUME(t.RBrace);
    $.CONSUME(t.Semicolon);
  });
  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-ForStatement
  $.RULE("forStatement", () => {
    $.OR([
      {
        GATE: () => this.BACKTRACK_LOOKAHEAD($.isBasicForStatement),
        ALT: () => $.SUBRULE($.basicForStatement)
      },
      { ALT: () => $.SUBRULE($.enhancedForStatement) }
    ]);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-BasicForStatement
  $.RULE("basicForStatement", () => {
    $.CONSUME(t.For);
    $.CONSUME(t.LBrace);
    $.OPTION(() => {
      $.SUBRULE($.forInit);
    });
    $.CONSUME(t.Semicolon);
    $.OPTION2(() => {
      $.SUBRULE($.expression);
    });
    $.CONSUME2(t.Semicolon);
    $.OPTION3(() => {
      $.SUBRULE($.forUpdate);
    });
    $.CONSUME(t.RBrace);
    $.SUBRULE($.statement);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-ForInit
  $.RULE("forInit", () => {
    $.OR([
      {
        GATE: () => $.BACKTRACK_LOOKAHEAD($.isLocalVariableDeclaration),
        ALT: () => $.SUBRULE($.localVariableDeclaration)
      },
      { ALT: () => $.SUBRULE($.statementExpressionList) }
    ]);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-ForUpdate
  $.RULE("forUpdate", () => {
    $.SUBRULE($.statementExpressionList);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-StatementExpressionList
  $.RULE("statementExpressionList", () => {
    $.SUBRULE($.statementExpression);
    $.MANY(() => {
      $.CONSUME(t.Comma);
      $.SUBRULE2($.statementExpression);
    });
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-EnhancedForStatement
  $.RULE("enhancedForStatement", () => {
    $.CONSUME(t.For);
    $.CONSUME(t.LBrace);
    $.MANY(() => {
      $.SUBRULE($.variableModifier);
    });
    $.SUBRULE($.localVariableType);
    $.SUBRULE($.variableDeclaratorId);
    $.CONSUME(t.Colon);
    $.SUBRULE($.expression);
    $.CONSUME(t.RBrace);
    $.SUBRULE($.statement);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-BreakStatement
  $.RULE("breakStatement", () => {
    $.CONSUME(t.Break);
    $.OPTION(() => {
      $.CONSUME(t.Identifier);
    });
    $.CONSUME(t.Semicolon);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-ContinueStatement
  $.RULE("continueStatement", () => {
    $.CONSUME(t.Continue);
    $.OPTION(() => {
      $.CONSUME(t.Identifier);
    });
    $.CONSUME(t.Semicolon);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-ReturnStatement
  $.RULE("returnStatement", () => {
    $.CONSUME(t.Return);
    $.OPTION(() => {
      $.SUBRULE($.expression);
    });
    $.CONSUME(t.Semicolon);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-ThrowStatement
  $.RULE("throwStatement", () => {
    $.CONSUME(t.Throw);
    $.SUBRULE($.expression);
    $.CONSUME(t.Semicolon);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-SynchronizedStatement
  $.RULE("synchronizedStatement", () => {
    $.CONSUME(t.Synchronized);
    $.CONSUME(t.LBrace);
    $.SUBRULE($.expression);
    $.CONSUME(t.RBrace);
    $.SUBRULE($.block);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-TryStatement
  $.RULE("tryStatement", () => {
    $.OR([
      {
        ALT: () => {
          $.CONSUME(t.Try);
          $.SUBRULE($.block);
          $.OR2([
            {
              ALT: () => {
                $.SUBRULE($.catches);
                $.OPTION(() => {
                  $.SUBRULE($.finally);
                });
              }
            },
            { ALT: () => $.SUBRULE2($.finally) }
          ]);
        }
      },
      { ALT: () => $.SUBRULE($.tryWithResourcesStatement) }
    ]);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-Catches
  $.RULE("catches", () => {
    $.SUBRULE($.catchClause);
    $.MANY(() => {
      $.SUBRULE2($.catchClause);
    });
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-CatchClause
  $.RULE("catchClause", () => {
    $.CONSUME(t.Catch);
    $.CONSUME(t.LBrace);
    $.SUBRULE($.catchFormalParameter);
    $.CONSUME(t.RBrace);
    $.SUBRULE($.block);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-CatchFormalParameter
  $.RULE("catchFormalParameter", () => {
    $.MANY(() => {
      $.SUBRULE($.variableModifier);
    });
    $.SUBRULE($.catchType);
    $.SUBRULE($.variableDeclaratorId);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-CatchType
  $.RULE("catchType", () => {
    $.SUBRULE($.unannClassType);
    $.MANY(() => {
      $.CONSUME(t.Or);
      $.SUBRULE2($.classType);
    });
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-Finally
  $.RULE("finally", () => {
    $.CONSUME(t.Finally);
    $.SUBRULE($.block);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-TryWithResourcesStatement
  $.RULE("tryWithResourcesStatement", () => {
    $.CONSUME(t.Try);
    $.SUBRULE($.resourceSpecification);
    $.SUBRULE($.block);
    $.OPTION(() => {
      $.SUBRULE($.catches);
    });
    $.OPTION2(() => {
      $.SUBRULE($.finally);
    });
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-ResourceSpecification
  $.RULE("resourceSpecification", () => {
    $.CONSUME(t.LBrace);
    $.SUBRULE($.resourceList);
    $.OPTION(() => {
      $.CONSUME(t.Semicolon);
    });
    $.CONSUME(t.RBrace);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-ResourceList
  $.RULE("resourceList", () => {
    $.SUBRULE($.resource);
    $.MANY({
      GATE: () => tokenMatcher($.LA(2).tokenType, t.RBrace) === false,
      DEF: () => {
        $.CONSUME(t.Semicolon);
        $.SUBRULE2($.resource);
      }
    });
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-Resource
  $.RULE("resource", () => {
    $.OR([
      {
        GATE: $.BACKTRACK($.resourceInit),
        // Spec Deviation: extracted this alternative to "resourceInit"
        //                 to enable backtracking.
        ALT: () => $.SUBRULE($.resourceInit)
      },
      { ALT: () => $.SUBRULE($.variableAccess) }
    ]);
  });

  // Spec Deviation: extracted from "resource"
  $.RULE("resourceInit", () => {
    $.MANY(() => {
      $.SUBRULE($.variableModifier);
    });
    $.SUBRULE($.localVariableType);
    $.CONSUME(t.Identifier);
    $.CONSUME(t.Equals);
    $.SUBRULE($.expression);
  });

  // https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-VariableAccess
  $.RULE("variableAccess", () => {
    // Spec Deviation: both "expressionName" and "fieldAccess" can be parsed
    //                 by the "primary" rule
    // TODO: verify that the primary is a fieldAccess or an expressionName.
    $.SUBRULE($.primary);
  });

  // ------------------------------------
  // Special optimized backtracking rules.
  // ------------------------------------
  $.RULE("isBasicForStatement", () => {
    $.CONSUME(t.For);
    $.CONSUME(t.LBrace);
    $.OPTION(() => {
      $.SUBRULE($.forInit);
    });
    $.CONSUME(t.Semicolon);
    // consuming the first semiColon distinguishes between
    // "basic" and "enhanced" for statements
    return true;
  });

  $.RULE("isLocalVariableDeclaration", () => {
    $.MANY(() => {
      $.SUBRULE($.variableModifier);
    });
    $.SUBRULE($.localVariableType);
    $.SUBRULE($.variableDeclaratorId);

    const nextTokenType = this.LA(1).tokenType;
    switch (nextTokenType) {
      // Int x;
      case t.Semicolon:
      // Int x, y, z;
      case t.Comma:
      // Int x = 5;
      case t.Equals:
        return true;
      default:
        return false;
    }
  });
}
131574
@Override
	public void visit(Rule rule) {
		Rule copy = null;
		Filter filterCopy = null;

		if (rule.getFilter() != null) {
			Filter filter = rule.getFilter();
			filterCopy = copy(filter);
		}

		List<Symbolizer> symsCopy = new ArrayList<Symbolizer>();
		for (Symbolizer sym : rule.symbolizers()) {
			if (!skipSymbolizer(sym)) {
				Symbolizer symCopy = copy(sym);
				symsCopy.add(symCopy);
			}
		}

		Graphic[] legendCopy = rule.getLegendGraphic();
		for (int i = 0; i < legendCopy.length; i++) {
			legendCopy[i] = copy(legendCopy[i]);
		}

		Description descCopy = rule.getDescription();
		descCopy = copy(descCopy);

		copy = sf.createRule();
		copy.symbolizers().addAll(symsCopy);
		copy.setDescription(descCopy);
		copy.setLegendGraphic(legendCopy);
		copy.setName(rule.getName());
		copy.setFilter(filterCopy);
		copy.setElseFilter(rule.isElseFilter());
		copy.setMaxScaleDenominator(rule.getMaxScaleDenominator());
		copy.setMinScaleDenominator(rule.getMinScaleDenominator());

		if (STRICT && !copy.equals(rule)) {
			throw new IllegalStateException(
					"Was unable to duplicate provided Rule:" + rule);
		}
		pages.push(copy);
	}
402147
function(rule) {
      var state = this.bt.current_state();
      try { return rule.call(this); } 
      catch(f) {
        this.bt.catch_mismatch(f);
        this.bt.restore(state);
      }
    }
459913
public final void ruleParserRule() throws RecognitionException {

        		int stackSize = keepStackSize();
        	
        try {
            // InternalXtext.g:241:2: ( ( ( rule__ParserRule__Group__0 ) ) )
            // InternalXtext.g:242:2: ( ( rule__ParserRule__Group__0 ) )
            {
            // InternalXtext.g:242:2: ( ( rule__ParserRule__Group__0 ) )
            // InternalXtext.g:243:3: ( rule__ParserRule__Group__0 )
            {
             before(grammarAccess.getParserRuleAccess().getGroup()); 
            // InternalXtext.g:244:3: ( rule__ParserRule__Group__0 )
            // InternalXtext.g:244:4: rule__ParserRule__Group__0
            {
            pushFollow(FollowSets000.FOLLOW_2);
            rule__ParserRule__Group__0();

            state._fsp--;


            }

             after(grammarAccess.getParserRuleAccess().getGroup()); 

            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {

            	restoreStackSize(stackSize);

        }
        return ;
    }
310545
public synchronized void addRule(final RuleImpl rule) throws InvalidPatternException {
        final List<TerminalNode> terminals = this.ruleBuilder.addRule( rule,
                                                                       this.kBase );

        BaseNode[] nodes = terminals.toArray( new BaseNode[terminals.size()] );
        this.rules.put( rule.getFullyQualifiedName(), nodes );
        if (rule.isQuery()) {
            this.queries.put( rule.getName(), nodes );
        }
    }
1000045
public void add(Rule rule) {
		List<Token> tokens = rule.getTokens();
		for (Token token : tokens) {
			for (String str : token.getTerms()) {
				if (str.charAt(0) != ':') {
					Library.insertWord(forest, new Value(str, "rule", "10000"));
				}
			}
		}


		for (String str : tokens.get(0).getTerms()) {
			Set<Rule> rules = ruleIndex.get(str);
			if(rules==null){
				rules = new HashSet<>() ;
				ruleIndex.put(str,rules) ;
			}
			rules.add(rule) ;
		}
	}
1336585
function(rule) {
      var ans = arguments[1] !== undefined ? [arguments[1]] : [],
          state;
      while (true) {
        state = this.bt.current_state();
        try { ans.push(rule.call(this)) } 
        catch (f) {
          this.bt.catch_mismatch(f);
          this.bt.restore(state);
          break;
        }
      }
      return ans
    }
619290
function processRules(rules) {


		if (rules !== undefined) {

			rCount = rules.length;

			//reduce common declarations amongst children into parent
			if (OPTIONS.new_reduce_common_into_parent) {


				var directParents = [];
				var hierachy = [];
				var hierachyKeys = [];
				var hierachyLen = 0;
				var selectedHierachyLevel = 0;
				var commonParentsIdx = -1;
				var commonParentsKeys = [];
				var commonParents = [];
				var commonParentsLen = 0;
				var commonParent = '';
				var commonParent2 = '';
				var commonParentTotal = 0;
				var commonParentDeclarations = [];
				var commonLineage = '';
				var newParentDeclarations = [];
				var processedCommonParentsChildren = [];
				var classLineage = '';
				var parentClassLineage = '';
				var lineageLabel = '';
				var tmpDeclarations = [];

				for (i = 0; i < rCount; ++i) {

					///rules
					//group classes - create hierarchy
					if (rules[i].selectors !== undefined) {
						for (j = 0; j < rules[i].selectors.length; j++) { //each comma delimited
							
							if (rules[i].selectors[j].indexOf('.') != -1) {

								classLineage = rules[i].selectors[j].split(' ');
								parentClassLineage = classLineage.slice(0); //clone
								parentClassLineage.pop();
								parentClassLineage = parentClassLineage.join(' ');

								if (parentClassLineage !== undefined && parentClassLineage != '') {

									if (directParents[parentClassLineage] !== undefined) {
										directParents[parentClassLineage].push({
											selector: rules[i].selectors[j],
											index: i
										});
									} else {
										directParents[parentClassLineage] = [{
											selector: rules[i].selectors[j],
											index: i
										}];	
									}
									
								}


								for (k = 0; k < classLineage.length; k++) { //depth of hierachy

									if (k > 0) {
										lineageLabel = '';

										for (l = k; l > 0; l--) {
											lineageLabel += classLineage[k-l] + ' ';	
										}
										lineageLabel += classLineage[k];	

										if (hierachy[lineageLabel] === undefined) {
											hierachy[lineageLabel] = 0;
										}

										hierachy[lineageLabel] += 1;

									} else {

										if (hierachy[classLineage[k]] === undefined) {
											hierachy[classLineage[k]] = 0;
										}

										hierachy[classLineage[k]] += 1;
									}
								} //end of for
							} //end of if
						} //end of for
					}
				}

				function sortHierachy(obj) {
					var keys = Object.keys(obj);
					keys.sort(function(a,b){return b.length-a.length})
					hierachy = [];
					for (i = 0; i < keys.length; i++) {

						hierachy[keys[i]] = obj[keys[i]];


						Object.keys(directParents).forEach(function(key, index, val) {
						  
						  if (this[key].length > 1) {
							  for (j = 0; j < this[key].length; j++) {

							  	if (keys[i] == this[key][j].selector) {

								  	if (OPTIONS.verbose) { console.log(success('Process - Rules - Group Common Parent Rule : ' + keys[i] ));}
								  	commonParentsKeys.push({
								  		selector: key,
								  		index: this[key][j].index,
								  		childSelector: keys[i]
								  	});
								  }
							  }
							}

						}, directParents);
					}
					return hierachy;
				}
				sortHierachy(hierachy);
				hierachyKeys = Object.keys(hierachy);
				hierachyLen = hierachyKeys.length;
				selectedHierachyLevel = 0;
				commonParentsLen = commonParentsKeys.length;

				// get declarations
				for (i = 0; i < commonParentsKeys.length; i++) {

					if (rules[commonParentsKeys[i].index].declarations !== undefined) {

						for (j = 0; j < rules[commonParentsKeys[i].index].declarations.length; j++) {

							if (commonParentDeclarations[rules[commonParentsKeys[i].index].declarations[j].property + '_' + rules[commonParentsKeys[i].index].declarations[j].value] !== undefined) {

								commonParentDeclarations[rules[commonParentsKeys[i].index].declarations[j].property + '_' + rules[commonParentsKeys[i].index].declarations[j].value].count += 1;

							} else {
								commonParentDeclarations[rules[commonParentsKeys[i].index].declarations[j].property + '_' + rules[commonParentsKeys[i].index].declarations[j].value] = {

									property: rules[commonParentsKeys[i].index].declarations[j].property,
									value: rules[commonParentsKeys[i].index].declarations[j].value,
									count: 1,
									selector: rules[commonParentsKeys[i].index].selectors,
									selectorIndex: commonParentsKeys[i].index,
									commonParent: commonParentsKeys[i].selector
								};
							}
						}

					}

				}

				Object.keys(commonParentDeclarations).forEach(function(val, index, key) {

					if (this[val].count == directParents[this[val].commonParent].length) {

						if (newParentDeclarations[this[val].commonParent] !== undefined) {
							newParentDeclarations[this[val].commonParent].declarations.push({
								type: 'declaration',
								property: this[val].property,
								value: this[val].value
							});
						} else {
							newParentDeclarations[this[val].commonParent] = {
								declarations: [{
									type: 'declaration',
									property: this[val].property,
									value: this[val].value
								}],
								selectorIndex: this[val].selectorIndex
							};
						}

						commonParents.push(this[val].commonParent);
					}

				}, commonParentDeclarations);


				commonParentsLen = commonParentsKeys.length;

				for (i = 0; i < commonParentsLen; i++) {

					Object.keys(newParentDeclarations).forEach(function(key, index) {

						if (commonParentsKeys[i] !== undefined && commonParentsKeys[i].selector == key) {

						  if (rules[commonParentsKeys[i].index] !== undefined && rules[commonParentsKeys[i].index].declarations !== undefined) {
						  	
						  	//clone declarations
						  	tmpDeclarations = rules[commonParentsKeys[i].index].declarations.slice(0); //clone
						  	dCount = tmpDeclarations.length;
							  
						  	for (j = 0; j < this[key].declarations.length; j++) { //each parent declaration

							  	//remove declarations
							  	for (k = 0; k < dCount; k++) { //each child declaration

							  		if (
							  			this[key].declarations[j] !== undefined
							  			&& this[key].declarations[j].type == 'declaration'
							  			&& this[key].declarations[j].property == tmpDeclarations[k].property
							  			&& this[key].declarations[j].value == tmpDeclarations[k].value
							  		) {
							  			tmpDeclarations.splice(k, 1); 
							  			k -= 1;
							  			dCount-=1;
							  		}
							  	} //end of k loop

							  } //end of j loop
							  
							  if (tmpDeclarations.length == 0) {

							  	//remove whole rule
							  	rules.splice(commonParentsKeys[i].index, 1);
							  	i-=1;
							  	commonParentsLen-=1;

							  } else {
							  	//update declarations
							  	rules[commonParentsKeys[i].index].declarations = tmpDeclarations;
							  }
								  	
						  }
						}
					  
					}, newParentDeclarations);
				} //end of i loop

				//Create Common Parents
				Object.keys(newParentDeclarations).forEach(function(key, index) {
				  
				  rules.splice( ((this[key].selectorIndex-1 < 0) ? this[key].selectorIndex : this[key].selectorIndex-1), 0, {
						type : 'rule',
						selectors: [key],
						declarations: this[key].declarations
					});

				}, newParentDeclarations);

				//some cleanup
				directParents = [];
				hierachy = [];
				hierachyKeys = [];
				commonParentsKeys = [];
				commonParents = [];
				commonParentDeclarations = [];
				newParentDeclarations = [];
				processedCommonParentsChildren = [];
				tmpDeclarations = [];
				
				//reset rules count
				rCount = rules.length;

			} //end of reduce common declarations amongst children into parent





			for (i = 0; i < rCount; ++i) {

				////comments
				//checking declarations for comments
				if (rules[i] !== undefined && rules[i].declarations !== undefined) {
					declarations = rules[i].declarations;
					dCount = declarations.length;

					for (j = 0; j < dCount; ++j) {

						//check for empty properties
						if (rules[i].declarations[j].value == '') {
							summary.empty_declarations.push({
								'selectors': rules[i].selectors,
								'property': rules[i].declarations[j]
							});
						}

						//remove comments in declarations - for turning off comments
						if (OPTIONS.trim_comments || OPTIONS.trim) {
							if (declarations[j] !== undefined && declarations[j].type == 'comment') {
								if (OPTIONS.verbose) { console.log(info('Process - Rules - Remove Comment')); }
								rules[i].declarations.splice(j, 1);
								j-=1;
								dCount-=1;
							}
						}
					}
				}

				//remove comments in root - for turning off comments
				if (OPTIONS.trim_comments || OPTIONS.trim) {
					if (rules[i] !== undefined && rules[i].type == 'comment') {
						if (OPTIONS.verbose) { console.log(info('Process - Rules - Remove Comment')); }
						rules.splice(i, 1);
						i-=1;
						rCount-=1;
					}
				}
				////end of comments


				////rules
				//remove duplicate root rules
				for (j = i+1; j < rCount; ++j) {
					// console.log(j, rCount)
					//root rules
					//rule selector
					if (rules[i] !== undefined 
						// && rules[i].type == 'rule'
						&& rules[i].selectors !== undefined 
						&& rules[j] !== undefined && rules[j].selectors !== undefined) {

						//duplicate rule found
						if (rules[i].selectors.toString() == rules[j].selectors.toString()) {

							//remove previous comment in root
							if (OPTIONS.trim_removed_rules_previous_comment || OPTIONS.trim) {
								if (rules[i-1] !== undefined && rules[i-1].type == 'comment') {

									rules.splice(i-1, 1);
									i-=1;
									j-=1;
									rCount-=1;
								}
							}

							if (OPTIONS.verbose) { console.log(success('Process - Rules - Group Duplicate Rule : ' + (rules[j].selectors ? rules[j].selectors.join(', ') : '')));}

							//copy + reduce
							summary.stats.summary.noDuplicateRules += 1;
							if ( j < i && (j-i) > 1 ) { //check comparison distance
								summary.duplicate_rules.push({
									'selectors': (rules[i].type == 'page') ? '@page' : rules[i].selectors,
									'position': rules[i].position
								});
								rules[j].declarations = rules[j].declarations.concat(rules[i].declarations);
								rules.splice(i, 1);
							} else {
								summary.duplicate_rules.push({
									'selectors': (rules[j].type == 'page') ? '@page' : rules[j].selectors,
									'position': rules[j].position
								});
								rules[i].declarations = rules[i].declarations.concat(rules[j].declarations);
								rules.splice(j, 1);
							}
							i-=1;
							j-=1;
							rCount-=1;				

						}
					} //end of rule selector

					//media selector - it could affect evaluation sequence
					if (rules[i] !== undefined && rules[i].type == 'media' 
						&& rules[i].media !== undefined 
						&& rules[j] !== undefined && rules[j].media !== undefined
						&& OPTIONS.bypass_media_rules != true
					) {

						//duplicate rule found
						if (rules[i].media.toString() == rules[j].media.toString()) {

							//remove previous comment in root
							if (OPTIONS.trim_removed_rules_previous_comment || OPTIONS.trim) {
								if (rules[i-1] !== undefined && rules[i-1].type == 'comment') {

									rules.splice(i-1, 1);
									i-=1;
									j-=1;
									rCount-=1;
								}
							}

							if (OPTIONS.verbose) { console.log(info('Process - Rules - @media - Group Duplicate Rule : ' + (rules[j].selectors ? rules[j].selectors.join(', ') : ''))); }

							//copy + reduce
							summary.stats.summary.noDuplicateRules += 1;
							if ( j < i && (j-i) > 1 ) { //check comparison distance
								summary.duplicate_rules.push({
									'selectors': '@media ' + rules[i].media,
									'position': rules[i].position
								});
								rules[j].rules = rules[j].rules.concat(rules[i].rules);
								rules.splice(i, 1);
							} else {
								summary.duplicate_rules.push({
									'selectors': '@media ' + rules[j].media,
									'position': rules[j].position
								});
								rules[i].rules = rules[i].rules.concat(rules[j].rules);
								rules.splice(j, 1);
							}
							i-=1;
							j-=1;
							rCount-=1;
						}
					} 
					//end of media selector

					//document selector
					if (rules[i] !== undefined && rules[i].type == 'document' 
						&& rules[i].document !== undefined 
						&& rules[j] !== undefined && rules[j].document !== undefined) {

						//duplicate rule found
						if (rules[i].document.toString() == rules[j].document.toString()) {

							//remove previous comment in root
							if (OPTIONS.trim_removed_rules_previous_comment || OPTIONS.trim) {
								if (rules[i-1] !== undefined && rules[i-1].type == 'comment') {

									rules.splice(i-1, 1);
									i-=1;
									j-=1;
									rCount-=1;
								}
							}

							if (OPTIONS.verbose) { console.log(success('Process - Rules - @document - Group Duplicate Rule : ' + (rules[j].selectors ? rules[j].selectors.join(', ') : ''))); }

							//copy + reduce
							summary.stats.summary.noDuplicateRules += 1;
							if ( j < i && (j-i) > 1 ) { //check comparison distance
								summary.duplicate_rules.push({
									'selectors': '@document ' + rules[i].document,
									'position': rules[i].position
								});
								rules[j].rules = rules[j].rules.concat(rules[i].rules);
								rules.splice(i, 1);
							} else {
								summary.duplicate_rules.push({
									'selectors': '@document ' + rules[j].document,
									'position': rules[j].position
								});
								rules[i].rules = rules[i].rules.concat(rules[j].rules);
								rules.splice(j, 1);
							}
							i-=1;
							j-=1;
							rCount-=1;
							
						}
					} //end of document selector

					//supports selector
					if (rules[i] !== undefined && rules[i].type == 'supports' 
						&& rules[i].supports !== undefined 
						&& rules[j] !== undefined && rules[j].supports !== undefined) {

						//duplicate rule found
						if (rules[i].supports.toString() == rules[j].supports.toString()) {

							//remove previous comment in root
							if (OPTIONS.trim_removed_rules_previous_comment || OPTIONS.trim) {
								if (rules[i-1] !== undefined && rules[i-1].type == 'comment') {

									rules.splice(i-1, 1);
									i-=1;
									j-=1;
									rCount-=1;
								}
							}

							
							if (OPTIONS.verbose) { console.log(success('Process - Rules - @supports - Group Duplicate Rule : ' + (rules[j].supports ? rules[j].supports : ''))); }

							//copy + reduce
							summary.stats.summary.noDuplicateRules += 1;
							if ( j < i && (j-i) > 1 ) { //check comparison distance
								summary.duplicate_rules.push({
									'selectors': '@supports ' + rules[i].supports,
									'position': rules[i].position
								});
								rules[j].rules = rules[j].rules.concat(rules[i].rules);
								rules.splice(i, 1);
							} else {
								summary.duplicate_rules.push({
									'selectors': '@supports ' + rules[j].supports,
									'position': rules[j].position
								});
								rules[i].rules = rules[i].rules.concat(rules[j].rules);
								rules.splice(j, 1);
							}
							i-=1;
							j-=1;
							rCount-=1;
							

						}
					} //end of supports selector



				} //end of j
				////end of rules


				////declarations
				//reduce root delcarations by property name and by duplicate values
				if (rules[i] !== undefined 
					&& (rules[i].type == 'rule' || (rules[i].type == 'page' && OPTIONS.bypass_page_rules == false))
				) {

					declarationsNameCounts = [];

					dCount = rules[i].declarations.length;

					//declarations duplicate check
					for (l = 0; l < dCount; ++l) {

						if (rules[i].declarations[l].type == 'declaration') {
							if (declarationsNameCounts[rules[i].declarations[l].property] !== undefined) {
								declarationsNameCounts[rules[i].declarations[l].property] += 1;
							} else {
								declarationsNameCounts[rules[i].declarations[l].property] = 1;
							}
						}
					} //end of declarations duplicate check


					//reduce according to values
					declarationsValueCounts = [];
					valKey = '';
					//detect duplicate values
					for (key in declarationsNameCounts) {

			      if (!reduceRulesListName.includes(key)) { //only properties not in list


							for (l = 0; l < dCount; ++l) {

								if (
									rules[i].declarations[l].type == 'declaration'
									&& rules[i].declarations[l].property == key
								) {
									hash = crypto.createHash('sha256');
									hash.update(rules[i].declarations[l].property + rules[i].declarations[l].value);
									
									valKey = hash.digest('hex');

									if (declarationsValueCounts[valKey] !== undefined) {
										declarationsValueCounts[valKey].id += ',' + l;
										declarationsValueCounts[valKey].count += 1;
									} else {
										declarationsValueCounts[valKey] = {
											id : l,
											count : 1
										}
									}
								}
							}
			      }
			    }

			    //remove duplicate declarations by duplicate values
			    declarationsValueCountsCount = Object.keys(declarationsValueCounts).length;

			    amountRemoved = 1;

					for (key in declarationsValueCounts) {
			      if (declarationsValueCounts.hasOwnProperty(key)) {


			      	if (declarationsValueCounts[key].count > 1) {
			      		duplicate_ids = declarationsValueCounts[key].id.split(',');

			      		amountRemoved = 1; //shift the ids by the amount removed
								for (l = 0; l < duplicate_ids.length-1; ++l) { // -1 to leave last behind

									//remove previous comment above declaration to be removed
									if (OPTIONS.trim_removed_rules_previous_comment || OPTIONS.trim) {

										if (rules[i].declarations[duplicate_ids[l]-1] !== undefined && rules[i].declarations[duplicate_ids[l]-1].type == 'comment') {

											rules[i].declarations.splice(duplicate_ids[l]-1, 1);
											dCount-=1;

											//adjust removal ids by amount already removed
											if (duplicate_ids[l] !== undefined) {
												duplicate_ids[l] -= amountRemoved; //shift the ids by the amount removed
											}
											amountRemoved += 1;
										}
									}

									if (OPTIONS.verbose) { console.log(success('Process - Declaration - Group Duplicate Declarations : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : '') + ' - ' + (rules[i].declarations[l]!==undefined?rules[i].declarations[l].property:''))); }

									summary.duplicate_declarations.push(rules[i].declarations[duplicate_ids[l]]);
									summary.stats.summary.noDuplicateDeclarations += 1;
									rules[i].declarations.splice(duplicate_ids[l], 1);
									dCount-=1;

									//adjust removal ids by amount already removed
									if (duplicate_ids[l+1] !== undefined) {
										duplicate_ids[l+1] -= amountRemoved; //shift the ids by the amount removed

										//shift all the ids of the declarations afterwards
										for (key2 in declarationsValueCounts) {
											if (declarationsValueCounts.hasOwnProperty(key2) && (key2 != key)) {

												if (typeof declarationsValueCounts[key2].id == 'number') {
													duplicate_ids = [];
													duplicate_ids[0] = declarationsValueCounts[key2].id;
												} else {
													duplicate_ids = declarationsValueCounts[key2].id.split(',');	
												}
							      		
							      		for (l = 0; l < duplicate_ids.length; ++l) {
							      			
													if (duplicate_ids[l] !== undefined) {
								      			duplicate_ids[l] -= amountRemoved;
								      		}
							      		}
							      		declarationsValueCounts[key2].id = duplicate_ids.join();
											}
										}
										//end of shifting all ids

									}
									amountRemoved += 1;
								}

				      } //end of if
			      } //end of if
			    } //end of for in
					//end of reduce according to values

					for (k = 0; k < reduceRulesListNameCount; ++k) {

						//declarations reduction
						for (key in declarationsNameCounts) {
				      if (declarationsNameCounts.hasOwnProperty(key)) {

								if (declarationsNameCounts[key] > 1) {

									for (l = 0; l < dCount; ++l) {
										if (rules[i].declarations[l].type == 'declaration') {

											if (
												rules[i].declarations[l].property == key 
												&& declarationsNameCounts[key] > 1 //leave behind 1
											) {

												//reduce according to list
												if (rules[i].declarations[l].property == reduceRulesListName[k]) { 
													
													// console.log(declarationsNameCounts[key])
													// console.log(key)
													// console.log(rules[i].declarations[l].property)
													// console.log(reduceRulesListName[k])

													//remove previous comment above declaration to be removed
													if (OPTIONS.trim_removed_rules_previous_comment || OPTIONS.trim) {
														if (rules[i].declarations[l-1] !== undefined && rules[i].declarations[l-1].type == 'comment') {

															rules[i].declarations.splice(l-1, 1);
															l-=1;
															dCount-=1;
														}
													}

													if (OPTIONS.verbose) { console.log(success('Process - Declaration - Group Duplicate Declarations : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : '') + ' - ' + (rules[i].declarations[l]!==undefined?rules[i].declarations[l].property:''))); }

													// console.log(rules[i].declarations[l].value.indexOf('!important') !== -1)
													// console.log(rules[i].declarations[l].value)
													// console.log(rules[i].declarations[l+1].value)

													//prioritises !important declarations
													if (rules[i].declarations[l].value.indexOf('!important') !== -1) {
														
														summary.duplicate_declarations.push(rules[i].declarations[l+1]);
														summary.stats.summary.noDuplicateDeclarations += 1;
														rules[i].declarations.splice(l+1, 1);

													} else {

														summary.duplicate_declarations.push(rules[i].declarations[l]);
														summary.stats.summary.noDuplicateDeclarations += 1;
														rules[i].declarations.splice(l, 1);
													}

													l-=1;
													dCount-=1;
													declarationsNameCounts[key] -= 1;
												}
											}
										}
									}
								}
							}
						}
					} //end of reduce root declarations by property name

				} //end of rule check



				//reduce root declarations by selector
				selectorPropertiesList = [];
				declarationsCounts = [];
				for (k = 0; k < reduceRulesListSelectorCount; ++k) {

					if (rules[i] !== undefined 
						&& rules[i].type == 'rule'
					) {

						if (rules[i].selectors !== undefined && rules[i].selectors.toString() === reduceRulesListSelector[k]) {
						
							dCount = rules[i].declarations.length;

							//detect declarations duplicates
							for (l = 0; l < dCount; ++l) {
								if (rules[i].declarations[l].type == 'declaration'
								) {
									if (declarationsCounts[rules[i].declarations[l].property] !== undefined) {
										declarationsCounts[rules[i].declarations[l].property] += 1;
									} else {
										declarationsCounts[rules[i].declarations[l].property] = 1;
									}
								}
							} //end of declarations duplicate check

							// declarations reduction
							for (key in declarationsCounts) {
					      if (declarationsCounts.hasOwnProperty(key)) {

									if (declarationsCounts[key] > 1) {

										for (l = 0; l < dCount; ++l) {
											if (rules[i].declarations[l].type == 'declaration') {

												selectorPropertiesList = reduceRulesListSelectorPName[reduceRulesListSelector[k]];
												
												if (selectorPropertiesList !== undefined) { //specific in selector

													if (rules[i].declarations[l].property == key 
														&& (selectorPropertiesList.indexOf(rules[i].declarations[l].property) != -1)
														&& declarationsCounts[key] > 1) { //leave behind 1

														//remove previous comment above declaration to be removed
														if (OPTIONS.trim_removed_rules_previous_comment || OPTIONS.trim) {
															if (rules[i].declarations[l-1] !== undefined && rules[i].declarations[l-1].type == 'comment') {

																rules[i].declarations.splice(l-1, 1);
																l-=1;
																dCount-=1;
															}
														}

														if (OPTIONS.verbose) { console.log(success('Process - Declaration - Group Duplicate Declarations : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : '') + ' - ' + (rules[i].declarations[l]!==undefined?rules[i].declarations[l].property:''))); }
														summary.duplicate_declarations.push(rules[i].declarations[l]);
														summary.stats.summary.noDuplicateDeclarations += 1;
														rules[i].declarations.splice(l, 1);
														l-=1;
														dCount-=1;
														declarationsCounts[key] -= 1;
													}

												} else { //all in selector

													if (rules[i].declarations[l].property == key 
														&& declarationsCounts[key] > 1) { //leave behind 1

														//remove previous comment above declaration to be removed
														if (OPTIONS.trim_removed_rules_previous_comment || OPTIONS.trim) {
															if (rules[i].declarations[l-1] !== undefined && rules[i].declarations[l-1].type == 'comment') {

																rules[i].declarations.splice(l-1, 1);
																l-=1;
																dCount-=1;
															}
														}

														if (OPTIONS.verbose) { console.log(success('Process - Declaration - Group Duplicate Declarations : ' + (rules[i].selectors ? rules[i].selectors.join(', ') : '') + ' - ' + (rules[i].declarations[l]!==undefined?rules[i].declarations[l].property:''))); }
														summary.duplicate_declarations.push(rules[i].declarations[l]);
														summary.stats.summary.noDuplicateDeclarations += 1;
														rules[i].declarations.splice(l, 1);
														l-=1;
														dCount-=1;
														declarationsCounts[key] -= 1;
													}
												}
											}
										}
									}

					      }
					    } //end of declarations reduction

						} //end of if
					} //end of if				
				} //end of reduce root declarations by selector

				////end of declarations




				////empty nodes
				//remove empty @sign keyframes
				if (rules[i] != undefined && rules[i].keyframes !== undefined && rules[i].keyframes.length == 0) {

					//remove previous comment in root
					if (OPTIONS.trim_removed_rules_previous_comment || OPTIONS.trim) {
						if (rules[i-1] !== undefined && rules[i-1].type == 'comment') {
							if (OPTIONS.verbose) { console.log(info('Process - @keyframes - Remove comment : ' + (rules[i].keyframes ? rules[i].keyframes.join(', ') : ''))); }
							rules.splice(i-1, 1);
							i-=1;
							rCount-=1;
						}
					}
					
					if (OPTIONS.verbose) { console.log(info('Process - @keyframes - Remove Empty Rule : ' + (rules[i].keyframes ? rules[i].keyframes.join(', ') : ''))); }

					rules.splice(i, 1);
					i-=1;
					rCount-=1;
				}

				//remove empty @sign media
				if (rules[i] !== undefined && rules[i].type == 'media' 
					&& rules[i].rules.length == 0) {

					//remove previous comment in root
					if (OPTIONS.trim_removed_rules_previous_comment || OPTIONS.trim) {
						if (rules[i-1] !== undefined && rules[i-1].type == 'comment') {
							if (OPTIONS.verbose) { console.log(info('Process - @media - Remove comment : ' + (rules[i].media ? rules[i].media : ''))); }
							rules.splice(i-1, 1);
							i-=1;
							rCount-=1;
						}
					}
					if (OPTIONS.verbose) { console.log(info('Process - @media - Remove Empty Rule : ' + (rules[i].media ? rules[i].media : ''))); }
					rules.splice(i, 1);
					i-=1;
					rCount-=1;
				}

				//remove empty @sign document
				if (rules[i] !== undefined && rules[i].type == 'document' 
					&& rules[i].rules.length == 0) {

					//remove previous comment in root
					if (OPTIONS.trim_removed_rules_previous_comment || OPTIONS.trim) {
						if (rules[i-1] !== undefined && rules[i-1].type == 'comment') {
							if (OPTIONS.verbose) { console.log(info('Process - @document - Remove comment : ' + (rules[i].document ? rules[i].document : ''))); }
							rules.splice(i-1, 1);
							i-=1;
							rCount-=1;
						}
					}

					if (OPTIONS.verbose) { console.log(info('Process - @document - Remove Empty Rule : ' + (rules[i].document ? rules[i].document : ''))); }
					rules.splice(i, 1);
					i-=1;
					rCount-=1;
				}

				//remove empty @sign supports
				if (rules[i] !== undefined && rules[i].type == 'supports' 
					&& rules[i].rules.length == 0) {

					//remove previous comment in root
					if (OPTIONS.trim_removed_rules_previous_comment || OPTIONS.trim) {
						if (rules[i-1] !== undefined && rules[i-1].type == 'comment') {
							if (OPTIONS.verbose) { console.log(info('Process - @supports - Remove comment : ' + (rules[i].supports ? rules[i].supports : ''))); }
							rules.splice(i-1, 1);
							i-=1;
							rCount-=1;
						}
					}

					if (OPTIONS.verbose) { console.log(info('Process - @supports - Remove Empty Rule : ' + (rules[i].supports ? rules[i].supports : ''))); }
					rules.splice(i, 1);
					i-=1;
					rCount-=1;
				}
				////end of empty nodes



			} //end of i

		} //end of undefined
	}
1042620
public function parseGroupRule($rule)
    {
        $origin = $this->router->getGroup();
        $this->router->setGroup($this);

        if ($rule instanceof \Closure) {
            Container::getInstance()->invokeFunction($rule);
        } elseif (is_array($rule)) {
            $this->addRules($rule);
        } elseif (is_string($rule) && $rule) {
            $this->router->bind($rule, $this->domain);
        }

        $this->router->setGroup($origin);
    }
337107
function _getRule(attribute, rules) {
    rules = rules || [];

    if ( ! rules[attribute]) {
      return;
    }

    for(var i in rules[attribute]) {
      var value = rules[attribute][i];
      parsedRule = _parseRule(rule);

      if (in_array(parsedRule.rule, rules))
        return [parsedRule.rule, parsedRule.parameters];
    }
  }
970220
function Rule(ruleString, params, data) {
    Tools.call(this, ruleString);

    /**
     * @public
     * @memberOf {Rule}
     * @property
     * @type {Object}
     * */
    this.params = _.extend({
        basePath: '',
        queryEq: '=',
        querySep: '&'
    }, params);

    /**
     * @public
     * @memberOf {Rule}
     * @property
     * @type {Object}
     * */
    this.data = _.extend({
        name: uniqueId()
    }, data);

    /**
     * @protected
     * @memberOf {Rule}
     * @property
     * @type {Array<String>}
     * */
    this._pathParams = this._findPathParams();

    /**
     * @protected
     * @memberOf {Rule}
     * @property
     * @type {Object}
     * */
    this._queryParams = this._compileQueryParams();

    /**
     * @protected
     * @memberOf {Rule}
     * @property
     * @type {Array}
     * */
    this._queryParamsNames = _.keys(this._queryParams);

    this.params.types = _.extend({}, commonTypes, this.params.types);

    /**
     * @protected
     * @memberOf {Rule}
     * @property
     * @type {Object}
     * */
    this._kinds = _.mapValues(this.params.types, function (regex, kind) {
        return new Kind(kind, regex);
    });

    _.forEach([{
        rules: this._pathParams,
        defaultKind: 'Segment'
    }, {
        rules: this._pathRule.query,
        defaultKind: 'String'
    }], function (setup) {
        _.forEach(setup.rules, function (rule) {
            if (!rule.kind) {
                if (rule.regex) {
                    rule.setUniqueKindName();
                    this._kinds[rule.kind] = new Kind(rule.kind, rule.regex);
                } else {
                    rule.kind = setup.defaultKind;
                }
            }

            if (!_.has(this._kinds, rule.kind)) {
                throw new TypeError(f('Unknown %j parameter type %j', rule.name, rule.kind));
            }
        }, this);
    }, this);

    /**
     * @protected
     * @memberOf {Rule}
     * @property
     * @type {Object}
     * */
    this._paramsCount = this._compileParamsCount();

    /**
     * @protected
     * @memberOf {Rule}
     * @property
     * @type {RegExp}
     * */
    this._matchRegExp = this._compileMatchRegExp();
}
366976
private void parseRule( Rule rule ) {
        ruleStack.add( rule );
        for( ;; ) {
            int ch = reader.nextBlockMarker();
            switch( ch ) {
                case -1:
                    throw createException( "Unexpected end of Less data" );
                case ';':
                    parseSemicolon( rule );
                    break;
                case '{':
                    parseBlock( rule );
                    break;
                case '}':
                    parseSemicolon( rule );
                    ruleStack.removeLast();
                    return;
                default:
                    throw createException( "Unrecognized input: '" + reader.getLookAhead() + "'" );
            }
        }

    }