'use strict';

var acorn = require('acorn');
var astTypes = require('@pregenerator/ast-types');

function _interopNamespace(e) {
  if (e && e.__esModule) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () {
            return e[k];
          }
        });
      }
    });
  }
  n['default'] = e;
  return Object.freeze(n);
}

var acorn__namespace = /*#__PURE__*/_interopNamespace(acorn);

var cov_b967qkmb7 = function () {
  var path = "/Users/fdintino/src/js/pregenerator-wip/packages/parser/src/attach-comments.ts";
  var hash = "b7b4bfaa84a0d731b3869961daac57af83380803";
  var global = new Function("return this")();
  var gcv = "__coverage__";
  var coverageData = {
    path: "/Users/fdintino/src/js/pregenerator-wip/packages/parser/src/attach-comments.ts",
    statementMap: {
      "0": {
        start: {
          line: 3,
          column: 40
        },
        end: {
          line: 3,
          column: 47
        }
      },
      "1": {
        start: {
          line: 4,
          column: 23
        },
        end: {
          line: 4,
          column: 50
        }
      },
      "2": {
        start: {
          line: 5,
          column: 4
        },
        end: {
          line: 7,
          column: 5
        }
      },
      "3": {
        start: {
          line: 6,
          column: 8
        },
        end: {
          line: 6,
          column: 37
        }
      },
      "4": {
        start: {
          line: 8,
          column: 4
        },
        end: {
          line: 10,
          column: 5
        }
      },
      "5": {
        start: {
          line: 9,
          column: 8
        },
        end: {
          line: 9,
          column: 41
        }
      },
      "6": {
        start: {
          line: 11,
          column: 4
        },
        end: {
          line: 11,
          column: 22
        }
      },
      "7": {
        start: {
          line: 16,
          column: 14
        },
        end: {
          line: 16,
          column: 26
        }
      },
      "8": {
        start: {
          line: 17,
          column: 12
        },
        end: {
          line: 17,
          column: 13
        }
      },
      "9": {
        start: {
          line: 18,
          column: 4
        },
        end: {
          line: 28,
          column: 5
        }
      },
      "10": {
        start: {
          line: 19,
          column: 8
        },
        end: {
          line: 19,
          column: 25
        }
      },
      "11": {
        start: {
          line: 20,
          column: 8
        },
        end: {
          line: 20,
          column: 27
        }
      },
      "12": {
        start: {
          line: 21,
          column: 8
        },
        end: {
          line: 27,
          column: 9
        }
      },
      "13": {
        start: {
          line: 22,
          column: 12
        },
        end: {
          line: 22,
          column: 23
        }
      },
      "14": {
        start: {
          line: 25,
          column: 12
        },
        end: {
          line: 25,
          column: 28
        }
      },
      "15": {
        start: {
          line: 26,
          column: 12
        },
        end: {
          line: 26,
          column: 28
        }
      },
      "16": {
        start: {
          line: 29,
          column: 4
        },
        end: {
          line: 29,
          column: 13
        }
      },
      "17": {
        start: {
          line: 33,
          column: 20
        },
        end: {
          line: 33,
          column: 28
        }
      },
      "18": {
        start: {
          line: 34,
          column: 19
        },
        end: {
          line: 34,
          column: 26
        }
      },
      "19": {
        start: {
          line: 35,
          column: 4
        },
        end: {
          line: 35,
          column: 78
        }
      },
      "20": {
        start: {
          line: 35,
          column: 43
        },
        end: {
          line: 35,
          column: 76
        }
      },
      "21": {
        start: {
          line: 36,
          column: 4
        },
        end: {
          line: 36,
          column: 65
        }
      },
      "22": {
        start: {
          line: 37,
          column: 4
        },
        end: {
          line: 39,
          column: 5
        }
      },
      "23": {
        start: {
          line: 38,
          column: 8
        },
        end: {
          line: 38,
          column: 59
        }
      },
      "24": {
        start: {
          line: 40,
          column: 4
        },
        end: {
          line: 40,
          column: 16
        }
      },
      "25": {
        start: {
          line: 41,
          column: 4
        },
        end: {
          line: 43,
          column: 5
        }
      },
      "26": {
        start: {
          line: 42,
          column: 8
        },
        end: {
          line: 42,
          column: 59
        }
      },
      "27": {
        start: {
          line: 44,
          column: 4
        },
        end: {
          line: 44,
          column: 19
        }
      },
      "28": {
        start: {
          line: 48,
          column: 21
        },
        end: {
          line: 48,
          column: 23
        }
      },
      "29": {
        start: {
          line: 49,
          column: 4
        },
        end: {
          line: 51,
          column: 5
        }
      },
      "30": {
        start: {
          line: 50,
          column: 8
        },
        end: {
          line: 50,
          column: 66
        }
      },
      "31": {
        start: {
          line: 52,
          column: 4
        },
        end: {
          line: 54,
          column: 5
        }
      },
      "32": {
        start: {
          line: 52,
          column: 17
        },
        end: {
          line: 52,
          column: 18
        }
      },
      "33": {
        start: {
          line: 52,
          column: 26
        },
        end: {
          line: 52,
          column: 49
        }
      },
      "34": {
        start: {
          line: 53,
          column: 8
        },
        end: {
          line: 53,
          column: 78
        }
      },
      "35": {
        start: {
          line: 56,
          column: 17
        },
        end: {
          line: 56,
          column: 18
        }
      },
      "36": {
        start: {
          line: 57,
          column: 4
        },
        end: {
          line: 90,
          column: 7
        }
      },
      "37": {
        start: {
          line: 59,
          column: 25
        },
        end: {
          line: 59,
          column: 34
        }
      },
      "38": {
        start: {
          line: 60,
          column: 12
        },
        end: {
          line: 62,
          column: 13
        }
      },
      "39": {
        start: {
          line: 61,
          column: 16
        },
        end: {
          line: 61,
          column: 29
        }
      },
      "40": {
        start: {
          line: 63,
          column: 12
        },
        end: {
          line: 78,
          column: 13
        }
      },
      "41": {
        start: {
          line: 64,
          column: 32
        },
        end: {
          line: 64,
          column: 48
        }
      },
      "42": {
        start: {
          line: 65,
          column: 16
        },
        end: {
          line: 67,
          column: 17
        }
      },
      "43": {
        start: {
          line: 66,
          column: 20
        },
        end: {
          line: 66,
          column: 26
        }
      },
      "44": {
        start: {
          line: 68,
          column: 16
        },
        end: {
          line: 77,
          column: 17
        }
      },
      "45": {
        start: {
          line: 69,
          column: 20
        },
        end: {
          line: 71,
          column: 21
        }
      },
      "46": {
        start: {
          line: 70,
          column: 24
        },
        end: {
          line: 70,
          column: 50
        }
      },
      "47": {
        start: {
          line: 72,
          column: 20
        },
        end: {
          line: 72,
          column: 55
        }
      },
      "48": {
        start: {
          line: 73,
          column: 20
        },
        end: {
          line: 73,
          column: 47
        }
      },
      "49": {
        start: {
          line: 76,
          column: 20
        },
        end: {
          line: 76,
          column: 32
        }
      },
      "50": {
        start: {
          line: 80,
          column: 12
        },
        end: {
          line: 88,
          column: 13
        }
      },
      "51": {
        start: {
          line: 81,
          column: 16
        },
        end: {
          line: 81,
          column: 29
        }
      },
      "52": {
        start: {
          line: 83,
          column: 17
        },
        end: {
          line: 88,
          column: 13
        }
      },
      "53": {
        start: {
          line: 84,
          column: 16
        },
        end: {
          line: 84,
          column: 29
        }
      },
      "54": {
        start: {
          line: 87,
          column: 16
        },
        end: {
          line: 87,
          column: 36
        }
      },
      "55": {
        start: {
          line: 91,
          column: 4
        },
        end: {
          line: 91,
          column: 15
        }
      },
      "56": {
        start: {
          line: 92,
          column: 4
        },
        end: {
          line: 125,
          column: 7
        }
      },
      "57": {
        start: {
          line: 94,
          column: 12
        },
        end: {
          line: 94,
          column: 32
        }
      },
      "58": {
        start: {
          line: 95,
          column: 25
        },
        end: {
          line: 95,
          column: 34
        }
      },
      "59": {
        start: {
          line: 96,
          column: 12
        },
        end: {
          line: 113,
          column: 13
        }
      },
      "60": {
        start: {
          line: 97,
          column: 32
        },
        end: {
          line: 97,
          column: 48
        }
      },
      "61": {
        start: {
          line: 98,
          column: 16
        },
        end: {
          line: 100,
          column: 17
        }
      },
      "62": {
        start: {
          line: 99,
          column: 20
        },
        end: {
          line: 99,
          column: 26
        }
      },
      "63": {
        start: {
          line: 101,
          column: 16
        },
        end: {
          line: 112,
          column: 17
        }
      },
      "64": {
        start: {
          line: 104,
          column: 20
        },
        end: {
          line: 106,
          column: 21
        }
      },
      "65": {
        start: {
          line: 105,
          column: 24
        },
        end: {
          line: 105,
          column: 51
        }
      },
      "66": {
        start: {
          line: 107,
          column: 20
        },
        end: {
          line: 107,
          column: 56
        }
      },
      "67": {
        start: {
          line: 108,
          column: 20
        },
        end: {
          line: 108,
          column: 47
        }
      },
      "68": {
        start: {
          line: 111,
          column: 20
        },
        end: {
          line: 111,
          column: 32
        }
      },
      "69": {
        start: {
          line: 115,
          column: 12
        },
        end: {
          line: 123,
          column: 13
        }
      },
      "70": {
        start: {
          line: 116,
          column: 16
        },
        end: {
          line: 116,
          column: 29
        }
      },
      "71": {
        start: {
          line: 118,
          column: 17
        },
        end: {
          line: 123,
          column: 13
        }
      },
      "72": {
        start: {
          line: 119,
          column: 16
        },
        end: {
          line: 119,
          column: 29
        }
      },
      "73": {
        start: {
          line: 122,
          column: 16
        },
        end: {
          line: 122,
          column: 36
        }
      },
      "74": {
        start: {
          line: 126,
          column: 4
        },
        end: {
          line: 126,
          column: 16
        }
      }
    },
    fnMap: {
      "0": {
        name: "clone",
        decl: {
          start: {
            line: 2,
            column: 9
          },
          end: {
            line: 2,
            column: 14
          }
        },
        loc: {
          start: {
            line: 2,
            column: 24
          },
          end: {
            line: 12,
            column: 1
          }
        },
        line: 2
      },
      "1": {
        name: "upperBound",
        decl: {
          start: {
            line: 13,
            column: 9
          },
          end: {
            line: 13,
            column: 19
          }
        },
        loc: {
          start: {
            line: 13,
            column: 33
          },
          end: {
            line: 30,
            column: 1
          }
        },
        line: 13
      },
      "2": {
        name: "extendCommentRange",
        decl: {
          start: {
            line: 31,
            column: 9
          },
          end: {
            line: 31,
            column: 27
          }
        },
        loc: {
          start: {
            line: 31,
            column: 47
          },
          end: {
            line: 45,
            column: 1
          }
        },
        line: 31
      },
      "3": {
        name: "(anonymous_3)",
        decl: {
          start: {
            line: 35,
            column: 32
          },
          end: {
            line: 35,
            column: 33
          }
        },
        loc: {
          start: {
            line: 35,
            column: 43
          },
          end: {
            line: 35,
            column: 76
          }
        },
        line: 35
      },
      "4": {
        name: "attachComments",
        decl: {
          start: {
            line: 46,
            column: 24
          },
          end: {
            line: 46,
            column: 38
          }
        },
        loc: {
          start: {
            line: 46,
            column: 71
          },
          end: {
            line: 127,
            column: 1
          }
        },
        line: 46
      },
      "5": {
        name: "(anonymous_5)",
        decl: {
          start: {
            line: 58,
            column: 8
          },
          end: {
            line: 58,
            column: 9
          }
        },
        loc: {
          start: {
            line: 58,
            column: 24
          },
          end: {
            line: 89,
            column: 9
          }
        },
        line: 58
      },
      "6": {
        name: "(anonymous_6)",
        decl: {
          start: {
            line: 93,
            column: 8
          },
          end: {
            line: 93,
            column: 9
          }
        },
        loc: {
          start: {
            line: 93,
            column: 24
          },
          end: {
            line: 124,
            column: 9
          }
        },
        line: 93
      }
    },
    branchMap: {
      "0": {
        loc: {
          start: {
            line: 5,
            column: 4
          },
          end: {
            line: 7,
            column: 5
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 5,
            column: 4
          },
          end: {
            line: 7,
            column: 5
          }
        }, {
          start: {
            line: 5,
            column: 4
          },
          end: {
            line: 7,
            column: 5
          }
        }],
        line: 5
      },
      "1": {
        loc: {
          start: {
            line: 8,
            column: 4
          },
          end: {
            line: 10,
            column: 5
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 8,
            column: 4
          },
          end: {
            line: 10,
            column: 5
          }
        }, {
          start: {
            line: 8,
            column: 4
          },
          end: {
            line: 10,
            column: 5
          }
        }],
        line: 8
      },
      "2": {
        loc: {
          start: {
            line: 21,
            column: 8
          },
          end: {
            line: 27,
            column: 9
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 21,
            column: 8
          },
          end: {
            line: 27,
            column: 9
          }
        }, {
          start: {
            line: 21,
            column: 8
          },
          end: {
            line: 27,
            column: 9
          }
        }],
        line: 21
      },
      "3": {
        loc: {
          start: {
            line: 37,
            column: 4
          },
          end: {
            line: 39,
            column: 5
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 37,
            column: 4
          },
          end: {
            line: 39,
            column: 5
          }
        }, {
          start: {
            line: 37,
            column: 4
          },
          end: {
            line: 39,
            column: 5
          }
        }],
        line: 37
      },
      "4": {
        loc: {
          start: {
            line: 41,
            column: 4
          },
          end: {
            line: 43,
            column: 5
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 41,
            column: 4
          },
          end: {
            line: 43,
            column: 5
          }
        }, {
          start: {
            line: 41,
            column: 4
          },
          end: {
            line: 43,
            column: 5
          }
        }],
        line: 41
      },
      "5": {
        loc: {
          start: {
            line: 49,
            column: 4
          },
          end: {
            line: 51,
            column: 5
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 49,
            column: 4
          },
          end: {
            line: 51,
            column: 5
          }
        }, {
          start: {
            line: 49,
            column: 4
          },
          end: {
            line: 51,
            column: 5
          }
        }],
        line: 49
      },
      "6": {
        loc: {
          start: {
            line: 60,
            column: 12
          },
          end: {
            line: 62,
            column: 13
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 60,
            column: 12
          },
          end: {
            line: 62,
            column: 13
          }
        }, {
          start: {
            line: 60,
            column: 12
          },
          end: {
            line: 62,
            column: 13
          }
        }],
        line: 60
      },
      "7": {
        loc: {
          start: {
            line: 65,
            column: 16
          },
          end: {
            line: 67,
            column: 17
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 65,
            column: 16
          },
          end: {
            line: 67,
            column: 17
          }
        }, {
          start: {
            line: 65,
            column: 16
          },
          end: {
            line: 67,
            column: 17
          }
        }],
        line: 65
      },
      "8": {
        loc: {
          start: {
            line: 68,
            column: 16
          },
          end: {
            line: 77,
            column: 17
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 68,
            column: 16
          },
          end: {
            line: 77,
            column: 17
          }
        }, {
          start: {
            line: 68,
            column: 16
          },
          end: {
            line: 77,
            column: 17
          }
        }],
        line: 68
      },
      "9": {
        loc: {
          start: {
            line: 69,
            column: 20
          },
          end: {
            line: 71,
            column: 21
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 69,
            column: 20
          },
          end: {
            line: 71,
            column: 21
          }
        }, {
          start: {
            line: 69,
            column: 20
          },
          end: {
            line: 71,
            column: 21
          }
        }],
        line: 69
      },
      "10": {
        loc: {
          start: {
            line: 80,
            column: 12
          },
          end: {
            line: 88,
            column: 13
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 80,
            column: 12
          },
          end: {
            line: 88,
            column: 13
          }
        }, {
          start: {
            line: 80,
            column: 12
          },
          end: {
            line: 88,
            column: 13
          }
        }],
        line: 80
      },
      "11": {
        loc: {
          start: {
            line: 83,
            column: 17
          },
          end: {
            line: 88,
            column: 13
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 83,
            column: 17
          },
          end: {
            line: 88,
            column: 13
          }
        }, {
          start: {
            line: 83,
            column: 17
          },
          end: {
            line: 88,
            column: 13
          }
        }],
        line: 83
      },
      "12": {
        loc: {
          start: {
            line: 98,
            column: 16
          },
          end: {
            line: 100,
            column: 17
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 98,
            column: 16
          },
          end: {
            line: 100,
            column: 17
          }
        }, {
          start: {
            line: 98,
            column: 16
          },
          end: {
            line: 100,
            column: 17
          }
        }],
        line: 98
      },
      "13": {
        loc: {
          start: {
            line: 101,
            column: 16
          },
          end: {
            line: 112,
            column: 17
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 101,
            column: 16
          },
          end: {
            line: 112,
            column: 17
          }
        }, {
          start: {
            line: 101,
            column: 16
          },
          end: {
            line: 112,
            column: 17
          }
        }],
        line: 101
      },
      "14": {
        loc: {
          start: {
            line: 101,
            column: 20
          },
          end: {
            line: 103,
            column: 71
          }
        },
        type: "binary-expr",
        locations: [{
          start: {
            line: 101,
            column: 20
          },
          end: {
            line: 101,
            column: 62
          }
        }, {
          start: {
            line: 102,
            column: 21
          },
          end: {
            line: 102,
            column: 67
          }
        }, {
          start: {
            line: 103,
            column: 24
          },
          end: {
            line: 103,
            column: 70
          }
        }],
        line: 101
      },
      "15": {
        loc: {
          start: {
            line: 104,
            column: 20
          },
          end: {
            line: 106,
            column: 21
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 104,
            column: 20
          },
          end: {
            line: 106,
            column: 21
          }
        }, {
          start: {
            line: 104,
            column: 20
          },
          end: {
            line: 106,
            column: 21
          }
        }],
        line: 104
      },
      "16": {
        loc: {
          start: {
            line: 115,
            column: 12
          },
          end: {
            line: 123,
            column: 13
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 115,
            column: 12
          },
          end: {
            line: 123,
            column: 13
          }
        }, {
          start: {
            line: 115,
            column: 12
          },
          end: {
            line: 123,
            column: 13
          }
        }],
        line: 115
      },
      "17": {
        loc: {
          start: {
            line: 118,
            column: 17
          },
          end: {
            line: 123,
            column: 13
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 118,
            column: 17
          },
          end: {
            line: 123,
            column: 13
          }
        }, {
          start: {
            line: 118,
            column: 17
          },
          end: {
            line: 123,
            column: 13
          }
        }],
        line: 118
      }
    },
    s: {
      "0": 0,
      "1": 0,
      "2": 0,
      "3": 0,
      "4": 0,
      "5": 0,
      "6": 0,
      "7": 0,
      "8": 0,
      "9": 0,
      "10": 0,
      "11": 0,
      "12": 0,
      "13": 0,
      "14": 0,
      "15": 0,
      "16": 0,
      "17": 0,
      "18": 0,
      "19": 0,
      "20": 0,
      "21": 0,
      "22": 0,
      "23": 0,
      "24": 0,
      "25": 0,
      "26": 0,
      "27": 0,
      "28": 0,
      "29": 0,
      "30": 0,
      "31": 0,
      "32": 0,
      "33": 0,
      "34": 0,
      "35": 0,
      "36": 0,
      "37": 0,
      "38": 0,
      "39": 0,
      "40": 0,
      "41": 0,
      "42": 0,
      "43": 0,
      "44": 0,
      "45": 0,
      "46": 0,
      "47": 0,
      "48": 0,
      "49": 0,
      "50": 0,
      "51": 0,
      "52": 0,
      "53": 0,
      "54": 0,
      "55": 0,
      "56": 0,
      "57": 0,
      "58": 0,
      "59": 0,
      "60": 0,
      "61": 0,
      "62": 0,
      "63": 0,
      "64": 0,
      "65": 0,
      "66": 0,
      "67": 0,
      "68": 0,
      "69": 0,
      "70": 0,
      "71": 0,
      "72": 0,
      "73": 0,
      "74": 0
    },
    f: {
      "0": 0,
      "1": 0,
      "2": 0,
      "3": 0,
      "4": 0,
      "5": 0,
      "6": 0
    },
    b: {
      "0": [0, 0],
      "1": [0, 0],
      "2": [0, 0],
      "3": [0, 0],
      "4": [0, 0],
      "5": [0, 0],
      "6": [0, 0],
      "7": [0, 0],
      "8": [0, 0],
      "9": [0, 0],
      "10": [0, 0],
      "11": [0, 0],
      "12": [0, 0],
      "13": [0, 0],
      "14": [0, 0, 0],
      "15": [0, 0],
      "16": [0, 0],
      "17": [0, 0]
    },
    _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184",
    hash: "b7b4bfaa84a0d731b3869961daac57af83380803"
  };
  var coverage = global[gcv] || (global[gcv] = {});

  if (coverage[path] && coverage[path].hash === hash) {
    return coverage[path];
  }

  return coverage[path] = coverageData;
}();

