@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,182 +1,182 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configStrings = void 0;
4
- const clone_1 = require("../util/clone");
5
- const regex_1 = require("../util/regex");
6
- const bracket_1 = require("./bracket");
7
- const rules_1 = require("./rules");
8
- function copyStateDefinition(state) {
9
- const result = (0, clone_1.clone)(state);
10
- Object.entries(result).forEach(([key, val]) => {
11
- result[key] = (0, clone_1.clone)(val);
12
- });
13
- return result;
14
- }
15
- function exprTplStatesMap($, { tplEndToken, tplEnd }) {
16
- const rootState = {};
17
- const tplState = copyStateDefinition($);
18
- for (const [bracketKey, bracketRule] of Object.entries(tplState)) {
19
- if (bracketRule.t === 'string' &&
20
- (0, bracket_1.isBracketKey)(bracketKey) &&
21
- (0, bracket_1.isRightKey)(bracketKey) &&
22
- (bracketRule.match.startsWith(tplEnd) ||
23
- tplEnd.startsWith(bracketRule.match))) {
24
- const counterpartKey = (0, bracket_1.getCounterpartBracketKey)(bracketKey);
25
- if (!counterpartKey) {
26
- throw new Error('String template definition conflicts with brackets');
27
- }
28
- const counterpartRule = tplState[counterpartKey];
29
- if (!counterpartRule || counterpartRule.t !== 'string') {
30
- throw new Error('String template definition conflicts with brackets');
31
- }
32
- delete tplState[bracketKey];
33
- counterpartRule.push = '$';
34
- rootState[counterpartKey] = (0, clone_1.clone)(counterpartRule);
35
- rootState[bracketKey] = { ...bracketRule, pop: 1 };
36
- }
37
- }
38
- const tplEndRule = {
39
- t: 'string',
40
- type: tplEndToken,
41
- match: tplEnd,
42
- chunk: tplEnd,
43
- pop: 1,
44
- };
45
- tplState[tplEndToken] = tplEndRule;
46
- return { $: rootState, tplState };
47
- }
48
- function configStrings(states, opts) {
49
- if (!opts.length) {
50
- return states;
51
- }
52
- const $ = copyStateDefinition(states.$);
53
- const strStates = {};
54
- const exprTplPreStates = [];
55
- const tplStates = {};
56
- opts.forEach((strOpt, strIdx) => {
57
- const { startsWith: strStart, endsWith: strEnd = strStart, escapeChar, templates: tplOpts, } = strOpt;
58
- const strToken = `str$${strIdx}`;
59
- const strStartToken = `${strToken}$start`;
60
- const strEndToken = `${strToken}$end`;
61
- const strValueToken = `${strToken}$value`;
62
- const strStateName = `${strToken}$state`;
63
- const strState = {
64
- ...(escapeChar && strEnd[0]
65
- ? {
66
- // 1. Escape the escape character (e.g. \\) to prevent it from escaping the delimiter
67
- [`${strToken}$escape_bs`]: {
68
- t: 'string',
69
- type: strValueToken,
70
- match: `${escapeChar}${escapeChar}`,
71
- chunk: `${escapeChar}${escapeChar}`,
72
- },
73
- // 2. Escape the delimiter (e.g. \")
74
- [`${strToken}$escape`]: {
75
- t: 'string',
76
- type: strValueToken,
77
- match: `${escapeChar}${strEnd[0]}`,
78
- chunk: `${escapeChar}${strEnd[0]}`,
79
- },
80
- }
81
- : {}),
82
- [strEndToken]: {
83
- t: 'string',
84
- type: strEndToken,
85
- match: strEnd,
86
- chunk: strEnd,
87
- pop: 1,
88
- },
89
- [strValueToken]: { ...rules_1.fallbackRule, type: strValueToken },
90
- };
91
- tplOpts === null || tplOpts === void 0 ? void 0 : tplOpts.forEach((tplOpt, tplIdx) => {
92
- var _a;
93
- const { startsWith: tplStart } = tplOpt;
94
- if (tplOpt.type === 'expr') {
95
- const tplToken = `${strToken}$tpl$${tplIdx}`;
96
- const tplStartToken = `${tplToken}$start`;
97
- const tplEndToken = `${tplToken}$end`;
98
- const tplStateName = `${tplToken}$state`;
99
- strState[tplStartToken] = {
100
- t: 'string',
101
- type: tplStartToken,
102
- match: tplStart,
103
- chunk: tplStart,
104
- push: tplStateName,
105
- };
106
- const { endsWith: tplEnd } = tplOpt;
107
- exprTplPreStates.push({ tplStateName, tplEndToken, tplEnd });
108
- }
109
- if (tplOpt.type === 'var') {
110
- const tplToken = `${strToken}$tpl$${tplIdx}`;
111
- const tplStartToken = `${tplToken}$start`;
112
- const tplTokenName = `${tplToken}$token`;
113
- const { operators = [], symbols } = tplOpt;
114
- let symRegex = symbols;
115
- if (!symRegex && ((_a = $.symbol) === null || _a === void 0 ? void 0 : _a.t) === 'regex') {
116
- symRegex = $.symbol.match;
117
- }
118
- if (!symRegex) {
119
- throw new Error(`String definition isn't found for template definition`);
120
- }
121
- const start = (0, regex_1.escape)(tplStart);
122
- const symSource = symRegex.source;
123
- let varTplSource = `${start}${symSource}`;
124
- const opRules = {};
125
- if (operators.length) {
126
- const opSource = `(?:${operators.map(regex_1.escape).join('|')})`;
127
- varTplSource += `(?:${opSource}${symSource})*`;
128
- operators.forEach((match, idx) => {
129
- const type = `op$${idx}`;
130
- opRules[type] = {
131
- t: 'string',
132
- type,
133
- match,
134
- chunk: match,
135
- };
136
- });
137
- }
138
- const match = new RegExp(varTplSource);
139
- strState[tplTokenName] = {
140
- t: 'regex',
141
- type: tplTokenName,
142
- match,
143
- chunk: tplStart,
144
- };
145
- const tplStartRule = {
146
- t: 'string',
147
- type: tplStartToken,
148
- match: tplStart,
149
- chunk: tplStart,
150
- };
151
- const symbolRule = {
152
- t: 'regex',
153
- type: 'symbol',
154
- match: symRegex,
155
- chunk: null,
156
- };
157
- tplStates[tplTokenName] = {
158
- [tplStartToken]: tplStartRule,
159
- symbol: symbolRule,
160
- ...opRules,
161
- };
162
- }
163
- });
164
- strStates[strStateName] = strState;
165
- $[strStartToken] = {
166
- t: 'string',
167
- type: strStartToken,
168
- match: strStart,
169
- chunk: strStart,
170
- push: strStateName,
171
- };
172
- });
173
- for (const exprTplStateInput of exprTplPreStates) {
174
- const { tplStateName } = exprTplStateInput;
175
- const exprTplStates = exprTplStatesMap($, exprTplStateInput);
176
- Object.assign($, exprTplStates.$);
177
- tplStates[tplStateName] = exprTplStates.tplState;
178
- }
179
- return { $, ...strStates, ...tplStates };
180
- }
181
- exports.configStrings = configStrings;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configStrings = void 0;
4
+ const clone_1 = require("../util/clone");
5
+ const regex_1 = require("../util/regex");
6
+ const bracket_1 = require("./bracket");
7
+ const rules_1 = require("./rules");
8
+ function copyStateDefinition(state) {
9
+ const result = (0, clone_1.clone)(state);
10
+ Object.entries(result).forEach(([key, val]) => {
11
+ result[key] = (0, clone_1.clone)(val);
12
+ });
13
+ return result;
14
+ }
15
+ function exprTplStatesMap($, { tplEndToken, tplEnd }) {
16
+ const rootState = {};
17
+ const tplState = copyStateDefinition($);
18
+ for (const [bracketKey, bracketRule] of Object.entries(tplState)) {
19
+ if (bracketRule.t === 'string' &&
20
+ (0, bracket_1.isBracketKey)(bracketKey) &&
21
+ (0, bracket_1.isRightKey)(bracketKey) &&
22
+ (bracketRule.match.startsWith(tplEnd) ||
23
+ tplEnd.startsWith(bracketRule.match))) {
24
+ const counterpartKey = (0, bracket_1.getCounterpartBracketKey)(bracketKey);
25
+ if (!counterpartKey) {
26
+ throw new Error('String template definition conflicts with brackets');
27
+ }
28
+ const counterpartRule = tplState[counterpartKey];
29
+ if (!counterpartRule || counterpartRule.t !== 'string') {
30
+ throw new Error('String template definition conflicts with brackets');
31
+ }
32
+ delete tplState[bracketKey];
33
+ counterpartRule.push = '$';
34
+ rootState[counterpartKey] = (0, clone_1.clone)(counterpartRule);
35
+ rootState[bracketKey] = { ...bracketRule, pop: 1 };
36
+ }
37
+ }
38
+ const tplEndRule = {
39
+ t: 'string',
40
+ type: tplEndToken,
41
+ match: tplEnd,
42
+ chunk: tplEnd,
43
+ pop: 1,
44
+ };
45
+ tplState[tplEndToken] = tplEndRule;
46
+ return { $: rootState, tplState };
47
+ }
48
+ function configStrings(states, opts) {
49
+ if (!opts.length) {
50
+ return states;
51
+ }
52
+ const $ = copyStateDefinition(states.$);
53
+ const strStates = {};
54
+ const exprTplPreStates = [];
55
+ const tplStates = {};
56
+ opts.forEach((strOpt, strIdx) => {
57
+ const { startsWith: strStart, endsWith: strEnd = strStart, escapeChar, templates: tplOpts, } = strOpt;
58
+ const strToken = `str$${strIdx}`;
59
+ const strStartToken = `${strToken}$start`;
60
+ const strEndToken = `${strToken}$end`;
61
+ const strValueToken = `${strToken}$value`;
62
+ const strStateName = `${strToken}$state`;
63
+ const strState = {
64
+ ...(escapeChar && strEnd[0]
65
+ ? {
66
+ // 1. Escape the escape character (e.g. \\) to prevent it from escaping the delimiter
67
+ [`${strToken}$escape_bs`]: {
68
+ t: 'string',
69
+ type: strValueToken,
70
+ match: `${escapeChar}${escapeChar}`,
71
+ chunk: `${escapeChar}${escapeChar}`,
72
+ },
73
+ // 2. Escape the delimiter (e.g. \")
74
+ [`${strToken}$escape`]: {
75
+ t: 'string',
76
+ type: strValueToken,
77
+ match: `${escapeChar}${strEnd[0]}`,
78
+ chunk: `${escapeChar}${strEnd[0]}`,
79
+ },
80
+ }
81
+ : {}),
82
+ [strEndToken]: {
83
+ t: 'string',
84
+ type: strEndToken,
85
+ match: strEnd,
86
+ chunk: strEnd,
87
+ pop: 1,
88
+ },
89
+ [strValueToken]: { ...rules_1.fallbackRule, type: strValueToken },
90
+ };
91
+ tplOpts === null || tplOpts === void 0 ? void 0 : tplOpts.forEach((tplOpt, tplIdx) => {
92
+ var _a;
93
+ const { startsWith: tplStart } = tplOpt;
94
+ if (tplOpt.type === 'expr') {
95
+ const tplToken = `${strToken}$tpl$${tplIdx}`;
96
+ const tplStartToken = `${tplToken}$start`;
97
+ const tplEndToken = `${tplToken}$end`;
98
+ const tplStateName = `${tplToken}$state`;
99
+ strState[tplStartToken] = {
100
+ t: 'string',
101
+ type: tplStartToken,
102
+ match: tplStart,
103
+ chunk: tplStart,
104
+ push: tplStateName,
105
+ };
106
+ const { endsWith: tplEnd } = tplOpt;
107
+ exprTplPreStates.push({ tplStateName, tplEndToken, tplEnd });
108
+ }
109
+ if (tplOpt.type === 'var') {
110
+ const tplToken = `${strToken}$tpl$${tplIdx}`;
111
+ const tplStartToken = `${tplToken}$start`;
112
+ const tplTokenName = `${tplToken}$token`;
113
+ const { operators = [], symbols } = tplOpt;
114
+ let symRegex = symbols;
115
+ if (!symRegex && ((_a = $.symbol) === null || _a === void 0 ? void 0 : _a.t) === 'regex') {
116
+ symRegex = $.symbol.match;
117
+ }
118
+ if (!symRegex) {
119
+ throw new Error(`String definition isn't found for template definition`);
120
+ }
121
+ const start = (0, regex_1.escape)(tplStart);
122
+ const symSource = symRegex.source;
123
+ let varTplSource = `${start}${symSource}`;
124
+ const opRules = {};
125
+ if (operators.length) {
126
+ const opSource = `(?:${operators.map(regex_1.escape).join('|')})`;
127
+ varTplSource += `(?:${opSource}${symSource})*`;
128
+ operators.forEach((match, idx) => {
129
+ const type = `op$${idx}`;
130
+ opRules[type] = {
131
+ t: 'string',
132
+ type,
133
+ match,
134
+ chunk: match,
135
+ };
136
+ });
137
+ }
138
+ const match = new RegExp(varTplSource);
139
+ strState[tplTokenName] = {
140
+ t: 'regex',
141
+ type: tplTokenName,
142
+ match,
143
+ chunk: tplStart,
144
+ };
145
+ const tplStartRule = {
146
+ t: 'string',
147
+ type: tplStartToken,
148
+ match: tplStart,
149
+ chunk: tplStart,
150
+ };
151
+ const symbolRule = {
152
+ t: 'regex',
153
+ type: 'symbol',
154
+ match: symRegex,
155
+ chunk: null,
156
+ };
157
+ tplStates[tplTokenName] = {
158
+ [tplStartToken]: tplStartRule,
159
+ symbol: symbolRule,
160
+ ...opRules,
161
+ };
162
+ }
163
+ });
164
+ strStates[strStateName] = strState;
165
+ $[strStartToken] = {
166
+ t: 'string',
167
+ type: strStartToken,
168
+ match: strStart,
169
+ chunk: strStart,
170
+ push: strStateName,
171
+ };
172
+ });
173
+ for (const exprTplStateInput of exprTplPreStates) {
174
+ const { tplStateName } = exprTplStateInput;
175
+ const exprTplStates = exprTplStatesMap($, exprTplStateInput);
176
+ Object.assign($, exprTplStates.$);
177
+ tplStates[tplStateName] = exprTplStates.tplState;
178
+ }
179
+ return { $, ...strStates, ...tplStates };
180
+ }
181
+ exports.configStrings = configStrings;
182
182
  //# sourceMappingURL=string.js.map
