Mirror: The magical sticky regex-based parser generator 🧙
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove object-spread from codegen.js

+55 -45
-1
package.json
··· 51 51 "@ampproject/rollup-plugin-closure-compiler": "^0.26.0", 52 52 "@babel/core": "7.9.6", 53 53 "@babel/plugin-transform-modules-commonjs": "^7.9.6", 54 - "@babel/plugin-transform-object-assign": "^7.8.3", 55 54 "@rollup/plugin-buble": "^0.21.3", 56 55 "@rollup/plugin-commonjs": "^11.1.0", 57 56 "@rollup/plugin-node-resolve": "^7.1.3",
+2 -5
rollup.config.js
··· 22 22 unicodeRegExp: false, 23 23 dangerousForOf: true, 24 24 templateString: false, 25 + spreadRest: false, 25 26 }, 26 - objectAssign: 'Object.assign', 27 27 exclude: 'node_modules/**', 28 28 }), 29 29 babel({ ··· 31 31 extensions: ['ts', 'tsx', 'js'], 32 32 exclude: 'node_modules/**', 33 33 presets: [], 34 - plugins: [ 35 - '@babel/plugin-transform-object-assign', 36 - 'babel-plugin-closure-elimination', 37 - ], 34 + plugins: ['babel-plugin-closure-elimination'], 38 35 }), 39 36 ]; 40 37
+53 -32
src/codegen.js
··· 9 9 return body.trim(); 10 10 } 11 11 12 + const newOpts = (prev, next) => ({ 13 + index: next.index != null ? next.index : prev.index, 14 + length: next.length != null ? next.length : prev.length, 15 + onAbort: onAbort.length != null ? onAbort.length : onAbort.length, 16 + abort: abort.length != null ? abort.length : abort.length, 17 + capturing: capturing.length != null ? capturing.length : capturing.length, 18 + }); 19 + 12 20 const assignIndex = (depth) => 13 21 depth ? js`var index_${depth} = ${_state}.index;` : ''; 14 22 ··· 66 74 if (!opts.length && capturing) { 67 75 return js` 68 76 ${js`var length_${depth} = ${_node}.length;`} 69 - ${astSequence(ast.sequence, depth + 1, { 70 - ...opts, 71 - length: depth, 72 - capturing, 73 - })} 77 + ${astSequence( 78 + ast.sequence, 79 + depth + 1, 80 + newOpts(opts, { 81 + length: depth, 82 + capturing, 83 + }) 84 + )} 74 85 `; 75 86 } 76 87 77 - return astSequence(ast.sequence, depth + 1, { 78 - ...opts, 79 - capturing, 80 - }); 88 + return astSequence( 89 + ast.sequence, 90 + depth + 1, 91 + newOpts(opts, { 92 + capturing, 93 + }) 94 + ); 81 95 }; 82 96 83 97 const astChild = (ast, depth, opts) => ··· 91 105 return js` 92 106 ${label}: for (var ${count} = 0; true; ${count}++) { 93 107 ${assignIndex(depth)} 94 - ${astChild(ast, depth, { 95 - ...opts, 96 - onAbort: js` 108 + ${astChild( 109 + ast, 110 + depth, 111 + newOpts(opts, { 112 + onAbort: js` 97 113 if (${count}) { 98 114 ${restoreIndex(depth)} 99 115 break ${label}; ··· 101 117 ${opts.onAbort || ''} 102 118 } 103 119 `, 104 - })} 120 + }) 121 + )} 105 122 } 106 123 `; 107 124 }; ··· 111 128 return js` 112 129 ${label}: while (true) { 113 130 ${assignIndex(depth)} 114 - ${astChild(ast, depth, { 115 - ...opts, 116 - length: 0, 117 - index: depth, 118 - abort: js`break ${label};`, 119 - onAbort: '', 120 - })} 131 + ${astChild( 132 + ast, 133 + depth, 134 + newOpts(opts, { 135 + length: 0, 136 + index: depth, 137 + abort: js`break ${label};`, 138 + onAbort: '', 139 + }) 140 + )} 121 141 } 122 142 `; 123 143 }; 124 144 125 145 const astOptional = (ast, depth, opts) => js` 126 146 ${assignIndex(depth)} 127 - ${astChild(ast, depth, { 128 - ...opts, 129 - index: depth, 130 - abort: '', 131 - onAbort: '', 132 - })} 147 + ${astChild( 148 + ast, 149 + depth, 150 + newOpts(opts, { 151 + index: depth, 152 + abort: '', 153 + onAbort: '', 154 + }) 155 + )} 133 156 `; 134 157 135 158 const astQuantifier = (ast, depth, opts) => { ··· 137 160 const label = `invert_${depth}`; 138 161 139 162 if (ast.lookahead === 'negative') { 140 - opts = { 141 - ...opts, 163 + opts = newOpts(opts, { 142 164 index: depth, 143 165 abort: js`break ${label};`, 144 - }; 166 + }); 145 167 } 146 168 147 169 let child; ··· 181 203 182 204 let childOpts = opts; 183 205 if (ast.alternation) { 184 - childOpts = { 185 - ...childOpts, 206 + childOpts = newOpts(opts, { 186 207 index: depth, 187 208 abort: js`break ${block};`, 188 209 onAbort: '', 189 - }; 210 + }); 190 211 } 191 212 192 213 let sequence = '';
-7
yarn.lock
··· 250 250 "@babel/helper-simple-access" "^7.8.3" 251 251 babel-plugin-dynamic-import-node "^2.3.3" 252 252 253 - "@babel/plugin-transform-object-assign@^7.8.3": 254 - version "7.8.3" 255 - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-assign/-/plugin-transform-object-assign-7.8.3.tgz#dc3b8dd50ef03837868a37b7df791f64f288538e" 256 - integrity sha512-i3LuN8tPDqUCRFu3dkzF2r1Nx0jp4scxtm7JxtIqI9he9Vk20YD+/zshdzR9JLsoBMlJlNR82a62vQExNEVx/Q== 257 - dependencies: 258 - "@babel/helper-plugin-utils" "^7.8.3" 259 - 260 253 "@babel/template@^7.3.3", "@babel/template@^7.8.3", "@babel/template@^7.8.6": 261 254 version "7.8.6" 262 255 resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.8.6.tgz#86b22af15f828dfb086474f964dcc3e39c43ce2b"