function clone(comment) {
  cov_b967qkmb7.f[0]++;
  const {
    type,
    value,
    start,
    end
  } = (cov_b967qkmb7.s[0]++, comment);
  const newComment = (cov_b967qkmb7.s[1]++, {
    type,
    value,
    start,
    end
  });
  cov_b967qkmb7.s[2]++;

  if (comment.loc) {
    cov_b967qkmb7.b[0][0]++;
    cov_b967qkmb7.s[3]++;
    newComment.loc = comment.loc;
  } else {
    cov_b967qkmb7.b[0][1]++;
  }

  cov_b967qkmb7.s[4]++;

  if (comment.range) {
    cov_b967qkmb7.b[1][0]++;
    cov_b967qkmb7.s[5]++;
    newComment.range = comment.range;
  } else {
    cov_b967qkmb7.b[1][1]++;
  }

  cov_b967qkmb7.s[6]++;
  return newComment;
}

function upperBound(array, func) {
  cov_b967qkmb7.f[1]++;
  let diff;
  let current;
  let len = (cov_b967qkmb7.s[7]++, array.length);
  let i = (cov_b967qkmb7.s[8]++, 0);
  cov_b967qkmb7.s[9]++;

  while (len) {
    cov_b967qkmb7.s[10]++;
    diff = len >>> 1;
    cov_b967qkmb7.s[11]++;
    current = i + diff;
    cov_b967qkmb7.s[12]++;

    if (func(array[current])) {
      cov_b967qkmb7.b[2][0]++;
      cov_b967qkmb7.s[13]++;
      len = diff;
    } else {
      cov_b967qkmb7.b[2][1]++;
      cov_b967qkmb7.s[14]++;
      i = current + 1;
      cov_b967qkmb7.s[15]++;
      len -= diff + 1;
    }
  }

  cov_b967qkmb7.s[16]++;
  return i;
}

