///////////////////////////////////////////////////////////////////////// helper functions chain a parser to another parser
424255
function chain(stream, state, parser) {
        state.tokenize = parser;
        return parser(stream, state);
    }
1012885
function composeK(...args) {
  if(!arguments.length) {
    throw new TypeError(err)
  }

  const fns =
    args.slice().reverse()

  const head =
    fns[0]

  if(!isFunction(head)) {
    throw new TypeError(err)
  }

  if(fns.length === 1) {
    return head
  }

  const tail = fns.slice(1).reduce((comp, fn) => {
    if(!isFunction(fn)) {
      throw new TypeError(err)
    }

    return function(m) {
      if(!isChain(m)) {
        throw new TypeError(err)
      }
      return comp(m).chain(fn)
    }
  }, x => x)

  return function() {
    return tail(head.apply(null, arguments))
  }
}
413193
public static <A, B, T> Parser<T> sequence(
      final Parser<A> p1, final Parser<B> p2, final BiFunction<? super A, ? super B, ? extends T> map) {
    return new Parser<T>() {
      @Override boolean apply(ParseContext ctxt) {
        boolean r1 = p1.apply(ctxt);
        if (!r1) return false;
        A o1 = p1.getReturn(ctxt);
        boolean r2 = p2.apply(ctxt);
        if (!r2) return false;
        B o2 = p2.getReturn(ctxt);
        ctxt.result = map.apply(o1, o2);
        return true;
      }
      @Override public String toString() {
        return map.toString();
      }
    };
  }
541248
function main(option, parser, force) {
  if(typeof option === 'function') {
    parser = option;
    option = null;
  }
  if(option !== false) {
    option = option || parse.option;
    parser = parser || parse;
  }
  //var mode = parse.auto;
  if(typeof parser === 'function') {
    module.exports.mode = parser(parse.modes, option, process.argv.slice(2));
  }
  initialize(force);
  return module.exports;
}
86489
function(parser, expr, param){
    if( param.isConditional() ){
      // TODO: not sure what this will output
      parser.state.current.addDependency(
        new RequireHeaderDependency(expr.callee.range));
      param.options.forEach(function(param) {
        var result = parser.applyPluginsBailResult("call require:commonjs:item",
                                                 expr, param);
        if(result === undefined) {
          throw new Error(
            "Cannot convert options with mixed known and unknown stuff");
        }
      });
      return true;
    }
    if( param.isString() ){
      var dep;
      var localModule = LocalModulesHelpers.getLocalModule(parser.state, param.string);
      if( localModule ) {
        return true;
      }
      dep = new AngularModuleDependency(param.string, param.range);
      dep.loc = param.loc;
      parser.state.current.addDependency(dep);
      return true;
    }
    parser.applyPluginsBailResult("call require:commonjs:context", expr, param);
    return true;
  }
89883
function dereference (parser, options) {
  // console.log('Dereferencing $ref pointers in %s', parser.$refs._root$Ref.path);
  var dereferenced = crawl(parser.schema, parser.$refs._root$Ref.path, "#", [], parser.$refs, options);
  parser.$refs.circular = dereferenced.circular;
  parser.schema = dereferenced.value;
}
828112
function processParentheses(tokenizer, scope) {
  if (tokenizer.token.match(types.CLOSE_PARENTHESES)) {
    throw new SyntaxError('Unexpected end of expression');
  }

  if (tokenizer.token.match(types.OPEN_PARENTHESES)) {
    const node = processLogicalOr(tokenizer.skipToken(), scope);

    if (!tokenizer.token.match(types.CLOSE_PARENTHESES)) {
      throw new SyntaxError('Unexpected end of expression');
    }

    tokenizer.skipToken();
    return node;
  }

  throw new SyntaxError('Unexpected end of expression');
}
872806
public static <T> Parser<T> sequence(
      Parser<?> p1, Parser<?> p2, Parser<?> p3, Parser<?> p4, Parser<T> p5) {
    return sequence(p1, p2, p3, p4, p5,
        InternalFunctors.<Object, Object, Object, Object, T>lastOfFive());
  }
