@renovatebot/good-enough-parser 1.1.24 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +6 -6
  2. package/dist/cjs/index.d.ts +4 -4
  3. package/dist/cjs/index.js +7 -7
  4. package/dist/cjs/lang/groovy.d.ts +6 -6
  5. package/dist/cjs/lang/groovy.js +83 -83
  6. package/dist/cjs/lang/index.d.ts +20 -20
  7. package/dist/cjs/lang/index.js +56 -56
  8. package/dist/cjs/lang/python.d.ts +6 -6
  9. package/dist/cjs/lang/python.js +73 -73
  10. package/dist/cjs/lang/scala.d.ts +6 -6
  11. package/dist/cjs/lang/scala.js +71 -71
  12. package/dist/cjs/lang/starlark.d.ts +6 -6
  13. package/dist/cjs/lang/starlark.js +58 -58
  14. package/dist/cjs/lang/types.d.ts +6 -6
  15. package/dist/cjs/lang/types.js +2 -2
  16. package/dist/cjs/lexer/bracket.d.ts +6 -6
  17. package/dist/cjs/lexer/bracket.js +57 -57
  18. package/dist/cjs/lexer/comment.d.ts +3 -3
  19. package/dist/cjs/lexer/comment.js +44 -44
  20. package/dist/cjs/lexer/index.d.ts +5 -5
  21. package/dist/cjs/lexer/index.js +155 -155
  22. package/dist/cjs/lexer/number.d.ts +2 -2
  23. package/dist/cjs/lexer/number.js +18 -18
  24. package/dist/cjs/lexer/operator.d.ts +2 -2
  25. package/dist/cjs/lexer/operator.js +24 -24
  26. package/dist/cjs/lexer/rules.d.ts +4 -4
  27. package/dist/cjs/lexer/rules.js +74 -74
  28. package/dist/cjs/lexer/string.d.ts +2 -2
  29. package/dist/cjs/lexer/string.js +181 -181
  30. package/dist/cjs/lexer/symbol.d.ts +2 -2
  31. package/dist/cjs/lexer/symbol.js +18 -18
  32. package/dist/cjs/lexer/token.d.ts +3 -3
  33. package/dist/cjs/lexer/token.js +64 -64
  34. package/dist/cjs/lexer/types.d.ts +142 -142
  35. package/dist/cjs/lexer/types.js +2 -2
  36. package/dist/cjs/parser/cursor.d.ts +2 -2
  37. package/dist/cjs/parser/cursor.js +13 -13
  38. package/dist/cjs/parser/index.d.ts +3 -3
  39. package/dist/cjs/parser/index.js +19 -19
  40. package/dist/cjs/parser/tree.d.ts +4 -4
  41. package/dist/cjs/parser/tree.js +246 -246
  42. package/dist/cjs/parser/types.d.ts +33 -33
  43. package/dist/cjs/parser/types.js +2 -2
  44. package/dist/cjs/query/builder.d.ts +144 -144
  45. package/dist/cjs/query/builder.js +332 -332
  46. package/dist/cjs/query/handler.d.ts +2 -2
  47. package/dist/cjs/query/handler.js +10 -10
  48. package/dist/cjs/query/index.d.ts +2 -2
  49. package/dist/cjs/query/index.js +32 -32
  50. package/dist/cjs/query/matchers/abstract-matcher.d.ts +9 -9
  51. package/dist/cjs/query/matchers/abstract-matcher.js +36 -36
  52. package/dist/cjs/query/matchers/alt-matcher.d.ts +10 -10
  53. package/dist/cjs/query/matchers/alt-matcher.js +33 -33
  54. package/dist/cjs/query/matchers/anchor-matcher.d.ts +17 -17
  55. package/dist/cjs/query/matchers/anchor-matcher.js +50 -50
  56. package/dist/cjs/query/matchers/comment-matcher.d.ts +10 -10
  57. package/dist/cjs/query/matchers/comment-matcher.js +39 -39
  58. package/dist/cjs/query/matchers/index.d.ts +6 -6
  59. package/dist/cjs/query/matchers/index.js +22 -22
  60. package/dist/cjs/query/matchers/many-matcher.d.ts +13 -13
  61. package/dist/cjs/query/matchers/many-matcher.js +61 -61
  62. package/dist/cjs/query/matchers/num-matcher.d.ts +8 -8
  63. package/dist/cjs/query/matchers/num-matcher.js +34 -34
  64. package/dist/cjs/query/matchers/op-matcher.d.ts +8 -8
  65. package/dist/cjs/query/matchers/op-matcher.js +34 -34
  66. package/dist/cjs/query/matchers/seq-matcher.d.ts +14 -14
  67. package/dist/cjs/query/matchers/seq-matcher.js +76 -76
  68. package/dist/cjs/query/matchers/str-matcher.d.ts +38 -38
  69. package/dist/cjs/query/matchers/str-matcher.js +108 -108
  70. package/dist/cjs/query/matchers/sym-matcher.d.ts +8 -8
  71. package/dist/cjs/query/matchers/sym-matcher.js +34 -34
  72. package/dist/cjs/query/matchers/tree-matcher.d.ts +23 -23
  73. package/dist/cjs/query/matchers/tree-matcher.js +121 -121
  74. package/dist/cjs/query/options.d.ts +10 -10
  75. package/dist/cjs/query/options.js +149 -149
  76. package/dist/cjs/query/regex.d.ts +1 -1
  77. package/dist/cjs/query/regex.js +13 -13
  78. package/dist/cjs/query/types.d.ts +100 -100
  79. package/dist/cjs/query/types.js +2 -2
  80. package/dist/cjs/util/clone.d.ts +1 -1
  81. package/dist/cjs/util/clone.js +5 -5
  82. package/dist/cjs/util/regex.d.ts +1 -1
  83. package/dist/cjs/util/regex.js +7 -7
  84. package/dist/esm/index.d.ts +4 -4
  85. package/dist/esm/index.js +8 -8
  86. package/dist/esm/lang/groovy.d.ts +6 -6
  87. package/dist/esm/lang/groovy.js +80 -80
  88. package/dist/esm/lang/index.d.ts +20 -20
  89. package/dist/esm/lang/index.js +37 -37
  90. package/dist/esm/lang/python.d.ts +6 -6
  91. package/dist/esm/lang/python.js +70 -70
  92. package/dist/esm/lang/scala.d.ts +6 -6
  93. package/dist/esm/lang/scala.js +68 -68
  94. package/dist/esm/lang/starlark.d.ts +6 -6
  95. package/dist/esm/lang/starlark.js +55 -55
  96. package/dist/esm/lang/types.d.ts +6 -6
  97. package/dist/esm/lang/types.js +1 -1
  98. package/dist/esm/lexer/bracket.d.ts +6 -6
  99. package/dist/esm/lexer/bracket.js +49 -49
  100. package/dist/esm/lexer/comment.d.ts +3 -3
  101. package/dist/esm/lexer/comment.js +39 -39
  102. package/dist/esm/lexer/index.d.ts +5 -5
  103. package/dist/esm/lexer/index.js +136 -136
  104. package/dist/esm/lexer/number.d.ts +2 -2
  105. package/dist/esm/lexer/number.js +14 -14
  106. package/dist/esm/lexer/operator.d.ts +2 -2
  107. package/dist/esm/lexer/operator.js +20 -20
  108. package/dist/esm/lexer/rules.d.ts +4 -4
  109. package/dist/esm/lexer/rules.js +69 -69
  110. package/dist/esm/lexer/string.d.ts +2 -2
  111. package/dist/esm/lexer/string.js +177 -177
  112. package/dist/esm/lexer/symbol.d.ts +2 -2
  113. package/dist/esm/lexer/symbol.js +14 -14
  114. package/dist/esm/lexer/token.d.ts +3 -3
  115. package/dist/esm/lexer/token.js +60 -60
  116. package/dist/esm/lexer/types.d.ts +142 -142
  117. package/dist/esm/lexer/types.js +1 -1
  118. package/dist/esm/parser/cursor.d.ts +2 -2
  119. package/dist/esm/parser/cursor.js +9 -9
  120. package/dist/esm/parser/index.d.ts +3 -3
  121. package/dist/esm/parser/index.js +3 -3
  122. package/dist/esm/parser/tree.d.ts +4 -4
  123. package/dist/esm/parser/tree.js +241 -241
  124. package/dist/esm/parser/types.d.ts +33 -33
  125. package/dist/esm/parser/types.js +1 -1
  126. package/dist/esm/query/builder.d.ts +144 -144
  127. package/dist/esm/query/builder.js +304 -304
  128. package/dist/esm/query/handler.d.ts +2 -2
  129. package/dist/esm/query/handler.js +6 -6
  130. package/dist/esm/query/index.d.ts +2 -2
  131. package/dist/esm/query/index.js +2 -2
  132. package/dist/esm/query/matchers/abstract-matcher.d.ts +9 -9
  133. package/dist/esm/query/matchers/abstract-matcher.js +32 -32
  134. package/dist/esm/query/matchers/alt-matcher.d.ts +10 -10
  135. package/dist/esm/query/matchers/alt-matcher.js +29 -29
  136. package/dist/esm/query/matchers/anchor-matcher.d.ts +17 -17
  137. package/dist/esm/query/matchers/anchor-matcher.js +44 -44
  138. package/dist/esm/query/matchers/comment-matcher.d.ts +10 -10
  139. package/dist/esm/query/matchers/comment-matcher.js +35 -35
  140. package/dist/esm/query/matchers/index.d.ts +6 -6
  141. package/dist/esm/query/matchers/index.js +6 -6
  142. package/dist/esm/query/matchers/many-matcher.d.ts +13 -13
  143. package/dist/esm/query/matchers/many-matcher.js +57 -57
  144. package/dist/esm/query/matchers/num-matcher.d.ts +8 -8
  145. package/dist/esm/query/matchers/num-matcher.js +30 -30
  146. package/dist/esm/query/matchers/op-matcher.d.ts +8 -8
  147. package/dist/esm/query/matchers/op-matcher.js +30 -30
  148. package/dist/esm/query/matchers/seq-matcher.d.ts +14 -14
  149. package/dist/esm/query/matchers/seq-matcher.js +72 -72
  150. package/dist/esm/query/matchers/str-matcher.d.ts +38 -38
  151. package/dist/esm/query/matchers/str-matcher.js +102 -102
  152. package/dist/esm/query/matchers/sym-matcher.d.ts +8 -8
  153. package/dist/esm/query/matchers/sym-matcher.js +30 -30
  154. package/dist/esm/query/matchers/tree-matcher.d.ts +23 -23
  155. package/dist/esm/query/matchers/tree-matcher.js +117 -117
  156. package/dist/esm/query/options.d.ts +10 -10
  157. package/dist/esm/query/options.js +139 -139
  158. package/dist/esm/query/regex.d.ts +1 -1
  159. package/dist/esm/query/regex.js +9 -9
  160. package/dist/esm/query/types.d.ts +100 -100
  161. package/dist/esm/query/types.js +1 -1
  162. package/dist/esm/util/clone.d.ts +1 -1
  163. package/dist/esm/util/clone.js +1 -1
  164. package/dist/esm/util/regex.d.ts +1 -1
  165. package/dist/esm/util/regex.js +3 -3
  166. package/package.json +3 -3
