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
··· 328 328 break group_2; 329 329 } 330 330 331 - group_4: { 332 - var y4 = state.y, 333 - x4 = state.x; 331 + var y4 = state.y, 332 + x4 = state.x; 334 333 335 - if ((x = _node_expression4(state)) != null) { 336 - node.push(x); 337 - } else { 338 - state.y = y4; 339 - state.x = x4; 340 - node.length = ln2; 341 - break group_4; 342 - } 334 + if ((x = _node_expression4(state)) != null) { 335 + node.push(x); 336 + } else { 337 + state.y = y4; 338 + state.x = x4; 343 339 } 344 340 345 341 if ((x = _node_expression5(state)) != null) {
+8
src/codegen.js
··· 98 98 ${astChild(ast, depth, opts)} 99 99 } 100 100 `; 101 + } else if (ast.quantifier === '?' && ast.expression) { 102 + opts.index = depth; 103 + opts.abort = ''; 104 + 105 + child = js` 106 + ${assignIndex(depth)} 107 + ${astChild(ast, depth, opts)} 108 + `; 101 109 } else if (ast.quantifier === '?') { 102 110 opts.index = depth; 103 111 opts.abort = js`break ${group}`;