612716
function LIST(element_parser, delimiter_parser, save_delimiter) {
        if (typeof save_delimiter === "undefined") { save_delimiter = false; }
        var _func = 'LIST';
        var _parser = CONCAT(element_parser, REPEAT(CONCAT(delimiter_parser, element_parser), 0));

        return function (buffer, index, depth) {
            if (typeof depth === "undefined") { depth = 0; }
            _trace(_func, depth, true);

            var r;
            var _r = _parser(buffer, index, depth);

            if (paka.S.OK == _r.status) {
                var _children = [];

                _children.push(_r.children[0]);

                for (var i = 0; i < _r.children[1].children.length; ++i) {
                    if (save_delimiter) {
                        _children.push(_r.children[1].children[i].children[0]);
                    }
                    _children.push(_r.children[1].children[i].children[1]);
                }

                r = R.ok(paka.P.LIST, index, _r.length, _children);
            } else {
                r = R.error(paka.P.LIST, index, null, 'Failed to match LIST');
            }

            paka.S.ERROR == r.status && _update_last_error(r);
            _trace(_func, depth, false, r.status);
            return r;
        };
    }
189080
function walkNodesBreadthFirstHelper(ast, f) {
  let childAst = [];
  (ast || []).forEach(node => {
    f(node);
    childAst = childAst.concat(getChildren(node));
  });
  if (childAst.length > 0) {
    walkNodesBreadthFirstHelper(childAst, f);
  }
}
180059
function parsers(snapdragon, options) {
  var reflinks = snapdragon.reflinks = {unresolved: [], resolved: {}};
  if (options && options.reflinks) {
    reflinks.resolved = extend({}, options.reflinks);
  }

  snapdragon.parser.sets.reflink = snapdragon.parser.sets.reflink || [];
  snapdragon.parser

    /**
     * Newlins
     */

    .capture('newline', /^\n/)

    /**
     * Text parser
     */

    .capture('text', function() {
      if (this.isInside('reflink')) return;
      var pos = this.position();
      var m = this.match(not);
      if (!m || !m[0]) return;

      return pos({
        type: 'text',
        val: m[0]
      });
    })

    /**
     * Bracket (noop)
     */

    .capture('reflink', function() {})

    /**
     * Open: '['
     */

    .capture('reflink.open', function() {
      var parsed = this.parsed;
      var pos = this.position();
      var m = this.match(/^\[(?=.*\])/);
      if (!m) return;

      var prev = this.prev();
      var last = utils.last(prev.nodes);

      var open = pos({
        type: 'reflink.open',
        val: m[0]
      });

      var node = pos({
        type: 'reflink',
        label: '',
        nodes: [open]
      });

      define(node, 'parsed', parsed);
      define(node, 'parent', prev);
      define(open, 'parent', node);
      this.push('reflink', node);
      prev.nodes.push(node);
    })

    /**
     * Bracket text
     */

    .capture('reflink.inner', function() {
      if (!this.isInside('reflink')) return;
      var pos = this.position();
      var m = this.match(not);
      if (!m || !m[0]) return;

      var prev = this.prev();
      var node = pos({
        type: 'reflink.inner',
        val: m[0]
      });

      if (prev.type !== 'reflink') {
        node.type = 'text';
      }

      prev.nodes.push(node);
      define(node, 'parent', prev);
      prev.label = node.val;
    })

    /**
     * Close: ']'
     */

    .capture('reflink.close', function() {
      var parsed = this.parsed;
      var pos = this.position();
      var m = this.match(/^(\])(:?)([^\n]+)?/);
      if (!m) return;

      var prev = this.prev();
      var last = utils.last(prev.nodes);

      var node = pos({
        type: 'reflink.close',
        val: m[1] + (m[2] ? (m[2] + ' ') : '')
      });

      define(node, 'rest', this.input);

      if (last.type === 'reflink.open') {
        node.type = 'reflink.inner';
        node.escaped = true;
        return node;
      }

      var parent = this.pop('reflink');
      if (!this.isType(parent, 'reflink')) {
        if (this.options.strict) {
          throw new Error('missing opening "["');
        }
        node.type = 'reflink.inner';
        node.escaped = true;
        return node;
      }

      parent.nodes.push(node);
      define(node, 'parent', parent);

      if (m[3] && !m[2]) {
        node.val += m[3];
        return;
      }

      if (m[2] && m[3]) {
        var tok = pos({type: 'reflink.link'});
        parseLink(m[3], tok, parent);
        parent.nodes.push(tok);
        define(tok, 'parent', parent);

        var key = parent.label;
        tok.label = key;

        if (tok.resolved) {
          reflinks.resolved[key] = tok;
        } else {
          reflinks.unresolved.push(tok);
        }
      }
    });
}
572336
function chunks() {
  for (var
    update,
    out = [],
    updates = this.updates,
    template = this.chunks,
    callback = this.callback,
    all = Promise.resolve(template[0]),
    chain = function (after) {
      return all.then(function (through) {
                  notify(through);
                  return after;
                });
    },
    getSubValue = function (value) {
      if (isArray(value)) {
        value.forEach(getSubValue);
      } else {
        all = chain(
          Promise.resolve(value)
                 .then(resolveArray)
        );
      }
    },
    getValue = function (value) {
      if (isArray(value)) {
        var hc = Promise.resolve(createHyperComment());
        all = chain(hc);
        value.forEach(getSubValue);
        all = chain(hc);
      } else {
        all = chain(
          Promise.resolve(value)
                 .then(resolveAsTemplateValue(update))
                 .then(update === asTemplateValue ? identity : update)
        );
      }
    },
    notify = function (chunk) {
      out.push(chunk);
      callback(chunk);
    },
    i = 1,
    length = arguments.length; i < length; i++
  ) {
    update = updates[i - 1];
    getValue(arguments[i]);
    all = chain(template[i]);
  }
  return all.then(notify).then(function () { return out; });
}
34605
function(parser, expr) {
    var mod = parser.evaluateExpression(expr.arguments[0]);
    return this._addDependency(parser, expr, mod);
  }