function extendCommentRange(_comment, _tokens) {
  cov_b967qkmb7.f[2]++;
  let target;
  const comment = (cov_b967qkmb7.s[17]++, _comment);
  const tokens = (cov_b967qkmb7.s[18]++, _tokens);
  cov_b967qkmb7.s[19]++;
  target = upperBound(tokens, token => {
    cov_b967qkmb7.f[3]++;
    cov_b967qkmb7.s[20]++;
    return token.range[0] > comment.range[0];
  });
  cov_b967qkmb7.s[21]++;
  comment.extendedRange = [comment.range[0], comment.range[1]];
  cov_b967qkmb7.s[22]++;

  if (target !== tokens.length) {
    cov_b967qkmb7.b[3][0]++;
    cov_b967qkmb7.s[23]++;
    comment.extendedRange[1] = tokens[target].range[0];
  } else {
    cov_b967qkmb7.b[3][1]++;
  }

  cov_b967qkmb7.s[24]++;
  target -= 1;
  cov_b967qkmb7.s[25]++;

  if (target >= 0) {
    cov_b967qkmb7.b[4][0]++;
    cov_b967qkmb7.s[26]++;
    comment.extendedRange[0] = tokens[target].range[1];
  } else {
    cov_b967qkmb7.b[4][1]++;
  }

  cov_b967qkmb7.s[27]++;
  return comment;
}