@@ -1,156 +1,156 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.createLexer = exports.configureLexerRules = void 0;
18
- const moo_1 = require("moo");
19
- const bracket_1 = require("./bracket");
20
- const comment_1 = require("./comment");
21
- const number_1 = require("./number");
22
- const operator_1 = require("./operator");
23
- const rules_1 = require("./rules");
24
- const string_1 = require("./string");
25
- const symbol_1 = require("./symbol");
26
- const token_1 = require("./token");
27
- __exportStar(require("./token"), exports);
28
- __exportStar(require("./types"), exports);
29
- function configureLexerRules(lexerConfig) {
30
- const whitespace = lexerConfig.joinLines
31
- ? {
32
- t: 'regex',
33
- type: 'whitespace',
34
- match: new RegExp(`(?:${lexerConfig.joinLines}\\r?\\n|[ \\t\\r])+`),
35
- lineBreaks: true,
36
- chunk: null,
37
- }
38
- : {
39
- t: 'regex',
40
- type: 'whitespace',
41
- match: /[ \t\r]+/,
42
- chunk: null,
43
- };
44
- let result = {
45
- $: {
46
- whitespace,
47
- newline: {
48
- t: 'regex',
49
- type: 'newline',
50
- match: /\r?\n/,
51
- chunk: null,
52
- lineBreaks: true,
53
- },
54
- _: { ...rules_1.fallbackRule, type: '_' },
55
- },
56
- };
57
- const { comments, symbols, operators, brackets, strings, numbers } = lexerConfig;
58
- result = (0, comment_1.configComments)(result, comments);
59
- result = (0, symbol_1.configSymbols)(result, { match: symbols });
60
- result = (0, operator_1.configOperators)(result, operators);
61
- result = (0, bracket_1.configBrackets)(result, brackets);
62
- result = (0, string_1.configStrings)(result, strings);
63
- result = (0, number_1.configNumbers)(result, { match: numbers });
64
- const orderedResult = (0, rules_1.createOrderedStateMap)(result);
65
- return orderedResult;
66
- }
67
- exports.configureLexerRules = configureLexerRules;
68
- function isVarToken(key) {
69
- return typeof key === 'string' && /^str\$\d+\$tpl\$\d+\$token$/.test(key);
70
- }
71
- function getVarEndToken({ type, value, offset, line, col, lineBreaks, }) {
72
- return {
73
- type: type === null || type === void 0 ? void 0 : type.replace(/\$[^$]+$/, '$end'),
74
- value: '',
75
- text: '',
76
- offset: offset + value.length,
77
- line: line + lineBreaks,
78
- col: col + value.length,
79
- lineBreaks: 0,
80
- };
81
- }
82
- function getSubLexers(states) {
83
- const result = {};
84
- for (const [key, rules] of Object.entries(states)) {
85
- if (isVarToken(key)) {
86
- result[key] = (0, moo_1.compile)(rules);
87
- }
88
- }
89
- return result;
90
- }
91
- function createLexer(options) {
92
- const rules = configureLexerRules(options);
93
- const subLexers = getSubLexers(rules);
94
- const mainLexer = (0, moo_1.states)(rules);
95
- let subLexer;
96
- let subLexerToken;
97
- const result = {
98
- reset(input) {
99
- Object.values(subLexers).forEach((subLexer) => subLexer.reset());
100
- subLexer = undefined;
101
- subLexerToken = undefined;
102
- if (typeof input === 'undefined' || input === null) {
103
- mainLexer.reset();
104
- }
105
- else {
106
- mainLexer.reset(input);
107
- }
108
- return result;
109
- },
110
- [Symbol.iterator]() {
111
- const next = () => {
112
- const mooLexer = subLexer !== null && subLexer !== void 0 ? subLexer : mainLexer;
113
- const mooIter = mooLexer[Symbol.iterator]();
114
- const nextElem = mooIter.next();
115
- if (nextElem.done) {
116
- if (subLexer && subLexerToken) {
117
- const subLexerType = subLexerToken.type;
118
- mooLexer.reset();
119
- if (isVarToken(subLexerType)) {
120
- const x = getVarEndToken(subLexerToken);
121
- const value = (0, token_1.coerceToken)(x);
122
- subLexer = undefined;
123
- subLexerToken = undefined;
124
- return { done: false, value };
125
- }
126
- else {
127
- subLexer = undefined;
128
- subLexerToken = undefined;
129
- return next();
130
- }
131
- }
132
- else {
133
- return { done: true, value: null };
134
- }
135
- }
136
- const mooToken = nextElem.value;
137
- if (!subLexer) {
138
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
139
- const mooTokenType = mooToken.type;
140
- subLexer = subLexers[mooTokenType];
141
- if (subLexer) {
142
- subLexerToken = mooToken;
143
- subLexer.reset(mooToken.value);
144
- return next();
145
- }
146
- }
147
- const value = (0, token_1.coerceToken)(mooToken, subLexerToken);
148
- return { done: false, value };
149
- };
150
- return { next };
151
- },
152
- };
153
- return result;
154
- }
155
- exports.createLexer = createLexer;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createLexer = exports.configureLexerRules = void 0;
18
+ const moo_1 = require("moo");
19
+ const bracket_1 = require("./bracket");
20
+ const comment_1 = require("./comment");
21
+ const number_1 = require("./number");
22
+ const operator_1 = require("./operator");
23
+ const rules_1 = require("./rules");
24
+ const string_1 = require("./string");
25
+ const symbol_1 = require("./symbol");
26
+ const token_1 = require("./token");
27
+ __exportStar(require("./token"), exports);
28
+ __exportStar(require("./types"), exports);
29
+ function configureLexerRules(lexerConfig) {
30
+ const whitespace = lexerConfig.joinLines
31
+ ? {
32
+ t: 'regex',
33
+ type: 'whitespace',
34
+ match: new RegExp(`(?:${lexerConfig.joinLines}\\r?\\n|[ \\t\\r])+`),
35
+ lineBreaks: true,
36
+ chunk: null,
37
+ }
38
+ : {
39
+ t: 'regex',
40
+ type: 'whitespace',
41
+ match: /[ \t\r]+/,
42
+ chunk: null,
43
+ };
44
+ let result = {
45
+ $: {
46
+ whitespace,
47
+ newline: {
48
+ t: 'regex',
49
+ type: 'newline',
50
+ match: /\r?\n/,
51
+ chunk: null,
52
+ lineBreaks: true,
53
+ },
54
+ _: { ...rules_1.fallbackRule, type: '_' },
55
+ },
56
+ };
57
+ const { comments, symbols, operators, brackets, strings, numbers } = lexerConfig;
58
+ result = (0, comment_1.configComments)(result, comments);
59
+ result = (0, symbol_1.configSymbols)(result, { match: symbols });
60
+ result = (0, operator_1.configOperators)(result, operators);
61
+ result = (0, bracket_1.configBrackets)(result, brackets);
62
+ result = (0, string_1.configStrings)(result, strings);
63
+ result = (0, number_1.configNumbers)(result, { match: numbers });
64
+ const orderedResult = (0, rules_1.createOrderedStateMap)(result);
65
+ return orderedResult;
66
+ }
67
+ exports.configureLexerRules = configureLexerRules;
68
+ function isVarToken(key) {
69
+ return typeof key === 'string' && /^str\$\d+\$tpl\$\d+\$token$/.test(key);
70
+ }
71
+ function getVarEndToken({ type, value, offset, line, col, lineBreaks, }) {
72
+ return {
73
+ type: type === null || type === void 0 ? void 0 : type.replace(/\$[^$]+$/, '$end'),
74
+ value: '',
75
+ text: '',
76
+ offset: offset + value.length,
77
+ line: line + lineBreaks,
78
+ col: col + value.length,
79
+ lineBreaks: 0,
80
+ };
81
+ }
82
+ function getSubLexers(states) {
83
+ const result = {};
84
+ for (const [key, rules] of Object.entries(states)) {
85
+ if (isVarToken(key)) {
86
+ result[key] = (0, moo_1.compile)(rules);
87
+ }
88
+ }
89
+ return result;
90
+ }
91
+ function createLexer(options) {
92
+ const rules = configureLexerRules(options);
93
+ const subLexers = getSubLexers(rules);
94
+ const mainLexer = (0, moo_1.states)(rules);
95
+ let subLexer;
96
+ let subLexerToken;
97
+ const result = {
98
+ reset(input) {
99
+ Object.values(subLexers).forEach((subLexer) => subLexer.reset());
100
+ subLexer = undefined;
101
+ subLexerToken = undefined;
102
+ if (typeof input === 'undefined' || input === null) {
103
+ mainLexer.reset();
104
+ }
105
+ else {
106
+ mainLexer.reset(input);
107
+ }
108
+ return result;
109
+ },
110
+ [Symbol.iterator]() {
111
+ const next = () => {
112
+ const mooLexer = subLexer !== null && subLexer !== void 0 ? subLexer : mainLexer;
113
+ const mooIter = mooLexer[Symbol.iterator]();
114
+ const nextElem = mooIter.next();
115
+ if (nextElem.done) {
116
+ if (subLexer && subLexerToken) {
117
+ const subLexerType = subLexerToken.type;
118
+ mooLexer.reset();
119
+ if (isVarToken(subLexerType)) {
120
+ const x = getVarEndToken(subLexerToken);
121
+ const value = (0, token_1.coerceToken)(x);
122
+ subLexer = undefined;
123
+ subLexerToken = undefined;
124
+ return { done: false, value };
125
+ }
126
+ else {
127
+ subLexer = undefined;
128
+ subLexerToken = undefined;
129
+ return next();
130
+ }
131
+ }
132
+ else {
133
+ return { done: true, value: null };
134
+ }
135
+ }
136
+ const mooToken = nextElem.value;
137
+ if (!subLexer) {
138
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
139
+ const mooTokenType = mooToken.type;
140
+ subLexer = subLexers[mooTokenType];
141
+ if (subLexer) {
142
+ subLexerToken = mooToken;
143
+ subLexer.reset(mooToken.value);
144
+ return next();
145
+ }
146
+ }
147
+ const value = (0, token_1.coerceToken)(mooToken, subLexerToken);
148
+ return { done: false, value };
149
+ };
150
+ return { next };
151
+ },
152
+ };
153
+ return result;
154
+ }
155
+ exports.createLexer = createLexer;
156
156
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
- import type { NumberOption, StatesMap } from './types';
2
- export declare function configNumbers(states: StatesMap, { match }: NumberOption): StatesMap;
1
+ import type { NumberOption, StatesMap } from './types';
2
+ export declare function configNumbers(states: StatesMap, { match }: NumberOption): StatesMap;
3
3
  //# sourceMappingURL=number.d.ts.map