1203954
function Chain() {
  this._stores = [];

  const len = arguments.length;
  for (let ii = 0; ii < len; ++ii) {
    const value = arguments[ii];
    if (value instanceof Store) {
      if (this._stores.indexOf(value) >= 0) continue;
      this._stores.push(value);
    }
  }
}
378355
def add_compare_chains_parser(subparsers, parent_parser):
    
    parser = subparsers.add_parser(
        'compare-chains',
        help='Compare chains from different nodes.',
        description=(
            'Compute and display information about how the chains at '
            'different nodes differ.'
        ),
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog='''
By default, prints a table of summary data and a table of per-node data with
the following fields. Pass --tree for a fork graph.

COMMON ANCESTOR
    The most recent block that all chains have in common.

COMMON HEIGHT
    Let min_height := the minimum height of any chain across all nodes passed
    in. COMMON HEIGHT = min_height.

HEAD
    The block id of the most recent block on a given chain.

HEIGHT
    The block number of the most recent block on a given chain.

LAG
    Let max_height := the maximum height of any chain across all nodes passed
    in. LAG = max_height - HEIGHT for a given chain.

DIVERG
    Let common_ancestor_height := the height of the COMMON ANCESTOR.
    DIVERG = HEIGHT - common_ancestor_height

''',
        parents=[parent_parser, base_multinode_parser()])

    parser.add_argument(
        '-l',
        '--limit',
        default=25,
        type=int,
        help='the number of blocks to request at a time',
    )

    parser.add_argument(
        '--table',
        action='store_true',
        help='Print out a fork table for all nodes since the common ancestor.')

    parser.add_argument(
        '--tree',
        action='store_true',
        help='Print out a fork tree for all nodes since the common ancestor.')
929659
function helper(context, helpers, helperName, args) {
  if (typeof helpers[helperName] !== 'function') {
    return '';
  }
  try {
    const out = helpers[helperName].apply(context, args);
    return out || '';
  } catch (e) {
    return '';
  }
}
1093217
function getTextBetween(node1, node2) {
            const allTokens = [node1].concat(sourceCode.getTokensBetween(node1, node2)).concat(node2);
            const sourceText = sourceCode.getText();

            return allTokens.slice(0, -1).reduce((accumulator, token, index) => accumulator + sourceText.slice(token.range[1], allTokens[index + 1].range[0]), "");
        }