function attachComments(tree, providedComments, tokens) {
  cov_b967qkmb7.f[4]++;
  // At first, we should calculate extended comment ranges.
  const comments = (cov_b967qkmb7.s[28]++, []);
  cov_b967qkmb7.s[29]++;

  if (!tree.range) {
    cov_b967qkmb7.b[5][0]++;
    cov_b967qkmb7.s[30]++;
    throw new Error("attachComments needs range information");
  } else {
    cov_b967qkmb7.b[5][1]++;
  }

  cov_b967qkmb7.s[31]++;

  for (let i = (cov_b967qkmb7.s[32]++, 0), len = (cov_b967qkmb7.s[33]++, providedComments.length); i < len; i += 1) {
    cov_b967qkmb7.s[34]++;
    comments.push(extendCommentRange(clone(providedComments[i]), tokens));
  } // This is based on John Freeman's implementation.


  let cursor = (cov_b967qkmb7.s[35]++, 0);
  cov_b967qkmb7.s[36]++;
  astTypes.visit(tree, {
    visitNode(path) {
      cov_b967qkmb7.f[5]++;
      const node = (cov_b967qkmb7.s[37]++, path.node);
      cov_b967qkmb7.s[38]++;

      if (!node.range) {
        cov_b967qkmb7.b[6][0]++;
        cov_b967qkmb7.s[39]++;
        return false;
      } else {
        cov_b967qkmb7.b[6][1]++;
      }

      cov_b967qkmb7.s[40]++;

      while (cursor < comments.length) {
        const comment = (cov_b967qkmb7.s[41]++, comments[cursor]);
        cov_b967qkmb7.s[42]++;

        if (comment.extendedRange[1] > node.range[0]) {
          cov_b967qkmb7.b[7][0]++;
          cov_b967qkmb7.s[43]++;
          break;
        } else {
          cov_b967qkmb7.b[7][1]++;
        }

        cov_b967qkmb7.s[44]++;

        if (comment.extendedRange[1] === node.range[0]) {
          cov_b967qkmb7.b[8][0]++;
          cov_b967qkmb7.s[45]++;

          if (!node.leadingComments) {
            cov_b967qkmb7.b[9][0]++;
            cov_b967qkmb7.s[46]++;
            node.leadingComments = [];
          } else {
            cov_b967qkmb7.b[9][1]++;
          }

          cov_b967qkmb7.s[47]++;
          node.leadingComments.push(comment);
          cov_b967qkmb7.s[48]++;
          comments.splice(cursor, 1);
        } else {
          cov_b967qkmb7.b[8][1]++;
          cov_b967qkmb7.s[49]++;
          cursor += 1;
        }
      } // already out of owned node


      cov_b967qkmb7.s[50]++;

      if (cursor === comments.length) {
        cov_b967qkmb7.b[10][0]++;
        cov_b967qkmb7.s[51]++;
        return false;
      } else {
        cov_b967qkmb7.b[10][1]++;
        cov_b967qkmb7.s[52]++;

        if (comments[cursor].extendedRange[0] > node.range[1]) {
          cov_b967qkmb7.b[11][0]++;
          cov_b967qkmb7.s[53]++;
          return false;
        } else {
          cov_b967qkmb7.b[11][1]++;
          cov_b967qkmb7.s[54]++;
          this.traverse(path);
        }
      }
    }

  });
  cov_b967qkmb7.s[55]++;
  cursor = 0;
  cov_b967qkmb7.s[56]++;
  astTypes.visit(tree, {
    visitNode(path) {
      cov_b967qkmb7.f[6]++;
      cov_b967qkmb7.s[57]++;
      this.traverse(path);
      const node = (cov_b967qkmb7.s[58]++, path.node);
      cov_b967qkmb7.s[59]++;

      while (cursor < comments.length) {
        const comment = (cov_b967qkmb7.s[60]++, comments[cursor]);
        cov_b967qkmb7.s[61]++;

        if (node.range[1] < comment.extendedRange[0]) {
          cov_b967qkmb7.b[12][0]++;
          cov_b967qkmb7.s[62]++;
          break;
        } else {
          cov_b967qkmb7.b[12][1]++;
        }

        cov_b967qkmb7.s[63]++;

        if ((cov_b967qkmb7.b[14][0]++, node.range[1] === comment.extendedRange[0]) || (cov_b967qkmb7.b[14][1]++, node.range[0] === comment.extendedRange[0] - 1) && (cov_b967qkmb7.b[14][2]++, node.range[1] === comment.extendedRange[1] + 1)) {
          cov_b967qkmb7.b[13][0]++;
          cov_b967qkmb7.s[64]++;

          if (!node.trailingComments) {
            cov_b967qkmb7.b[15][0]++;
            cov_b967qkmb7.s[65]++;
            node.trailingComments = [];
          } else {
            cov_b967qkmb7.b[15][1]++;
          }

          cov_b967qkmb7.s[66]++;
          node.trailingComments.push(comment);
          cov_b967qkmb7.s[67]++;
          comments.splice(cursor, 1);
        } else {
          cov_b967qkmb7.b[13][1]++;
          cov_b967qkmb7.s[68]++;
          cursor += 1;
        }
      } // already out of owned node


      cov_b967qkmb7.s[69]++;

      if (cursor === comments.length) {
        cov_b967qkmb7.b[16][0]++;
        cov_b967qkmb7.s[70]++;
        this.abort();
      } else {
        cov_b967qkmb7.b[16][1]++;
        cov_b967qkmb7.s[71]++;

        if (comments[cursor].extendedRange[0] > node.range[1]) {
          cov_b967qkmb7.b[17][0]++;
          cov_b967qkmb7.s[72]++;
          return false;
        } else {
          cov_b967qkmb7.b[17][1]++;
          cov_b967qkmb7.s[73]++;
          this.traverse(path);
        }
      }
    }

  });
  cov_b967qkmb7.s[74]++;
  return tree;
}

