function _buildRules(rules) {
    // Array of rules to be used to simplify expressions
    var ruleSet = [];

    for (var i = 0; i < rules.length; i++) {
      var rule = rules[i];
      var newRule = void 0;

      var ruleType = _typeof(rule);

      switch (ruleType) {
        case 'string':
          var lr = rule.split('->');

          if (lr.length === 2) {
            rule = {
              l: lr[0],
              r: lr[1]
            };
          } else {
            throw SyntaxError('Could not parse rule: ' + rule);
          }

        /* falls through */

        case 'object':
          newRule = {
            l: removeParens(parse(rule.l)),
            r: removeParens(parse(rule.r))
          };

          if (rule.context) {
            newRule.evaluate = rule.context;
          }

          if (rule.evaluate) {
            newRule.evaluate = parse(rule.evaluate);
          }

          if (isAssociative(newRule.l)) {
            var makeNode = createMakeNodeFunction(newRule.l);

            var expandsym = _getExpandPlaceholderSymbol();

            newRule.expanded = {};
            newRule.expanded.l = makeNode([newRule.l.clone(), expandsym]); // Push the expandsym into the deepest possible branch.
            // This helps to match the newRule against nodes returned from getSplits() later on.

            flatten(newRule.expanded.l);
            unflattenr(newRule.expanded.l);
            newRule.expanded.r = makeNode([newRule.r, expandsym]);
          }

          break;

        case 'function':
          newRule = rule;
          break;

        default:
          throw TypeError('Unsupported type of rule: ' + ruleType);
      } // console.log('Adding rule: ' + rules[i])
      // console.log(newRule)


      ruleSet.push(newRule);
    }

    return ruleSet;
  }
Parse the string array of rules into nodes

Example syntax for rules:

Position constants to the left in a product:
{ l: 'n1 * c1', r: 'c1 * n1' }
n1 is any Node, and c1 is a ConstantNode.

Apply difference of squares formula:
{ l: '(n1 - n2) * (n1 + n2)', r: 'n1^2 - n2^2' }
n1, n2 mean any Node.

Short hand notation:
'n1 * c1 -> c1 * n1'