3 lines
33 KiB
JavaScript
3 lines
33 KiB
JavaScript
|
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eslint-community/regexpp"),t=require("refa");function r(e){return e.unicode||!!e.unicodeSets}function n(e,t){throw new Error(t||e)}function s(e){let t=null;for(const r of e)if(null===t)t=r.parent;else if(r.parent!==t)throw new Error("Expected all alternatives to have the same parent")}exports.Chars=void 0,function(e){e.maxChar=function(e){return r(e)?1114111:65535};const n=t.CharSet.empty(65535),s=t.CharSet.empty(1114111);e.empty=function(e){return r(e)?s:n};const a=t.CharSet.all(65535),o=t.CharSet.all(1114111);e.all=function(e){return r(e)?o:a};const c=t.JS.createCharSet([{kind:"any"}],{unicode:!1}).negate(),i=t.JS.createCharSet([{kind:"any"}],{unicode:!0}).negate();e.lineTerminator=function(e){return r(e)?i:c};const u=t.JS.createCharSet([{kind:"word",negate:!1}],{unicode:!1}),l=t.JS.createCharSet([{kind:"word",negate:!1}],{unicode:!0,ignoreCase:!1}),h=t.JS.createCharSet([{kind:"word",negate:!1}],{unicode:!0,ignoreCase:!0});e.word=function(e){return r(e)?e.ignoreCase?h:l:u};const p=t.JS.createCharSet([{kind:"digit",negate:!1}],{unicode:!1}),f=t.JS.createCharSet([{kind:"digit",negate:!1}],{unicode:!0});e.digit=function(e){return r(e)?f:p};const C=t.JS.createCharSet([{kind:"space",negate:!1}],{unicode:!1}),m=t.JS.createCharSet([{kind:"space",negate:!1}],{unicode:!0});e.space=function(e){return r(e)?m:C}}(exports.Chars||(exports.Chars={}));const a=Array.isArray;class o{get char(){return this._exactChars.union(this._inexactChars)}get exact(){return this._exactChars.isSupersetOf(this._inexactChars)}constructor(e){this._exactChars=e,this._inexactChars=e}add(e){e.exact?this._exactChars=this._exactChars.union(e.char):this._inexactChars=this._inexactChars.union(e.char)}static fromFlags(e){return new o(exports.Chars.empty(e))}static fromMaximum(e){return new o(t.CharSet.empty(e))}}function c(e,t){const r=e.char.intersect(t.char);return{char:r,exact:e.exact&&t.exact||r.isEmpty}}class i{constructor(e){this.count=e,this._indexes=[];for(let t=0;t<e;t++)this._indexes.push(t)}makeEqual(e,t){let r=this._indexes[e],n=this._indexes[t];for(;r!==n;)r<n?(this._indexes[t]=r,t=n,n=this._indexes[t]):(this._indexes[e]=n,e=r,r=this._indexes[e])}getEquivalenceSets(){let e=0;for(let t=0;t<this.count;t++)t===this._indexes[t]?this._indexes[t]=e++:this._indexes[t]=this._indexes[this._indexes[t]];return{count:e,indexes:this._indexes}}}function u(e){return l.from(e)}class l{constructor(e){this.toCharSet=new WeakMap,this.toUnicodeSet=new WeakMap,this.getFirstConsumedCharLTR=new WeakMap,this.getFirstConsumedCharRTL=new WeakMap,this.getLongestPrefix=new Map,this.dotAll=!!e.dotAll,this.global=!!e.global,this.hasIndices=!!e.hasIndices,this.ignoreCase=!!e.ignoreCase,this.multiline=!!e.multiline,this.sticky=!!e.sticky,this.unicode=!!e.unicode,this.unicodeSets=!!e.unicodeSets}static from(e){return e instanceof l?e:new l(e)}}function h(e,r){if(!t.JS.isFlags(r))throw new Error("Invalid flags.");return a(e)?0===e.length?exports.Chars.empty(r):1===e.length?p(e[0],r):exports.Chars.empty(r).union(...e.map((e=>p(e,r)))):p(e,r)}function p(e,r){if(r instanceof l){let n=r.toCharSet.get(e);return void 0===n&&(n=t.JS.parseCharSet(e,r),r.toCharSet.set(e,n)),n}return t.JS.parseCharSet(e,r)}function f(e,r){if(!t.JS.isFlags(r))throw new Error("Invalid flags.");return a(e)?0===e.length?t.JS.UnicodeSet.empty(exports.Chars.maxChar(r)):1===e.length?C(e[0],r):t.JS.UnicodeSet.empty(exports.Chars.maxChar(r)).union(...e.map((e=>C(e,r)))):C(e,r)}function C(e,r){if(r instanceof l){let n=r.toUnicodeSet.get(e);return void 0===n&&(n=t.JS.parseUnicodeSet(e,r),r.toUnicodeSet.set(e,n)),n}return t.JS.parseUnicodeSet(e,r)}function m(e,t){switch(e.type){case"Character":case"ClassStringDisjunction":case"StringAlternative":return!1;case"CharacterClassRange":return 0===e.min.value&&e.max.value===exports.Chars.maxChar(t);case"CharacterSet":return"property"===e.kind?!e.strings&&h(e,t).isAll:"any"===e.kind&&!!t.dotAll;case"CharacterClass":return e.negate?e.elements.every((e=>d(e,t))):0!==e.elements.length&&(1===e.elem
|
||
|
|
//# sourceMappingURL=index.js.map
|