tangled
alpha
login
or
join now
kitten.sh
/
reghex
Mirror: The magical sticky regex-based parser generator 🧙
0
fork
atom
overview
issues
pulls
pipelines
Add test for self-referential case
kitten.sh
5 years ago
ae71ec9f
99cab606
+38
-10
2 changed files
expand all
collapse all
unified
split
src
babel
__snapshots__
plugin.test.js.snap
plugin.test.js
+35
-7
src/babel/__snapshots__/plugin.test.js.snap
···
130
130
};"
131
131
`;
132
132
133
133
-
exports[`works with self-referential thuns 1`] = `
133
133
+
exports[`works with self-referential thunks 1`] = `
134
134
"import { match, tag, _exec, _pattern } from 'reghex';
135
135
-
const inner = m('inner')\`
136
136
-
\${() => node}
137
137
-
\`;
138
138
-
const node = m('node')\`
139
139
-
\${inner}
140
140
-
\`;"
135
135
+
136
136
+
var _inner_expression = _pattern(() => node);
137
137
+
138
138
+
const inner = function (state) {
139
139
+
var index_1 = state.index;
140
140
+
var node = [];
141
141
+
var match;
142
142
+
143
143
+
if (match = _exec(state, _inner_expression)) {
144
144
+
node.push(match);
145
145
+
} else {
146
146
+
state.index = index_1;
147
147
+
return;
148
148
+
}
149
149
+
150
150
+
node.tag = 'inner';
151
151
+
return node;
152
152
+
};
153
153
+
154
154
+
const node = function (state) {
155
155
+
var index_1 = state.index;
156
156
+
var node = [];
157
157
+
var match;
158
158
+
159
159
+
if (match = inner(state)) {
160
160
+
node.push(match);
161
161
+
} else {
162
162
+
state.index = index_1;
163
163
+
return;
164
164
+
}
165
165
+
166
166
+
node.tag = 'node';
167
167
+
return node;
168
168
+
};"
141
169
`;
142
170
143
171
exports[`works with standard features 1`] = `
+3
-3
src/babel/plugin.test.js
···
54
54
).toMatchSnapshot();
55
55
});
56
56
57
57
-
it('works with self-referential thuns', () => {
57
57
+
it('works with self-referential thunks', () => {
58
58
const code = `
59
59
import { match, tag } from 'reghex';
60
60
61
61
-
const inner = m('inner')\`
61
61
+
const inner = match('inner')\`
62
62
\${() => node}
63
63
\`;
64
64
65
65
-
const node = m('node')\`
65
65
+
const node = match('node')\`
66
66
\${inner}
67
67
\`;
68
68
`;