1 |
- {"version":3,"sources":["source-parser.js"],"names":["Object","defineProperty","exports","value","primitives_1","require","util_1","getParser","startLine","block","num","parseSource","source","rest","tokens","seedTokens","lineEnd","splitCR","start","splitSpace","startsWith","Markers","nostart","delimiter","slice","length","postDelimiter","isClosed","trimRight","endsWith","end","delim","trimmed","description","push","number","result","default"],"mappings":"AAAA;;AACAA,MAAM,CAACC,cAAP,CAAsBC,OAAtB,EAA+B,YAA/B,EAA6C;AAAEC,EAAAA,KAAK,EAAE;AAAT,CAA7C;;AACA,MAAMC,YAAY,GAAGC,OAAH,qBAAlB;;AACA,MAAMC,MAAM,GAAGD,OAAH,eAAZ;;AACA,SAASE,SAAT,CAAmB;AAAEC,EAAAA,SAAS,GAAG;AAAd,IAAqB,EAAxC,EAA4C;AACxC,MAAIC,KAAK,GAAG,IAAZ;AACA,MAAIC,GAAG,GAAGF,SAAV;AACA,SAAO,SAASG,WAAT,CAAqBC,MAArB,EAA6B;AAChC,QAAIC,IAAI,GAAGD,MAAX;AACA,UAAME,MAAM,GAAGR,MAAM,CAACS,UAAP,EAAf;AACA,KAACD,MAAM,CAACE,OAAR,EAAiBH,IAAjB,IAAyBP,MAAM,CAACW,OAAP,CAAeJ,IAAf,CAAzB;AACA,KAACC,MAAM,CAACI,KAAR,EAAeL,IAAf,IAAuBP,MAAM,CAACa,UAAP,CAAkBN,IAAlB,CAAvB;;AACA,QAAIJ,KAAK,KAAK,IAAV,IACAI,IAAI,CAACO,UAAL,CAAgBhB,YAAY,CAACiB,OAAb,CAAqBH,KAArC,CADA,IAEA,CAACL,IAAI,CAACO,UAAL,CAAgBhB,YAAY,CAACiB,OAAb,CAAqBC,OAArC,CAFL,EAEoD;AAChDb,MAAAA,KAAK,GAAG,EAAR;AACAK,MAAAA,MAAM,CAACS,SAAP,GAAmBV,IAAI,CAACW,KAAL,CAAW,CAAX,EAAcpB,YAAY,CAACiB,OAAb,CAAqBH,KAArB,CAA2BO,MAAzC,CAAnB;AACAZ,MAAAA,IAAI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;AACH;;AACDX,IAAAA,MAAM,CAACmB,WAAP,GAAqBpB,IAArB;AACAJ,IAAAA,KAAK,CAACyB,IAAN,CAAW;AAAEC,MAAAA,MAAM,EAAEzB,GAAV;AAAeE,MAAAA,MAAf;AAAuBE,MAAAA;AAAvB,KAAX;AACAJ,IAAAA,GAAG;;AACH,QAAIiB,QAAJ,EAAc;AACV,YAAMS,MAAM,GAAG3B,KAAK,CAACe,KAAN,EAAf;AACAf,MAAAA,KAAK,GAAG,IAAR;AACA,aAAO2B,MAAP;AACH;;AACD,WAAO,IAAP;AACH,GAvCD;AAwCH;;AACDlC,OAAO,CAACmC,OAAR,GAAkB9B,SAAlB","sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst primitives_1 = require(\"../primitives\");\nconst util_1 = require(\"../util\");\nfunction getParser({ startLine = 0, } = {}) {\n let block = null;\n let num = startLine;\n return function parseSource(source) {\n let rest = source;\n const tokens = util_1.seedTokens();\n [tokens.lineEnd, rest] = util_1.splitCR(rest);\n [tokens.start, rest] = util_1.splitSpace(rest);\n if (block === null &&\n rest.startsWith(primitives_1.Markers.start) &&\n !rest.startsWith(primitives_1.Markers.nostart)) {\n block = [];\n tokens.delimiter = rest.slice(0, primitives_1.Markers.start.length);\n rest = rest.slice(primitives_1.Markers.start.length);\n [tokens.postDelimiter, rest] = util_1.splitSpace(rest);\n }\n if (block === null) {\n num++;\n return null;\n }\n const isClosed = rest.trimRight().endsWith(primitives_1.Markers.end);\n if (tokens.delimiter === '' &&\n rest.startsWith(primitives_1.Markers.delim) &&\n !rest.startsWith(primitives_1.Markers.end)) {\n tokens.delimiter = primitives_1.Markers.delim;\n rest = rest.slice(primitives_1.Markers.delim.length);\n [tokens.postDelimiter, rest] = util_1.splitSpace(rest);\n }\n if (isClosed) {\n const trimmed = rest.trimRight();\n tokens.end = rest.slice(trimmed.length - primitives_1.Markers.end.length);\n rest = trimmed.slice(0, -primitives_1.Markers.end.length);\n }\n tokens.description = rest;\n block.push({ number: num, source, tokens });\n num++;\n if (isClosed) {\n const result = block.slice();\n block = null;\n return result;\n }\n return null;\n };\n}\nexports.default = getParser;\n"],"file":"source-parser.cjs"}
|