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
43const inner = function (state) {
44 var index_1 = state.index;
45 var node = [];
46 var match;
47
48 if (match = _exec(state, \\"inner\\")) {
49 node.push(match);
50 } else {
51 state.index = index_1;
52 return;
53 }
54
55 node.tag = 'inner';
56 return node;
57};
58
59const node = function (state) {
60 var index_1 = state.index;
61 var node = [];
62 var match;
63
64 if (match = inner(state)) {
65 node.push(match);
66 } else {
67 state.index = index_1;
68 return;
69 }
70
71 node.tag = 'node';
72 return node;
73};"
74`;
75
76exports[`works with non-capturing groups 1`] = `
77"import { match, _exec, _pattern, tag as _tag } from 'reghex';
78
79var _node_expression = _pattern(1),
80 _node_expression2 = _pattern(2),
81 _node_expression3 = _pattern(3);
82
83const node = function (state) {
84 var index_1 = state.index;
85 var node = [];
86 var match;
87
88 if (match = _exec(state, _node_expression)) {
89 node.push(match);
90 } else {
91 state.index = index_1;
92 return;
93 }
94
95 var length_2 = node.length;
96
97 alternation_3: {
98 block_3: {
99 var index_3 = state.index;
100
101 if (match = _exec(state, _node_expression2)) {
102 node.push(match);
103 } else {
104 state.index = index_3;
105 node.length = length_2;
106 break block_3;
107 }
108
109 break alternation_3;
110 }
111
112 loop_3: for (var count_3 = 0; true; count_3++) {
113 var index_3 = state.index;
114
115 if (!_exec(state, _node_expression3)) {
116 if (count_3) {
117 state.index = index_3;
118 break loop_3;
119 } else {}
120
121 state.index = index_1;
122 node.length = length_2;
123 return;
124 }
125 }
126 }
127
128 node.tag = 'node';
129 return node;
130};"
131`;
132
133exports[`works with standard features 1`] = `
134"import { match, _exec, _pattern, tag as _tag } from \\"reghex\\";
135
136var _node_expression = _pattern(1),
137 _node_expression2 = _pattern(2),
138 _node_expression3 = _pattern(3),
139 _node_expression4 = _pattern(4),
140 _node_expression5 = _pattern(5);
141
142const node = function (state) {
143 var index_1 = state.index;
144 var node = [];
145 var match;
146
147 alternation_2: {
148 block_2: {
149 var index_2 = state.index;
150
151 loop_2: for (var count_2 = 0; true; count_2++) {
152 var index_2 = state.index;
153
154 if (match = _exec(state, _node_expression)) {
155 node.push(match);
156 } else {
157 if (count_2) {
158 state.index = index_2;
159 break loop_2;
160 } else {}
161
162 state.index = index_2;
163 break block_2;
164 }
165 }
166
167 break alternation_2;
168 }
169
170 loop_2: for (var count_2 = 0; true; count_2++) {
171 var index_2 = state.index;
172
173 if (match = _exec(state, _node_expression2)) {
174 node.push(match);
175 } else {
176 if (count_2) {
177 state.index = index_2;
178 break loop_2;
179 } else {}
180
181 state.index = index_1;
182 return;
183 }
184 }
185
186 loop_2: while (true) {
187 var index_2 = state.index;
188 var length_2 = node.length;
189
190 if (match = _exec(state, _node_expression3)) {
191 node.push(match);
192 } else {
193 state.index = index_2;
194 node.length = length_2;
195 break loop_2;
196 }
197
198 var index_4 = state.index;
199
200 if (match = _exec(state, _node_expression4)) {
201 node.push(match);
202 } else {
203 state.index = index_4;
204 }
205
206 if (match = _exec(state, _node_expression5)) {
207 node.push(match);
208 } else {
209 state.index = index_2;
210 node.length = length_2;
211 break loop_2;
212 }
213 }
214 }
215
216 node.tag = 'node';
217 return node;
218};"
219`;
220
221exports[`works with transform functions 1`] = `
222"import { match, _exec, _pattern, tag as _tag } from 'reghex';
223
224var _inner_transform = x => x;
225
226const first = function (state) {
227 var index_1 = state.index;
228 var node = [];
229 var match;
230 node.tag = 'inner';
231 return _inner_transform(node);
232};
233
234const transform = x => x;
235
236const second = function (state) {
237 var index_1 = state.index;
238 var node = [];
239 var match;
240 node.tag = 'node';
241 return transform(node);
242};"
243`;