@@ -1,19 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configNumbers = void 0;
4
- function configNumbers(states, { match }) {
5
- return {
6
- ...states,
7
- $: {
8
- ...states.$,
9
- number: {
10
- t: 'regex',
11
- type: 'number',
12
- match,
13
- chunk: null,
14
- },
15
- },
16
- };
17
- }
18
- exports.configNumbers = configNumbers;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configNumbers = void 0;
4
+ function configNumbers(states, { match }) {
5
+ return {
6
+ ...states,
7
+ $: {
8
+ ...states.$,
9
+ number: {
10
+ t: 'regex',
11
+ type: 'number',
12
+ match,
13
+ chunk: null,
14
+ },
15
+ },
16
+ };
17
+ }
18
+ exports.configNumbers = configNumbers;
19
19
  //# sourceMappingURL=number.js.map
@@ -1,3 +1,3 @@
1
- import type { OperatorOption, StatesMap } from './types';
2
- export declare function configOperators(states: StatesMap, operators: OperatorOption[]): StatesMap;
1
+ import type { OperatorOption, StatesMap } from './types';
2
+ export declare function configOperators(states: StatesMap, operators: OperatorOption[]): StatesMap;
3
3
  //# sourceMappingURL=operator.d.ts.map
@@ -1,25 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configOperators = void 0;
4
- function configOperators(states, operators) {
5
- const operatorRules = {};
6
- operators.map((op, idx) => {
7
- const tokenName = `op$${idx}`;
8
- const tokenRule = {
9
- t: 'string',
10
- type: tokenName,
11
- match: op,
12
- chunk: op,
13
- };
14
- operatorRules[tokenName] = tokenRule;
15
- });
16
- return {
17
- ...states,
18
- $: {
19
- ...states.$,
20
- ...operatorRules,
21
- },
22
- };
23
- }
24
- exports.configOperators = configOperators;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configOperators = void 0;
4
+ function configOperators(states, operators) {
5
+ const operatorRules = {};
6
+ operators.map((op, idx) => {
7
+ const tokenName = `op$${idx}`;
8
+ const tokenRule = {
9
+ t: 'string',
10
+ type: tokenName,
11
+ match: op,
12
+ chunk: op,
13
+ };
14
+ operatorRules[tokenName] = tokenRule;
15
+ });
16
+ return {
17
+ ...states,
18
+ $: {
19
+ ...states.$,
20
+ ...operatorRules,
21
+ },
22
+ };
23
+ }
24
+ exports.configOperators = configOperators;
25
25
  //# sourceMappingURL=operator.js.map
