Mirror: The magical sticky regex-based parser generator 🧙

Add special case to keep codegen output small

Changed files
+15 -11
src
babel
__snapshots__
+7 -11
src/babel/__snapshots__/plugin.test.js.snap
···
break group_2;
}
-
group_4: {
-
var y4 = state.y,
-
x4 = state.x;
+
var y4 = state.y,
+
x4 = state.x;
-
if ((x = _node_expression4(state)) != null) {
-
node.push(x);
-
} else {
-
state.y = y4;
-
state.x = x4;
-
node.length = ln2;
-
break group_4;
-
}
+
if ((x = _node_expression4(state)) != null) {
+
node.push(x);
+
} else {
+
state.y = y4;
+
state.x = x4;
}
if ((x = _node_expression5(state)) != null) {
+8
src/codegen.js
···
${astChild(ast, depth, opts)}
}
`;
+
} else if (ast.quantifier === '?' && ast.expression) {
+
opts.index = depth;
+
opts.abort = '';
+
+
child = js`
+
${assignIndex(depth)}
+
${astChild(ast, depth, opts)}
+
`;
} else if (ast.quantifier === '?') {
opts.index = depth;
opts.abort = js`break ${group}`;