src/Grammar.js
function(what, name, actionDict) {
    function isSpecialAction(a) {
      return a === '_iter' || a === '_terminal' || a === '_nonterminal' || a === '_default';
    }

    var problems = [];
    for (var k in actionDict) {
      var v = actionDict[k];
      if (!isSpecialAction(k) && !(k in this.rules)) {
        problems.push("'" + k + "' is not a valid semantic action for '" + this.name + "'");
      } else if (typeof v !== 'function') {
        problems.push(
            "'" + k + "' must be a function in an action dictionary for '" + this.name + "'");
      } else {
        var actual = v.length;
        var expected = this._topDownActionArity(k);
        if (actual !== expected) {
          problems.push(
              "Semantic action '" + k + "' has the wrong arity: " +
              'expected ' + expected + ', got ' + actual);
        }
      }
    }
    if (problems.length > 0) {
      var prettyProblems = problems.map(function(problem) { return '- ' + problem; });
      var error = new Error(
          "Found errors in the action dictionary of the '" + name + "' " + what + ':\n' +
          prettyProblems.join('\n'));
      error.problems = problems;
      throw error;
    }
  }
function(what, name, actionDict) {
    function isSpecialAction(a) {
      return a === '_iter' || a === '_terminal' || a === '_nonterminal' || a === '_default';
    }

    var problems = [];
    for (var k in actionDict) {
      var v = actionDict[k];
      if (!isSpecialAction(k) && !(k in this.rules)) {
        problems.push("'" + k + "' is not a valid semantic action for '" + this.name + "'");
      } else if (typeof v !== 'function') {
        problems.push(
            "'" + k + "' must be a function in an action dictionary for '" + this.name + "'");
      } else {
        var actual = v.length;
        var expected = this._topDownActionArity(k);
        if (actual !== expected) {
          problems.push(
              "Semantic action '" + k + "' has the wrong arity: " +
              'expected ' + expected + ', got ' + actual);
        }
      }
    }
    if (problems.length > 0) {
      var prettyProblems = problems.map(function(problem) { return '- ' + problem; });
      var error = new Error(
          "Found errors in the action dictionary of the '" + name + "' " + what + ':\n' +
          prettyProblems.join('\n'));
      error.problems = problems;
      throw error;
    }
  }
function ( what , name , actionDict ) { function isSpecialAction ( a ) { return a === '_iter' || a === '_terminal' || a === '_nonterminal' || a === '_default' ; } var problems = [ ] ; for ( var k in actionDict ) { var v = actionDict [ k ] ; if ( ! isSpecialAction ( k ) && ! ( k in this . rules ) ) { problems . push ( "'" + k + "' is not a valid semantic action for '" + this . name + "'" ) ; } else if ( typeof v !== 'function' ) { problems . push ( "'" + k + "' must be a function in an action dictionary for '" + this . name + "'" ) ; } else { var actual = v . length ; var expected = this . _topDownActionArity ( k ) ; if ( actual !== expected ) { problems . push ( "Semantic action '" + k + "' has the wrong arity: " + 'expected ' + expected + ', got ' + actual ) ; } } } if ( problems . length > 0 ) { var prettyProblems = problems . map ( function ( problem ) { return '- ' + problem ; } ) ; var error = new Error ( "Found errors in the action dictionary of the '" + name + "' " + what + ':\n' + prettyProblems . join ( '\n' ) ) ; error . problems = problems ; throw error ; } }
Check that every key in `actionDict` corresponds to a semantic action, and that it maps to a function of the correct arity. If not, throw an exception.
Check that every key in actionDict corresponds to a semantic action and that it maps to a function of the correct arity . If not throw an exception .