tangled
alpha
login
or
join now
kitten.sh
/
reghex
0
fork
atom
Mirror: The magical sticky regex-based parser generator 🧙
0
fork
atom
overview
issues
pulls
pipelines
Improve codegen.js output for astExpression()
kitten.sh
5 years ago
567d1daa
247e15c0
+12
-6
2 changed files
expand all
collapse all
unified
split
src
babel
__snapshots__
plugin.test.js.snap
codegen.js
+2
-2
src/babel/__snapshots__/plugin.test.js.snap
···
185
185
break alt_3;
186
186
}
187
187
188
188
-
if ((x = _node_expression3(state)) != null) {} else {
188
188
+
if ((x = _node_expression3(state)) == null) {
189
189
state.y = y1;
190
190
state.x = x1;
191
191
node.length = ln2;
···
196
196
var y3 = state.y,
197
197
x3 = state.x;
198
198
199
199
-
if ((x = _node_expression3(state)) != null) {} else {
199
199
+
if ((x = _node_expression3(state)) == null) {
200
200
state.y = y3;
201
201
state.x = x3;
202
202
break loop_3;
+10
-4
src/codegen.js
···
30
30
const restoreLength =
31
31
(opts.length && opts.abort && js`${_node}.length = ln${opts.length};`) ||
32
32
'';
33
33
-
const expression = `${ast.expression.id}(${_state})`;
33
33
+
const condition = `(${_match} = ${ast.expression.id}(${_state})) ${
34
34
+
capture ? '!=' : '=='
35
35
+
} null`;
34
36
return js`
35
35
-
if ((${_match} = ${ast.expression.id}(${_state})) != null) {
36
36
-
${capture ? js`${_node}.push(${_match})` : ''}
37
37
-
} else {
37
37
+
if (${condition}) ${
38
38
+
capture
39
39
+
? js`{
40
40
+
${_node}.push(${_match});
41
41
+
} else `
42
42
+
: ''
43
43
+
}{
38
44
${restoreIndex(opts.index)}
39
45
${restoreLength}
40
46
${opts.abort}