var cov_yxnt8zh08 = function () {
  var path = "/Users/fdintino/src/js/pregenerator-wip/packages/parser/src/index.ts";
  var hash = "05d590a99618da5d5f36b7e5ca381a320c48b05e";
  var global = new Function("return this")();
  var gcv = "__coverage__";
  var coverageData = {
    path: "/Users/fdintino/src/js/pregenerator-wip/packages/parser/src/index.ts",
    statementMap: {
      "0": {
        start: {
          line: 5,
          column: 21
        },
        end: {
          line: 5,
          column: 23
        }
      },
      "1": {
        start: {
          line: 6,
          column: 19
        },
        end: {
          line: 6,
          column: 21
        }
      },
      "2": {
        start: {
          line: 7,
          column: 37
        },
        end: {
          line: 7,
          column: 48
        }
      },
      "3": {
        start: {
          line: 8,
          column: 17
        },
        end: {
          line: 14,
          column: 6
        }
      },
      "4": {
        start: {
          line: 15,
          column: 19
        },
        end: {
          line: 15,
          column: 58
        }
      },
      "5": {
        start: {
          line: 16,
          column: 20
        },
        end: {
          line: 16,
          column: 34
        }
      },
      "6": {
        start: {
          line: 17,
          column: 16
        },
        end: {
          line: 24,
          column: 5
        }
      },
      "7": {
        start: {
          line: 25,
          column: 4
        },
        end: {
          line: 25,
          column: 42
        }
      },
      "8": {
        start: {
          line: 26,
          column: 4
        },
        end: {
          line: 71,
          column: 7
        }
      },
      "9": {
        start: {
          line: 28,
          column: 29
        },
        end: {
          line: 28,
          column: 33
        }
      },
      "10": {
        start: {
          line: 29,
          column: 26
        },
        end: {
          line: 29,
          column: 30
        }
      },
      "11": {
        start: {
          line: 30,
          column: 12
        },
        end: {
          line: 48,
          column: 13
        }
      },
      "12": {
        start: {
          line: 31,
          column: 16
        },
        end: {
          line: 47,
          column: 17
        }
      },
      "13": {
        start: {
          line: 32,
          column: 20
        },
        end: {
          line: 32,
          column: 50
        }
      },
      "14": {
        start: {
          line: 33,
          column: 20
        },
        end: {
          line: 33,
          column: 44
        }
      },
      "15": {
        start: {
          line: 34,
          column: 20
        },
        end: {
          line: 34,
          column: 38
        }
      },
      "16": {
        start: {
          line: 38,
          column: 34
        },
        end: {
          line: 38,
          column: 45
        }
      },
      "17": {
        start: {
          line: 39,
          column: 20
        },
        end: {
          line: 39,
          column: 39
        }
      },
      "18": {
        start: {
          line: 40,
          column: 20
        },
        end: {
          line: 46,
          column: 23
        }
      },
      "19": {
        start: {
          line: 49,
          column: 12
        },
        end: {
          line: 68,
          column: 13
        }
      },
      "20": {
        start: {
          line: 50,
          column: 16
        },
        end: {
          line: 67,
          column: 17
        }
      },
      "21": {
        start: {
          line: 51,
          column: 20
        },
        end: {
          line: 51,
          column: 47
        }
      },
      "22": {
        start: {
          line: 53,
          column: 21
        },
        end: {
          line: 67,
          column: 17
        }
      },
      "23": {
        start: {
          line: 54,
          column: 20
        },
        end: {
          line: 54,
          column: 50
        }
      },
      "24": {
        start: {
          line: 56,
          column: 21
        },
        end: {
          line: 67,
          column: 17
        }
      },
      "25": {
        start: {
          line: 57,
          column: 20
        },
        end: {
          line: 57,
          column: 49
        }
      },
      "26": {
        start: {
          line: 59,
          column: 21
        },
        end: {
          line: 67,
          column: 17
        }
      },
      "27": {
        start: {
          line: 60,
          column: 20
        },
        end: {
          line: 60,
          column: 50
        }
      },
      "28": {
        start: {
          line: 62,
          column: 21
        },
        end: {
          line: 67,
          column: 17
        }
      },
      "29": {
        start: {
          line: 63,
          column: 20
        },
        end: {
          line: 63,
          column: 49
        }
      },
      "30": {
        start: {
          line: 64,
          column: 20
        },
        end: {
          line: 64,
          column: 56
        }
      },
      "31": {
        start: {
          line: 65,
          column: 20
        },
        end: {
          line: 65,
          column: 52
        }
      },
      "32": {
        start: {
          line: 66,
          column: 20
        },
        end: {
          line: 66,
          column: 39
        }
      },
      "33": {
        start: {
          line: 69,
          column: 12
        },
        end: {
          line: 69,
          column: 32
        }
      },
      "34": {
        start: {
          line: 72,
          column: 4
        },
        end: {
          line: 72,
          column: 15
        }
      }
    },
    fnMap: {
      "0": {
        name: "parse",
        decl: {
          start: {
            line: 4,
            column: 24
          },
          end: {
            line: 4,
            column: 29
          }
        },
        loc: {
          start: {
            line: 4,
            column: 42
          },
          end: {
            line: 73,
            column: 1
          }
        },
        line: 4
      },
      "1": {
        name: "(anonymous_1)",
        decl: {
          start: {
            line: 27,
            column: 8
          },
          end: {
            line: 27,
            column: 9
          }
        },
        loc: {
          start: {
            line: 27,
            column: 24
          },
          end: {
            line: 70,
            column: 9
          }
        },
        line: 27
      }
    },
    branchMap: {
      "0": {
        loc: {
          start: {
            line: 7,
            column: 37
          },
          end: {
            line: 7,
            column: 48
          }
        },
        type: "binary-expr",
        locations: [{
          start: {
            line: 7,
            column: 37
          },
          end: {
            line: 7,
            column: 42
          }
        }, {
          start: {
            line: 7,
            column: 46
          },
          end: {
            line: 7,
            column: 48
          }
        }],
        line: 7
      },
      "1": {
        loc: {
          start: {
            line: 8,
            column: 35
          },
          end: {
            line: 8,
            column: 50
          }
        },
        type: "binary-expr",
        locations: [{
          start: {
            line: 8,
            column: 35
          },
          end: {
            line: 8,
            column: 44
          }
        }, {
          start: {
            line: 8,
            column: 48
          },
          end: {
            line: 8,
            column: 50
          }
        }],
        line: 8
      },
      "2": {
        loc: {
          start: {
            line: 15,
            column: 24
          },
          end: {
            line: 15,
            column: 46
          }
        },
        type: "binary-expr",
        locations: [{
          start: {
            line: 15,
            column: 24
          },
          end: {
            line: 15,
            column: 30
          }
        }, {
          start: {
            line: 15,
            column: 34
          },
          end: {
            line: 15,
            column: 46
          }
        }],
        line: 15
      },
      "3": {
        loc: {
          start: {
            line: 23,
            column: 13
          },
          end: {
            line: 23,
            column: 37
          }
        },
        type: "binary-expr",
        locations: [{
          start: {
            line: 23,
            column: 13
          },
          end: {
            line: 23,
            column: 24
          }
        }, {
          start: {
            line: 23,
            column: 28
          },
          end: {
            line: 23,
            column: 37
          }
        }],
        line: 23
      },
      "4": {
        loc: {
          start: {
            line: 30,
            column: 12
          },
          end: {
            line: 48,
            column: 13
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 30,
            column: 12
          },
          end: {
            line: 48,
            column: 13
          }
        }, {
          start: {
            line: 30,
            column: 12
          },
          end: {
            line: 48,
            column: 13
          }
        }],
        line: 30
      },
      "5": {
        loc: {
          start: {
            line: 31,
            column: 16
          },
          end: {
            line: 47,
            column: 17
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 31,
            column: 16
          },
          end: {
            line: 47,
            column: 17
          }
        }, {
          start: {
            line: 31,
            column: 16
          },
          end: {
            line: 47,
            column: 17
          }
        }],
        line: 31
      },
      "6": {
        loc: {
          start: {
            line: 49,
            column: 12
          },
          end: {
            line: 68,
            column: 13
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 49,
            column: 12
          },
          end: {
            line: 68,
            column: 13
          }
        }, {
          start: {
            line: 49,
            column: 12
          },
          end: {
            line: 68,
            column: 13
          }
        }],
        line: 49
      },
      "7": {
        loc: {
          start: {
            line: 49,
            column: 16
          },
          end: {
            line: 49,
            column: 59
          }
        },
        type: "binary-expr",
        locations: [{
          start: {
            line: 49,
            column: 16
          },
          end: {
            line: 49,
            column: 40
          }
        }, {
          start: {
            line: 49,
            column: 44
          },
          end: {
            line: 49,
            column: 59
          }
        }],
        line: 49
      },
      "8": {
        loc: {
          start: {
            line: 50,
            column: 16
          },
          end: {
            line: 67,
            column: 17
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 50,
            column: 16
          },
          end: {
            line: 67,
            column: 17
          }
        }, {
          start: {
            line: 50,
            column: 16
          },
          end: {
            line: 67,
            column: 17
          }
        }],
        line: 50
      },
      "9": {
        loc: {
          start: {
            line: 53,
            column: 21
          },
          end: {
            line: 67,
            column: 17
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 53,
            column: 21
          },
          end: {
            line: 67,
            column: 17
          }
        }, {
          start: {
            line: 53,
            column: 21
          },
          end: {
            line: 67,
            column: 17
          }
        }],
        line: 53
      },
      "10": {
        loc: {
          start: {
            line: 56,
            column: 21
          },
          end: {
            line: 67,
            column: 17
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 56,
            column: 21
          },
          end: {
            line: 67,
            column: 17
          }
        }, {
          start: {
            line: 56,
            column: 21
          },
          end: {
            line: 67,
            column: 17
          }
        }],
        line: 56
      },
      "11": {
        loc: {
          start: {
            line: 59,
            column: 21
          },
          end: {
            line: 67,
            column: 17
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 59,
            column: 21
          },
          end: {
            line: 67,
            column: 17
          }
        }, {
          start: {
            line: 59,
            column: 21
          },
          end: {
            line: 67,
            column: 17
          }
        }],
        line: 59
      },
      "12": {
        loc: {
          start: {
            line: 62,
            column: 21
          },
          end: {
            line: 67,
            column: 17
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 62,
            column: 21
          },
          end: {
            line: 67,
            column: 17
          }
        }, {
          start: {
            line: 62,
            column: 21
          },
          end: {
            line: 67,
            column: 17
          }
        }],
        line: 62
      }
    },
    s: {
      "0": 0,
      "1": 0,
      "2": 0,
      "3": 0,
      "4": 0,
      "5": 0,
      "6": 0,
      "7": 0,
      "8": 0,
      "9": 0,
      "10": 0,
      "11": 0,
      "12": 0,
      "13": 0,
      "14": 0,
      "15": 0,
      "16": 0,
      "17": 0,
      "18": 0,
      "19": 0,
      "20": 0,
      "21": 0,
      "22": 0,
      "23": 0,
      "24": 0,
      "25": 0,
      "26": 0,
      "27": 0,
      "28": 0,
      "29": 0,
      "30": 0,
      "31": 0,
      "32": 0,
      "33": 0,
      "34": 0
    },
    f: {
      "0": 0,
      "1": 0
    },
    b: {
      "0": [0, 0],
      "1": [0, 0],
      "2": [0, 0],
      "3": [0, 0],
      "4": [0, 0],
      "5": [0, 0],
      "6": [0, 0],
      "7": [0, 0],
      "8": [0, 0],
      "9": [0, 0],
      "10": [0, 0],
      "11": [0, 0],
      "12": [0, 0]
    },
    _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184",
    hash: "05d590a99618da5d5f36b7e5ca381a320c48b05e"
  };
  var coverage = global[gcv] || (global[gcv] = {});

  if (coverage[path] && coverage[path].hash === hash) {
    return coverage[path];
  }

  return coverage[path] = coverageData;
}();
function parse(src, _opts) {
  cov_yxnt8zh08.f[0]++;
  const comments = (cov_yxnt8zh08.s[0]++, []);
  const tokens = (cov_yxnt8zh08.s[1]++, []);
  const {
    Parser,
    ...acornOpts
  } = (cov_yxnt8zh08.s[2]++, (cov_yxnt8zh08.b[0][0]++, _opts) || (cov_yxnt8zh08.b[0][1]++, {}));
  const opts = (cov_yxnt8zh08.s[3]++, Object.assign({}, (cov_yxnt8zh08.b[1][0]++, acornOpts) || (cov_yxnt8zh08.b[1][1]++, {}), {
    onComment: comments,
    onToken: tokens,
    locations: true,
    ranges: true,
    ecmaVersion: "latest"
  }));
  const parser = (cov_yxnt8zh08.s[4]++, new ((cov_yxnt8zh08.b[2][0]++, Parser) || (cov_yxnt8zh08.b[2][1]++, acorn__namespace.Parser))(opts, src));
  const program = (cov_yxnt8zh08.s[5]++, parser.parse());
  const ast = (cov_yxnt8zh08.s[6]++, {
    type: "File",
    program: program,
    start: program.start,
    end: program.end,
    range: program.range,
    loc: (cov_yxnt8zh08.b[3][0]++, program.loc) || (cov_yxnt8zh08.b[3][1]++, undefined)
  });
  cov_yxnt8zh08.s[7]++;
  attachComments(ast, comments, tokens);
  cov_yxnt8zh08.s[8]++;
  astTypes.visit(ast, {
    visitNode(path) {
      cov_yxnt8zh08.f[1]++;
      const {
        node
      } = (cov_yxnt8zh08.s[9]++, path);

      const _node = (cov_yxnt8zh08.s[10]++, node);

      cov_yxnt8zh08.s[11]++;

      if (astTypes.namedTypes.Property.check(node)) {
        cov_yxnt8zh08.b[4][0]++;
        cov_yxnt8zh08.s[12]++;

        if (node.kind === "init") {
          cov_yxnt8zh08.b[5][0]++;
          cov_yxnt8zh08.s[13]++;
          _node.type = "ObjectProperty";
          cov_yxnt8zh08.s[14]++;
          _node.shorthand = false;
          cov_yxnt8zh08.s[15]++;
          delete _node.kind;
        } else {
          cov_yxnt8zh08.b[5][1]++;
          // kind === 'get' or 'set'
          const value = (cov_yxnt8zh08.s[16]++, _node.value);
          cov_yxnt8zh08.s[17]++;
          delete _node.value;
          cov_yxnt8zh08.s[18]++;
          Object.assign(_node, {
            type: "ObjectMethod",
            generator: !!value.generator,
            async: !!value.async,
            body: value.body,
            params: value.params
          });
        }
      } else {
        cov_yxnt8zh08.b[4][1]++;
      }

      cov_yxnt8zh08.s[19]++;

      if ((cov_yxnt8zh08.b[7][0]++, _node.type === "Literal") && (cov_yxnt8zh08.b[7][1]++, "value" in node)) {
        cov_yxnt8zh08.b[6][0]++;
        cov_yxnt8zh08.s[20]++;

        if (node.value === null) {
          cov_yxnt8zh08.b[8][0]++;
          cov_yxnt8zh08.s[21]++;
          _node.type = "NullLiteral";
        } else {
          cov_yxnt8zh08.b[8][1]++;
          cov_yxnt8zh08.s[22]++;

          if (typeof node.value === "boolean") {
            cov_yxnt8zh08.b[9][0]++;
            cov_yxnt8zh08.s[23]++;
            _node.type = "BooleanLiteral";
          } else {
            cov_yxnt8zh08.b[9][1]++;
            cov_yxnt8zh08.s[24]++;

            if (typeof node.value === "string") {
              cov_yxnt8zh08.b[10][0]++;
              cov_yxnt8zh08.s[25]++;
              _node.type = "StringLiteral";
            } else {
              cov_yxnt8zh08.b[10][1]++;
              cov_yxnt8zh08.s[26]++;

              if (typeof node.value === "number") {
                cov_yxnt8zh08.b[11][0]++;
                cov_yxnt8zh08.s[27]++;
                _node.type = "NumericLiteral";
              } else {
                cov_yxnt8zh08.b[11][1]++;
                cov_yxnt8zh08.s[28]++;

                if (Object.prototype.toString.call(_node.value) === "[object RegExp]") {
                  cov_yxnt8zh08.b[12][0]++;
                  cov_yxnt8zh08.s[29]++;
                  _node.type = "RegExpLiteral";
                  cov_yxnt8zh08.s[30]++;
                  _node.pattern = _node.regex.pattern;
                  cov_yxnt8zh08.s[31]++;
                  _node.flags = _node.regex.flags;
                  cov_yxnt8zh08.s[32]++;
                  delete _node.regex;
                } else {
                  cov_yxnt8zh08.b[12][1]++;
                }
              }
            }
          }
        }
      } else {
        cov_yxnt8zh08.b[6][1]++;
      }

      cov_yxnt8zh08.s[33]++;
      this.traverse(path);
    }

  });
  cov_yxnt8zh08.s[34]++;
  return ast;
}

module.exports = parse;
//# sourceMappingURL=index.js.map