@@ -1,3 +1,3 @@
1
- import type { StatesMap, SymbolOption } from './types';
2
- export declare function configSymbols(states: StatesMap, { match }: SymbolOption): StatesMap;
1
+ import type { StatesMap, SymbolOption } from './types';
2
+ export declare function configSymbols(states: StatesMap, { match }: SymbolOption): StatesMap;
3
3
  //# sourceMappingURL=symbol.d.ts.map
@@ -1,19 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configSymbols = void 0;
4
- function configSymbols(states, { match }) {
5
- return {
6
- ...states,
7
- $: {
8
- ...states.$,
9
- symbol: {
10
- t: 'regex',
11
- type: 'symbol',
12
- match,
13
- chunk: null,
14
- },
15
- },
16
- };
17
- }
18
- exports.configSymbols = configSymbols;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configSymbols = void 0;
4
+ function configSymbols(states, { match }) {
5
+ return {
6
+ ...states,
7
+ $: {
8
+ ...states.$,
9
+ symbol: {
10
+ t: 'regex',
11
+ type: 'symbol',
12
+ match,
13
+ chunk: null,
14
+ },
15
+ },
16
+ };
17
+ }
18
+ exports.configSymbols = configSymbols;
19
19
  //# sourceMappingURL=symbol.js.map
