Some cosmetic changes
- Remove unused '__slice' variable - Nicely indent a map/concat chain - 'forEach' instead of 'map' in emitted code
This commit is contained in:
parent
f5b323b401
commit
75a4101622
|
@ -127,15 +127,18 @@ function generateJS( ast, options ) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ast.literals.map(
|
return ast.literals
|
||||||
( c, i ) => "var " + l( i ) + " = " + buildLiteral( c ) + ";"
|
.map( ( c, i ) => "var " + l( i ) + " = " + buildLiteral( c ) + ";" )
|
||||||
).concat( "", ast.classes.map(
|
.concat( "", ast.classes.map(
|
||||||
( c, i ) => "var " + r( i ) + " = " + buildRegexp( c ) + ";" )
|
( c, i ) => "var " + r( i ) + " = " + buildRegexp( c ) + ";"
|
||||||
).concat( "", ast.expectations.map(
|
) )
|
||||||
( c, i ) => "var " + e( i ) + " = " + buildExpectation( c ) + ";" )
|
.concat( "", ast.expectations.map(
|
||||||
).concat( "", ast.functions.map(
|
( c, i ) => "var " + e( i ) + " = " + buildExpectation( c ) + ";"
|
||||||
( c, i ) => "var " + f( i ) + " = " + buildFunc( c ) + ";"
|
) )
|
||||||
) ).join( "\n" );
|
.concat( "", ast.functions.map(
|
||||||
|
( c, i ) => "var " + f( i ) + " = " + buildFunc( c ) + ";"
|
||||||
|
) )
|
||||||
|
.join( "\n" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +182,7 @@ function generateJS( ast, options ) {
|
||||||
"",
|
"",
|
||||||
" rule$expectations = cached.expectations;",
|
" rule$expectations = cached.expectations;",
|
||||||
" if (peg$silentFails === 0) {",
|
" if (peg$silentFails === 0) {",
|
||||||
" rule$expectations.map(peg$expect);",
|
" rule$expectations.forEach(peg$expect);",
|
||||||
" }",
|
" }",
|
||||||
""
|
""
|
||||||
].join( "\n" ) );
|
].join( "\n" ) );
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const __hasOwnProperty = Object.prototype.hasOwnProperty;
|
const __hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||||
const __slice = Array.prototype.slice;
|
|
||||||
|
|
||||||
const objects = {
|
const objects = {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue