<commit_before>var postcss   = require('postcss');
var vars      = require('postcss-simple-vars');
var list      = postcss.list;

var SEPARATOR = /\s+in\s+/;

function checkParams(params) {
  if (!SEPARATOR.test(params)) return 'Missed "in" keyword in @each';

  var params = params.split(SEPARATOR);
  var name   = params[0].trim();
  var values = params[1].trim();

  if (!name.match(/\$[_a-zA-Z]?\w+/)) return 'Missed variable name in @each';
  if (!values.match(/(\w+\,?\s?)+/)) return 'Missed values list in @each';

  return null;
}

function paramsList(params) {
  var params    = params.split(SEPARATOR);
  var vars      = params[0].split(',');
  var valueName = vars[0];
  var indexName = vars[1];

  return {
    valueName:  valueName.replace('$', '').trim(),
    indexName:  indexName && indexName.replace('$', '').trim(),
    values:     list.comma(params[1])
  };
}

function processRules(rule, params) {
  var values = {};

  rule.nodes.forEach(function(node) {
    params.values.forEach(function(value, index) {
      var clone = node.clone();
      var proxy = postcss.rule({ nodes: [clone] });

      values[params.valueName] = value;
      if (params.indexName) values[params.indexName] = index;

      vars({ only: values })(proxy);

      rule.parent.insertBefore(rule, clone);
    });
  });
}

function processEach(rule) {
  processLoop(rule);

  var params = ' ' + rule.params + ' ';
  var error = checkParams(params);
  if (error) throw rule.error(error);

  var params = paramsList(params);
  processRules(rule, params);
  rule.removeSelf();
}

function processLoop(css) {
  css.eachAtRule('each', processEach);
};

module.exports = postcss.plugin('postcss-each', function(opts) {
  opts = opts || {};
  return processLoop;
});<commit_msg>Use a different variable for parsed params<commit_after>var postcss   = require('postcss');
var vars      = require('postcss-simple-vars');
var list      = postcss.list;

var SEPARATOR = /\s+in\s+/;

function checkParams(params) {
  if (!SEPARATOR.test(params)) return 'Missed "in" keyword in @each';

  var params = params.split(SEPARATOR);
  var name   = params[0].trim();
  var values = params[1].trim();

  if (!name.match(/\$[_a-zA-Z]?\w+/)) return 'Missed variable name in @each';
  if (!values.match(/(\w+\,?\s?)+/)) return 'Missed values list in @each';

  return null;
}

function paramsList(params) {
  var params    = params.split(SEPARATOR);
  var vars      = params[0].split(',');
  var valueName = vars[0];
  var indexName = vars[1];

  return {
    valueName:  valueName.replace('$', '').trim(),
    indexName:  indexName && indexName.replace('$', '').trim(),
    values:     list.comma(params[1])
  };
}

function processRules(rule, params) {
  var values = {};

  rule.nodes.forEach(function(node) {
    params.values.forEach(function(value, index) {
      var clone = node.clone();
      var proxy = postcss.rule({ nodes: [clone] });

      values[params.valueName] = value;
      if (params.indexName) values[params.indexName] = index;

      vars({ only: values })(proxy);

      rule.parent.insertBefore(rule, clone);
    });
  });
}

function processEach(rule) {
  processLoop(rule);

  var params = ' ' + rule.params + ' ';
  var error = checkParams(params);
  if (error) throw rule.error(error);

  var parsedParams = paramsList(params);
  processRules(rule, parsedParams);
  rule.removeSelf();
}

function processLoop(css) {
  css.eachAtRule('each', processEach);
};

module.exports = postcss.plugin('postcss-each', function(opts) {
  opts = opts || {};
  return processLoop;
});
{'fraction_non_alphanumeric': 0.17605831230726102, 'fraction_numerical': 0.00336417157275021, 'mean_word_length': 3.627756160830091, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6995341', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1180, 'n_words': 268}