@@ -1,5 +1,5 @@
1
- import type { FallbackRule, LexerRule, OrderedStatesMap, StatesMap } from './types';
2
- export declare const fallbackRule: Omit<FallbackRule, 'type'>;
3
- export declare function sortLexerRules(state: LexerRule[]): LexerRule[];
4
- export declare function createOrderedStateMap(statesMap: StatesMap): OrderedStatesMap;
1
+ import type { FallbackRule, LexerRule, OrderedStatesMap, StatesMap } from './types';
2
+ export declare const fallbackRule: Omit<FallbackRule, 'type'>;
3
+ export declare function sortLexerRules(state: LexerRule[]): LexerRule[];
4
+ export declare function createOrderedStateMap(statesMap: StatesMap): OrderedStatesMap;
5
5
  //# sourceMappingURL=rules.d.ts.map
@@ -1,75 +1,75 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createOrderedStateMap = exports.sortLexerRules = exports.fallbackRule = void 0;
4
- const moo_1 = require("moo");
5
- exports.fallbackRule = {
6
- ...moo_1.fallback,
7
- t: 'fallback',
8
- chunk: null,
9
- };
10
- function compareChunksByValue(x, y) {
11
- if (typeof x.chunk === 'string' && typeof y.chunk === 'string') {
12
- const xChunk = x.chunk;
13
- const yChunk = y.chunk;
14
- if (yChunk < xChunk) {
15
- return 1;
16
- }
17
- else if (xChunk < yChunk) {
18
- return -1;
19
- }
20
- }
21
- return 0;
22
- }
23
- function compareChunksByInclusion(x, y) {
24
- if (typeof x.chunk === 'string' && typeof y.chunk === 'string') {
25
- const xChunk = x.chunk;
26
- const yChunk = y.chunk;
27
- if (yChunk.startsWith(xChunk)) {
28
- return 1;
29
- }
30
- else if (xChunk.startsWith(yChunk)) {
31
- return -1;
32
- }
33
- }
34
- return 0;
35
- }
36
- function sortLexerRules(state) {
37
- const values = Object.values(state);
38
- if (values.length < 2) {
39
- return state;
40
- }
41
- const fallbackRules = [];
42
- const numberRules = [];
43
- const chunkRules = [];
44
- const otherRules = [];
45
- for (const rule of values) {
46
- if (rule.t === 'fallback') {
47
- fallbackRules.push(rule);
48
- }
49
- else if (rule.type === 'number') {
50
- numberRules.push(rule);
51
- }
52
- else if (typeof rule.chunk === 'string') {
53
- chunkRules.push(rule);
54
- }
55
- else {
56
- otherRules.push(rule);
57
- }
58
- }
59
- chunkRules.sort((x, y) => compareChunksByValue(x, y));
60
- chunkRules.sort((x, y) => compareChunksByInclusion(x, y));
61
- const res = [...numberRules, ...chunkRules, ...otherRules, ...fallbackRules];
62
- return res;
63
- }
64
- exports.sortLexerRules = sortLexerRules;
65
- function createOrderedStateMap(statesMap) {
66
- const result = { $: [] };
67
- for (const [stateName, state] of Object.entries(statesMap)) {
68
- const stateValues = Object.values(state);
69
- const orderedStateValues = sortLexerRules(stateValues);
70
- result[stateName] = orderedStateValues;
71
- }
72
- return result;
73
- }
74
- exports.createOrderedStateMap = createOrderedStateMap;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createOrderedStateMap = exports.sortLexerRules = exports.fallbackRule = void 0;
4
+ const moo_1 = require("moo");
5
+ exports.fallbackRule = {
6
+ ...moo_1.fallback,
7
+ t: 'fallback',
8
+ chunk: null,
9
+ };
10
+ function compareChunksByValue(x, y) {
11
+ if (typeof x.chunk === 'string' && typeof y.chunk === 'string') {
12
+ const xChunk = x.chunk;
13
+ const yChunk = y.chunk;
14
+ if (yChunk < xChunk) {
15
+ return 1;
16
+ }
17
+ else if (xChunk < yChunk) {
18
+ return -1;
19
+ }
20
+ }
21
+ return 0;
22
+ }
23
+ function compareChunksByInclusion(x, y) {
24
+ if (typeof x.chunk === 'string' && typeof y.chunk === 'string') {
25
+ const xChunk = x.chunk;
26
+ const yChunk = y.chunk;
27
+ if (yChunk.startsWith(xChunk)) {
28
+ return 1;
29
+ }
30
+ else if (xChunk.startsWith(yChunk)) {
31
+ return -1;
32
+ }
33
+ }
34
+ return 0;
35
+ }
36
+ function sortLexerRules(state) {
37
+ const values = Object.values(state);
38
+ if (values.length < 2) {
39
+ return state;
40
+ }
41
+ const fallbackRules = [];
42
+ const numberRules = [];
43
+ const chunkRules = [];
44
+ const otherRules = [];
45
+ for (const rule of values) {
46
+ if (rule.t === 'fallback') {
47
+ fallbackRules.push(rule);
48
+ }
49
+ else if (rule.type === 'number') {
50
+ numberRules.push(rule);
51
+ }
52
+ else if (typeof rule.chunk === 'string') {
53
+ chunkRules.push(rule);
54
+ }
55
+ else {
56
+ otherRules.push(rule);
57
+ }
58
+ }
59
+ chunkRules.sort((x, y) => compareChunksByValue(x, y));
60
+ chunkRules.sort((x, y) => compareChunksByInclusion(x, y));
61
+ const res = [...numberRules, ...chunkRules, ...otherRules, ...fallbackRules];
62
+ return res;
63
+ }
64
+ exports.sortLexerRules = sortLexerRules;
65
+ function createOrderedStateMap(statesMap) {
66
+ const result = { $: [] };
67
+ for (const [stateName, state] of Object.entries(statesMap)) {
68
+ const stateValues = Object.values(state);
69
+ const orderedStateValues = sortLexerRules(stateValues);
70
+ result[stateName] = orderedStateValues;
71
+ }
72
+ return result;
73
+ }
74
+ exports.createOrderedStateMap = createOrderedStateMap;
75
75
  //# sourceMappingURL=rules.js.map
@@ -1,3 +1,3 @@
1
- import type { StatesMap, StringOption } from './types';
2
- export declare function configStrings(states: StatesMap, opts: StringOption[]): StatesMap;
1
+ import type { StatesMap, StringOption } from './types';
2
+ export declare function configStrings(states: StatesMap, opts: StringOption[]): StatesMap;
3
3
  //# sourceMappingURL=string.d.ts.map