1// Jest Snapshot v1, https://goo.gl/fbAQLP
2
3exports[`works together with @babel/plugin-transform-modules-commonjs 1`] = `
4"\\"use strict\\";
5
6var _reghex = require(\\"reghex\\");
7
8var _node_expression = (0, _reghex._pattern)(1),
9 _node_expression2 = (0, _reghex._pattern)(2);
10
11const node = function (state) {
12 var index_1 = state.index;
13 var node = [];
14 var match;
15
16 if (match = (0, _reghex._exec)(state, _node_expression)) {
17 node.push(match);
18 } else {
19 state.index = index_1;
20 return;
21 }
22
23 if (match = (0, _reghex._exec)(state, _node_expression2)) {
24 node.push(match);
25 } else {
26 state.index = index_1;
27 return;
28 }
29
30 node.tag = 'node';
31 return node;
32};"
33`;
34
35exports[`works while only minifying 1`] = `
36"import { match } from 'reghex/macro';
37const node = match('node')([\\"\\", \\"+|\\", \\"+(\\", \\"(\\", \\"?\\", \\"))*\\"], 1, 2, 3, 4, 5);"
38`;
39
40exports[`works with local recursion 1`] = `
41"import { match as m, tag, _exec, _pattern } from 'reghex';
42
43var _inner_expression = _pattern(/inner/);
44
45const inner = function (state) {
46 var index_1 = state.index;
47 var node = [];
48 var match;
49
50 if (match = _exec(state, _inner_expression)) {
51 node.push(match);
52 } else {
53 state.index = index_1;
54 return;
55 }
56
57 node.tag = 'inner';
58 return node;
59};
60
61const node = function (state) {
62 var index_1 = state.index;
63 var node = [];
64 var match;
65
66 if (match = inner(state)) {
67 node.push(match);
68 } else {
69 state.index = index_1;
70 return;
71 }
72
73 node.tag = 'node';
74 return node;
75};"
76`;
77
78exports[`works with non-capturing groups 1`] = `
79"import { match, _exec, _pattern, tag as _tag } from 'reghex';
80
81var _node_expression = _pattern(1),
82 _node_expression2 = _pattern(2),
83 _node_expression3 = _pattern(3);
84
85const node = function (state) {
86 var index_1 = state.index;
87 var node = [];
88 var match;
89
90 if (match = _exec(state, _node_expression)) {
91 node.push(match);
92 } else {
93 state.index = index_1;
94 return;
95 }
96
97 var length_2 = node.length;
98
99 alternation_3: {
100 block_3: {
101 var index_3 = state.index;
102
103 if (match = _exec(state, _node_expression2)) {
104 node.push(match);
105 } else {
106 state.index = index_3;
107 node.length = length_2;
108 break block_3;
109 }
110
111 break alternation_3;
112 }
113
114 loop_3: for (var count_3 = 0; true; count_3++) {
115 var index_3 = state.index;
116
117 if (!_exec(state, _node_expression3)) {
118 if (count_3) {
119 state.index = index_3;
120 break loop_3;
121 } else {}
122
123 state.index = index_1;
124 node.length = length_2;
125 return;
126 }
127 }
128 }
129
130 node.tag = 'node';
131 return node;
132};"
133`;
134
135exports[`works with self-referential thunks 1`] = `
136"import { match, tag, _exec, _pattern } from 'reghex';
137
138const inner = function (state) {
139 var index_1 = state.index;
140 var node = [];
141 var match;
142
143 if (match = node(state)) {
144 node.push(match);
145 } else {
146 state.index = index_1;
147 return;
148 }
149
150 node.tag = 'inner';
151 return node;
152};
153
154const node = function (state) {
155 var index_1 = state.index;
156 var node = [];
157 var match;
158
159 if (match = inner(state)) {
160 node.push(match);
161 } else {
162 state.index = index_1;
163 return;
164 }
165
166 node.tag = 'node';
167 return node;
168};"
169`;
170
171exports[`works with standard features 1`] = `
172"import { match, _exec, _pattern, tag as _tag } from \\"reghex\\";
173
174var _node_expression = _pattern(1),
175 _node_expression2 = _pattern(2),
176 _node_expression3 = _pattern(3),
177 _node_expression4 = _pattern(4),
178 _node_expression5 = _pattern(5);
179
180const node = function (state) {
181 var index_1 = state.index;
182 var node = [];
183 var match;
184
185 alternation_2: {
186 block_2: {
187 var index_2 = state.index;
188
189 loop_2: for (var count_2 = 0; true; count_2++) {
190 var index_2 = state.index;
191
192 if (match = _exec(state, _node_expression)) {
193 node.push(match);
194 } else {
195 if (count_2) {
196 state.index = index_2;
197 break loop_2;
198 } else {}
199
200 state.index = index_2;
201 break block_2;
202 }
203 }
204
205 break alternation_2;
206 }
207
208 loop_2: for (var count_2 = 0; true; count_2++) {
209 var index_2 = state.index;
210
211 if (match = _exec(state, _node_expression2)) {
212 node.push(match);
213 } else {
214 if (count_2) {
215 state.index = index_2;
216 break loop_2;
217 } else {}
218
219 state.index = index_1;
220 return;
221 }
222 }
223
224 loop_2: while (true) {
225 var index_2 = state.index;
226 var length_2 = node.length;
227
228 if (match = _exec(state, _node_expression3)) {
229 node.push(match);
230 } else {
231 state.index = index_2;
232 node.length = length_2;
233 break loop_2;
234 }
235
236 var index_4 = state.index;
237
238 if (match = _exec(state, _node_expression4)) {
239 node.push(match);
240 } else {
241 state.index = index_4;
242 }
243
244 if (match = _exec(state, _node_expression5)) {
245 node.push(match);
246 } else {
247 state.index = index_2;
248 node.length = length_2;
249 break loop_2;
250 }
251 }
252 }
253
254 node.tag = 'node';
255 return node;
256};"
257`;
258
259exports[`works with transform functions 1`] = `
260"import { match, _exec, _pattern, tag as _tag } from 'reghex';
261
262var _inner_transform = x => x;
263
264const first = function (state) {
265 var index_1 = state.index;
266 var node = [];
267 var match;
268 node.tag = 'inner';
269 return _inner_transform(node);
270};
271
272const transform = x => x;
273
274const second = function (state) {
275 var index_1 = state.index;
276 var node = [];
277 var match;
278 node.tag = 'node';
279 return transform(node);
280};"
281`;