@@ -1,4 +1,4 @@
1
- import type { Token as MooToken } from 'moo';
2
- import type { Token } from './types';
3
- export declare function coerceToken({ type, value, offset, line, col, lineBreaks }: MooToken, parent?: MooToken): Token;
1
+ import type { Token as MooToken } from 'moo';
2
+ import type { Token } from './types';
3
+ export declare function coerceToken({ type, value, offset, line, col, lineBreaks }: MooToken, parent?: MooToken): Token;
4
4
  //# sourceMappingURL=token.d.ts.map
@@ -1,65 +1,65 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.coerceToken = void 0;
4
- function coerceToken({ type, value, offset, line, col, lineBreaks }, parent) {
5
- const base = parent
6
- ? {
7
- value,
8
- offset: offset + parent.offset,
9
- line: line + parent.line - 1,
10
- col: col + parent.col - 1,
11
- lineBreaks: lineBreaks + parent.lineBreaks,
12
- }
13
- : { value, offset, line, col, lineBreaks };
14
- if (typeof type === 'string') {
15
- const [p1, , p2, , p3] = type.split('$');
16
- if (p1 === 'newline') {
17
- return { type: 'newline', ...base };
18
- }
19
- else if (p1 === 'whitespace') {
20
- return { type: 'whitespace', ...base };
21
- }
22
- else if (p1 === 'bracket') {
23
- if (p2 === 'left') {
24
- return { type: 'bracket-left', ...base };
25
- }
26
- else if (p2 === 'right') {
27
- return { type: 'bracket-right', ...base };
28
- }
29
- }
30
- else if (p1 === 'comment') {
31
- return { type: 'comment', ...base };
32
- }
33
- else if (p1 === 'op') {
34
- return { type: 'operator', ...base };
35
- }
36
- else if (p1 === 'str') {
37
- if (p2 === 'start') {
38
- return { type: 'string-start', ...base };
39
- }
40
- else if (p2 === 'value') {
41
- return { type: 'string-value', ...base };
42
- }
43
- else if (p2 === 'end') {
44
- return { type: 'string-end', ...base };
45
- }
46
- else if (p2 === 'tpl') {
47
- if (p3 === 'start') {
48
- return { type: 'template-start', ...base };
49
- }
50
- else if (p3 === 'end') {
51
- return { type: 'template-end', ...base };
52
- }
53
- }
54
- }
55
- else if (p1 === 'symbol') {
56
- return { type: 'symbol', ...base };
57
- }
58
- else if (p1 === 'number') {
59
- return { type: 'number', ...base };
60
- }
61
- }
62
- return { type: '_', ...base };
63
- }
64
- exports.coerceToken = coerceToken;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coerceToken = void 0;
4
+ function coerceToken({ type, value, offset, line, col, lineBreaks }, parent) {
5
+ const base = parent
6
+ ? {
7
+ value,
8
+ offset: offset + parent.offset,
9
+ line: line + parent.line - 1,
10
+ col: col + parent.col - 1,
11
+ lineBreaks: lineBreaks + parent.lineBreaks,
12
+ }
13
+ : { value, offset, line, col, lineBreaks };
14
+ if (typeof type === 'string') {
15
+ const [p1, , p2, , p3] = type.split('$');
16
+ if (p1 === 'newline') {
17
+ return { type: 'newline', ...base };
18
+ }
19
+ else if (p1 === 'whitespace') {
20
+ return { type: 'whitespace', ...base };
21
+ }
22
+ else if (p1 === 'bracket') {
23
+ if (p2 === 'left') {
24
+ return { type: 'bracket-left', ...base };
25
+ }
26
+ else if (p2 === 'right') {
27
+ return { type: 'bracket-right', ...base };
28
+ }
29
+ }
30
+ else if (p1 === 'comment') {
31
+ return { type: 'comment', ...base };
32
+ }
33
+ else if (p1 === 'op') {
34
+ return { type: 'operator', ...base };
35
+ }
36
+ else if (p1 === 'str') {
37
+ if (p2 === 'start') {
38
+ return { type: 'string-start', ...base };
39
+ }
40
+ else if (p2 === 'value') {
41
+ return { type: 'string-value', ...base };
42
+ }
43
+ else if (p2 === 'end') {
44
+ return { type: 'string-end', ...base };
45
+ }
46
+ else if (p2 === 'tpl') {
47
+ if (p3 === 'start') {
48
+ return { type: 'template-start', ...base };
49
+ }
50
+ else if (p3 === 'end') {
51
+ return { type: 'template-end', ...base };
52
+ }
53
+ }
54
+ }
55
+ else if (p1 === 'symbol') {
56
+ return { type: 'symbol', ...base };
57
+ }
58
+ else if (p1 === 'number') {
59
+ return { type: 'number', ...base };
60
+ }
61
+ }
62
+ return { type: '_', ...base };
63
+ }
64
+ exports.coerceToken = coerceToken;
65
65
  //# sourceMappingURL=token.js.map