{"size": 927, "ext": "js", "max_stars_repo_path": "lib/rules-engine/parse/rules.js", "max_stars_repo_name": "defstream/nl3", "max_stars_repo_stars_event_min_datetime": "2015-12-24T02:37:44.000Z", "max_stars_repo_stars_event_max_datetime": "2018-03-04T11:44:32.000Z", "max_issues_repo_path": "lib/rules-engine/parse/rules.js", "max_issues_repo_name": "defstream/nl3", "max_issues_repo_issues_event_min_datetime": "2015-12-24T10:19:02.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-11T16:03:16.000Z", "max_forks_repo_path": "lib/rules-engine/parse/rules.js", "max_forks_repo_name": "defstream/nl3", "max_forks_repo_forks_event_min_datetime": "2015-12-24T10:17:51.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-23T06:12:16.000Z"}
{"max_stars_count": 12, "max_issues_count": 51, "max_forks_count": 13, "avg_line_length": 31.9655172414, "max_line_length": 79, "alphanum_fraction": 0.7001078749}
/*jslint node: true */
/*global module, require*/
'use strict';

var parseSubjects = require('./subjects');
var parsePredicates = require('./reduce-predicates');
var parseObjects = require('./objects');
var singularize = require('../../text/singularize');

/**
 * parses the grammar rules from a string array.
 * @param  {Object} ruleset The ruleset to apply the parsed grammar rules to.
 * @param  {Array}  data    An array of strings representing the grammar rules.
 * @return {Object}         The parsed grammar rules.
 */
module.exports = function rules(ruleset, data) {
  data = data.toString().split(' ');

  var subject = singularize(data[0]);
  var predicate = singularize(data[1]);
  var object = singularize(data[2]);

  ruleset = parseSubjects(ruleset, subject, predicate, object);
  ruleset = parsePredicates(ruleset, predicate);
  ruleset = parseObjects(ruleset, subject, predicate, object);

  return ruleset;
};
