1// Jest Snapshot v1, https://goo.gl/fbAQLP
2
3exports[`deduplicates hoisted expressions 1`] = `
4"import { match, __pattern as _pattern } from \\"reghex\\";
5const re = /1/;
6const str = '1';
7
8var _re_expression = _pattern(re),
9 _str_expression = _pattern(str);
10
11const a = function (state) {
12 var y1 = state.y,
13 x1 = state.x;
14 var node = [];
15 var x;
16
17 if ((x = _re_expression(state)) != null) {
18 node.push(x);
19 } else {
20 state.y = y1;
21 state.x = x1;
22 return;
23 }
24
25 if ((x = _str_expression(state)) != null) {
26 node.push(x);
27 } else {
28 state.y = y1;
29 state.x = x1;
30 return;
31 }
32
33 node.tag = 'a';
34 return node;
35};
36
37var _b_expression = _pattern('2');
38
39const b = function (state) {
40 var y1 = state.y,
41 x1 = state.x;
42 var node = [];
43 var x;
44
45 if ((x = _re_expression(state)) != null) {
46 node.push(x);
47 } else {
48 state.y = y1;
49 state.x = x1;
50 return;
51 }
52
53 if ((x = _b_expression(state)) != null) {
54 node.push(x);
55 } else {
56 state.y = y1;
57 state.x = x1;
58 return;
59 }
60
61 node.tag = 'b';
62 return node;
63};"
64`;
65
66exports[`works together with @babel/plugin-transform-modules-commonjs 1`] = `
67"\\"use strict\\";
68
69var _reghex = require(\\"reghex\\");
70
71var _node_expression = (0, _reghex.__pattern)(1),
72 _node_expression2 = (0, _reghex.__pattern)(2);
73
74const node = function (state) {
75 var y1 = state.y,
76 x1 = state.x;
77 var node = [];
78 var x;
79
80 if ((x = _node_expression(state)) != null) {
81 node.push(x);
82 } else {
83 state.y = y1;
84 state.x = x1;
85 return;
86 }
87
88 if ((x = _node_expression2(state)) != null) {
89 node.push(x);
90 } else {
91 state.y = y1;
92 state.x = x1;
93 return;
94 }
95
96 node.tag = 'node';
97 return node;
98};"
99`;
100
101exports[`works while only minifying 1`] = `
102"import { match } from 'reghex/macro';
103const node = match('node')([\\"\\", \\"+|\\", \\"+(\\", \\"(\\", \\"?\\", \\"))*\\"], 1, 2, 3, 4, 5);"
104`;
105
106exports[`works with local recursion 1`] = `
107"import { match as m, tag, __pattern as _pattern } from 'reghex';
108
109var _inner_expression = _pattern(/inner/);
110
111const inner = function (state) {
112 var y1 = state.y,
113 x1 = state.x;
114 var node = [];
115 var x;
116
117 if ((x = _inner_expression(state)) != null) {
118 node.push(x);
119 } else {
120 state.y = y1;
121 state.x = x1;
122 return;
123 }
124
125 node.tag = 'inner';
126 return node;
127};
128
129const node = function (state) {
130 var y1 = state.y,
131 x1 = state.x;
132 var node = [];
133 var x;
134
135 if ((x = inner(state)) != null) {
136 node.push(x);
137 } else {
138 state.y = y1;
139 state.x = x1;
140 return;
141 }
142
143 node.tag = 'node';
144 return node;
145};"
146`;
147
148exports[`works with non-capturing groups 1`] = `
149"import { match, __pattern as _pattern } from 'reghex';
150
151var _node_expression = _pattern(1),
152 _node_expression2 = _pattern(2),
153 _node_expression3 = _pattern(3);
154
155const node = function (state) {
156 var y1 = state.y,
157 x1 = state.x;
158 var node = [];
159 var x;
160
161 if ((x = _node_expression(state)) != null) {
162 node.push(x);
163 } else {
164 state.y = y1;
165 state.x = x1;
166 return;
167 }
168
169 var ln2 = node.length;
170
171 alt_3: {
172 block_3: {
173 var y3 = state.y,
174 x3 = state.x;
175
176 if ((x = _node_expression2(state)) != null) {
177 node.push(x);
178 } else {
179 state.y = y3;
180 state.x = x3;
181 node.length = ln2;
182 break block_3;
183 }
184
185 break alt_3;
186 }
187
188 if ((x = _node_expression3(state)) == null) {
189 state.y = y1;
190 state.x = x1;
191 node.length = ln2;
192 return;
193 }
194
195 loop_3: for (;;) {
196 var y3 = state.y,
197 x3 = state.x;
198
199 if ((x = _node_expression3(state)) == null) {
200 state.y = y3;
201 state.x = x3;
202 break loop_3;
203 }
204 }
205 }
206
207 node.tag = 'node';
208 return node;
209};"
210`;
211
212exports[`works with self-referential thunks 1`] = `
213"import { match, tag, __pattern as _pattern } from 'reghex';
214
215const inner = function (state) {
216 var y1 = state.y,
217 x1 = state.x;
218 var node = [];
219 var x;
220
221 if ((x = node(state)) != null) {
222 node.push(x);
223 } else {
224 state.y = y1;
225 state.x = x1;
226 return;
227 }
228
229 node.tag = 'inner';
230 return node;
231};
232
233const node = function (state) {
234 var y1 = state.y,
235 x1 = state.x;
236 var node = [];
237 var x;
238
239 if ((x = inner(state)) != null) {
240 node.push(x);
241 } else {
242 state.y = y1;
243 state.x = x1;
244 return;
245 }
246
247 node.tag = 'node';
248 return node;
249};"
250`;
251
252exports[`works with standard features 1`] = `
253"import { match, __pattern as _pattern } from \\"reghex\\";
254
255var _node_expression = _pattern(1),
256 _node_expression2 = _pattern(2),
257 _node_expression3 = _pattern(3),
258 _node_expression4 = _pattern(4),
259 _node_expression5 = _pattern(5);
260
261const node = function (state) {
262 var y1 = state.y,
263 x1 = state.x;
264 var node = [];
265 var x;
266
267 alt_2: {
268 block_2: {
269 var y2 = state.y,
270 x2 = state.x;
271
272 if ((x = _node_expression(state)) != null) {
273 node.push(x);
274 } else {
275 state.y = y2;
276 state.x = x2;
277 break block_2;
278 }
279
280 loop_2: for (;;) {
281 var y2 = state.y,
282 x2 = state.x;
283
284 if ((x = _node_expression(state)) != null) {
285 node.push(x);
286 } else {
287 state.y = y2;
288 state.x = x2;
289 break loop_2;
290 }
291 }
292
293 break alt_2;
294 }
295
296 if ((x = _node_expression2(state)) != null) {
297 node.push(x);
298 } else {
299 state.y = y1;
300 state.x = x1;
301 return;
302 }
303
304 loop_2: for (;;) {
305 var y2 = state.y,
306 x2 = state.x;
307
308 if ((x = _node_expression2(state)) != null) {
309 node.push(x);
310 } else {
311 state.y = y2;
312 state.x = x2;
313 break loop_2;
314 }
315 }
316
317 loop_2: for (;;) {
318 var y2 = state.y,
319 x2 = state.x;
320 var ln2 = node.length;
321
322 if ((x = _node_expression3(state)) != null) {
323 node.push(x);
324 } else {
325 state.y = y2;
326 state.x = x2;
327 node.length = ln2;
328 break loop_2;
329 }
330
331 var y4 = state.y,
332 x4 = state.x;
333
334 if ((x = _node_expression4(state)) != null) {
335 node.push(x);
336 } else {
337 state.y = y4;
338 state.x = x4;
339 }
340
341 if ((x = _node_expression5(state)) != null) {
342 node.push(x);
343 } else {
344 state.y = y2;
345 state.x = x2;
346 node.length = ln2;
347 break loop_2;
348 }
349 }
350 }
351
352 node.tag = 'node';
353 return node;
354};"
355`;
356
357exports[`works with transform functions 1`] = `
358"import { match, __pattern as _pattern } from 'reghex';
359
360var _inner_transform = x => x;
361
362const first = function (state) {
363 var y1 = state.y,
364 x1 = state.x;
365 var node = [];
366 var x;
367 node.tag = 'inner';
368 return _inner_transform(node);
369};
370
371const transform = x => x;
372
373const second = function (state) {
374 var y1 = state.y,
375 x1 = state.x;
376 var node = [];
377 var x;
378 node.tag = 'node';
379 return transform(node);
380};"
381`;