code: function pegParser(options, extension, cb) {
    if (typeof cb === 'undefined') {
      cb = extension;
      extension = null;
    }
  
    var grammarFiles = [];
    if (typeof options === 'string') {
      options = {grammar: options};
    }
    var grammar = options.grammar;
    if (typeof grammar === 'object') {
      if (grammar[extension]) {
        grammar = grammar[extension];
      }
    }
    if (typeof grammar !== 'string') {
      if (extension === 'js') {
        grammar = 'javascript';
      } else if (extension === 'md') {
        grammar = 'markdown';
      }
    }
    if (grammar) {
      grammarFiles.push(grammar);
      grammarFiles.push(path.join(__dirname, '../grammar', grammar + '.pegjs'));
    } else {
      grammarFiles.push(path.join(__dirname, '../grammar/javascript.pegjs'));
    }
  
    function findGrammarFile(wrapper, cb) {
      var grammarFile = wrapper.file;
      var cachedParser = quickpeg.parserFromMemory(grammarFile);
      if (cachedParser) {
        wrapper.parser = cachedParser;
        return cb(true);
      }
  
      var fsExists = fs.exists || path.exists;
      fsExists(grammarFile, function (exists) {
        if (!exists) {
          return cb(false);
        }
  
        quickpeg(grammarFile, function (err, cachedParser) {
          if (err) {
            wrapper.err = err;
            return;
          }
          wrapper.parser = cachedParser;
          return cb(true);
        });
      });
    }
    var grammarFileWrappers = grammarFiles.map(function (file) {
      return {
        parser: null,
        file: file,
        err: null
      };
    });
    async.detectSeries(grammarFileWrappers, findGrammarFile, function (wrapper) {
      if (wrapper.err || wrapper.parser) {
        return cb(wrapper.err, wrapper.parser, wrapper.file);
      }
      cb(new Error('grammar file not found'));
    });
  }
docs: /*
  Given doctor options and a file extension, retrieve an appropriate peg parser.
  @param {Object} options Doctor options.
  @param {String} extension File extension.
  @param {function} cb Function to call with peg parser.