Fix comma-dangle warning from ESLint

master
Futago-za Ryuu 4 年之前
父節點 56722b6d41
當前提交 b7b87ea8ae

@ -254,7 +254,7 @@ function generateBytecode( ast, session ) {
return condCode.concat(
[ thenCode.length, elseCode.length ],
thenCode,
elseCode
elseCode,
);
}
@ -291,14 +291,14 @@ function generateBytecode( ast, session ) {
buildSequence(
[ op.POP ],
[ negative ? op.POP : op.POP_CURR_POS ],
[ op.PUSH_UNDEFINED ]
[ op.PUSH_UNDEFINED ],
),
buildSequence(
[ op.POP ],
[ negative ? op.POP_CURR_POS : op.POP ],
[ op.PUSH_FAILED ]
)
)
[ op.PUSH_FAILED ],
),
),
);
}
@ -314,8 +314,8 @@ function generateBytecode( ast, session ) {
node.match|0,
[ op.IF ],
buildSequence( [ op.POP ], negative ? [ op.PUSH_FAILED ] : [ op.PUSH_UNDEFINED ] ),
buildSequence( [ op.POP ], negative ? [ op.PUSH_UNDEFINED ] : [ op.PUSH_FAILED ] )
)
buildSequence( [ op.POP ], negative ? [ op.PUSH_UNDEFINED ] : [ op.PUSH_FAILED ] ),
),
);
}
@ -324,7 +324,7 @@ function generateBytecode( ast, session ) {
return buildLoop(
[ op.WHILE_NOT_ERROR ],
buildSequence( [ op.APPEND ], expressionCode )
buildSequence( [ op.APPEND ], expressionCode ),
);
}
@ -355,7 +355,7 @@ function generateBytecode( ast, session ) {
// Do not generate unused constant, if no need it
const nameIndex = context.reportFailures ? addExpectedConst(
{ type: "rule", value: node.name }
{ type: "rule", value: node.name },
) : null;
const expressionCode = generate( node.expression, {
sp: context.sp,
@ -369,7 +369,7 @@ function generateBytecode( ast, session ) {
[ op.EXPECT, nameIndex ],
[ op.SILENT_FAILS_ON ],
expressionCode,
[ op.SILENT_FAILS_OFF ]
[ op.SILENT_FAILS_OFF ],
) : expressionCode;
},
@ -393,10 +393,10 @@ function generateBytecode( ast, session ) {
[ op.IF_ERROR ],
buildSequence(
[ op.POP ],
buildAlternativesCode( alternatives.slice( 1 ), context )
buildAlternativesCode( alternatives.slice( 1 ), context ),
),
[]
)
[],
),
);
}
@ -430,11 +430,11 @@ function generateBytecode( ast, session ) {
[ op.IF_NOT_ERROR ],
buildSequence(
[ op.LOAD_SAVED_POS, 1 ],
buildCall( functionIndex, 1, env, context.sp + 2 )
buildCall( functionIndex, 1, env, context.sp + 2 ),
),
[]
[],
),
[ op.NIP ]
[ op.NIP ],
);
},
@ -470,9 +470,9 @@ function generateBytecode( ast, session ) {
buildSequence(
processedCount > 1 ? [ op.POP_N, processedCount ] : [ op.POP ],
[ op.POP_CURR_POS ],
[ op.PUSH_FAILED ]
)
)
[ op.PUSH_FAILED ],
),
),
);
}
@ -481,7 +481,7 @@ function generateBytecode( ast, session ) {
return buildSequence(
[ op.PLUCK, TOTAL_ELEMENTS + 1, context.pluck.length ],
context.pluck.map( eSP => context.sp - eSP )
context.pluck.map( eSP => context.sp - eSP ),
);
if ( context.action )
@ -492,12 +492,12 @@ function generateBytecode( ast, session ) {
addFunctionConst( // functionIndex
false,
Object.keys( context.env ),
context.action.code
context.action.code,
),
TOTAL_ELEMENTS + 1,
context.env,
context.sp
)
context.sp,
),
);
return buildSequence( [ op.WRAP, TOTAL_ELEMENTS ], [ op.NIP ] );
@ -512,7 +512,7 @@ function generateBytecode( ast, session ) {
pluck: [],
action: context.action,
reportFailures: context.reportFailures,
} )
} ),
);
},
@ -557,8 +557,8 @@ function generateBytecode( ast, session ) {
node.expression.match|0,
[ op.IF_NOT_ERROR ],
buildSequence( [ op.POP ], [ op.TEXT ] ),
[ op.NIP ]
)
[ op.NIP ],
),
);
},
@ -589,8 +589,8 @@ function generateBytecode( ast, session ) {
-( node.expression.match|0 ),
[ op.IF_ERROR ],
buildSequence( [ op.POP ], [ op.PUSH_NULL ] ),
[]
)
[],
),
);
},
@ -608,7 +608,7 @@ function generateBytecode( ast, session ) {
[ op.PUSH_EMPTY_ARRAY ],
expressionCode,
buildAppendLoop( expressionCode ),
[ op.POP ]
[ op.POP ],
);
},
@ -629,8 +629,8 @@ function generateBytecode( ast, session ) {
node.expression.match|0,
[ op.IF_NOT_ERROR ],
buildSequence( buildAppendLoop( expressionCode ), [ op.POP ] ),
buildSequence( [ op.POP ], [ op.POP ], [ op.PUSH_FAILED ] )
)
buildSequence( [ op.POP ], [ op.POP ], [ op.PUSH_FAILED ] ),
),
);
},
@ -671,7 +671,7 @@ function generateBytecode( ast, session ) {
const match = node.match|0;
const needConst = match === 0 || ( match > 0 && ! node.ignoreCase );
const stringIndex = needConst ? addLiteralConst(
node.ignoreCase ? node.value.toLowerCase() : node.value
node.ignoreCase ? node.value.toLowerCase() : node.value,
) : null;
// Do not generate unused constant, if no need it
const expectedIndex = context.reportFailures ? addExpectedConst( {
@ -693,8 +693,8 @@ function generateBytecode( ast, session ) {
node.ignoreCase
? [ op.ACCEPT_N, node.value.length ]
: [ op.ACCEPT_STRING, stringIndex ],
[ op.PUSH_FAILED ]
)
[ op.PUSH_FAILED ],
),
);
}
@ -721,8 +721,8 @@ function generateBytecode( ast, session ) {
match,
[ op.MATCH_CLASS, classIndex ],
[ op.ACCEPT_N, 1 ],
[ op.PUSH_FAILED ]
)
[ op.PUSH_FAILED ],
),
);
},
@ -740,8 +740,8 @@ function generateBytecode( ast, session ) {
node.match|0,
[ op.MATCH_ANY ],
[ op.ACCEPT_N, 1 ],
[ op.PUSH_FAILED ]
)
[ op.PUSH_FAILED ],
),
);
},

@ -147,13 +147,13 @@ function generateJS( ast, session, options ) {
return ast.literals
.map( ( c, i ) => "var " + l( i ) + " = " + buildLiteral( c ) + ";" )
.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 ) + ";"
( c, i ) => "var " + e( i ) + " = " + buildExpectation( c ) + ";",
) )
.concat( "", ast.functions.map(
( c, i ) => "var " + f( i ) + " = " + buildFunc( c ) + ";"
( c, i ) => "var " + f( i ) + " = " + buildFunc( c ) + ";",
) )
.join( "\n" );
@ -492,15 +492,15 @@ function generateJS( ast, session, options ) {
" case " + op.IF_ERROR + ":", // IF_ERROR t, f
indent10( generateCondition(
"stack[stack.length - 1] === peg$FAILED",
0
0,
) ),
"",
" case " + op.IF_NOT_ERROR + ":", // IF_NOT_ERROR t, f
indent10(
generateCondition(
"stack[stack.length - 1] !== peg$FAILED",
0
)
0,
),
),
"",
" case " + op.WHILE_NOT_ERROR + ":", // WHILE_NOT_ERROR b
@ -512,19 +512,19 @@ function generateJS( ast, session, options ) {
" case " + op.MATCH_STRING + ":", // MATCH_STRING s, a, f, ...
indent10( generateCondition(
"input.substr(peg$currPos, peg$literals[bc[ip + 1]].length) === peg$literals[bc[ip + 1]]",
1
1,
) ),
"",
" case " + op.MATCH_STRING_IC + ":", // MATCH_STRING_IC s, a, f, ...
indent10( generateCondition(
"input.substr(peg$currPos, peg$literals[bc[ip + 1]].length).toLowerCase() === peg$literals[bc[ip + 1]]",
1
1,
) ),
"",
" case " + op.MATCH_CLASS + ":", // MATCH_CLASS c, a, f, ...
indent10( generateCondition(
"peg$regexps[bc[ip + 1]].test(input.charAt(peg$currPos))",
1
1,
) ),
"",
" case " + op.ACCEPT_N + ":", // ACCEPT_N n
@ -697,7 +697,7 @@ function generateJS( ast, session, options ) {
session.fatal(
"Rule '" + rule.name + "', position " + pos + ": "
+ "Branches of a condition can't move the stack pointer differently "
+ "(before: " + baseSp + ", after then: " + thenSp + ", after else: " + elseSp + ")."
+ "(before: " + baseSp + ", after then: " + thenSp + ", after else: " + elseSp + ").",
);
}
@ -735,7 +735,7 @@ function generateJS( ast, session, options ) {
session.fatal(
"Rule '" + rule.name + "', position " + pos + ": "
+ "Body of a loop can't move the stack pointer "
+ "(before: " + baseSp + ", after: " + bodySp + ")."
+ "(before: " + baseSp + ", after: " + bodySp + ").",
);
}
@ -829,14 +829,14 @@ function generateJS( ast, session, options ) {
case op.WRAP: // WRAP n
parts.push(
stack.push( "[" + stack.pop( bc[ ip + 1 ] ).join( ", " ) + "]" )
stack.push( "[" + stack.pop( bc[ ip + 1 ] ).join( ", " ) + "]" ),
);
ip += 2;
break;
case op.TEXT: // TEXT
parts.push(
stack.push( "input.substring(" + stack.pop() + ", peg$currPos)" )
stack.push( "input.substring(" + stack.pop() + ", peg$currPos)" ),
);
ip++;
break;
@ -886,7 +886,7 @@ function generateJS( ast, session, options ) {
+ l( bc[ ip + 1 ] )
: "input.charCodeAt(peg$currPos) === "
+ ast.literals[ bc[ ip + 1 ] ].charCodeAt( 0 )
, 1
, 1,
);
break;
@ -896,7 +896,7 @@ function generateJS( ast, session, options ) {
+ ast.literals[ bc[ ip + 1 ] ].length
+ ").toLowerCase() === "
+ l( bc[ ip + 1 ] )
, 1
, 1,
);
break;
@ -908,12 +908,12 @@ function generateJS( ast, session, options ) {
parts.push( stack.push(
bc[ ip + 1 ] > 1
? "input.substr(peg$currPos, " + bc[ ip + 1 ] + ")"
: "input.charAt(peg$currPos)"
: "input.charAt(peg$currPos)",
) );
parts.push(
bc[ ip + 1 ] > 1
? "peg$currPos += " + bc[ ip + 1 ] + ";"
: "peg$currPos++;"
: "peg$currPos++;",
);
ip += 2;
break;
@ -923,7 +923,7 @@ function generateJS( ast, session, options ) {
parts.push(
ast.literals[ bc[ ip + 1 ] ].length > 1
? "peg$currPos += " + ast.literals[ bc[ ip + 1 ] ].length + ";"
: "peg$currPos++;"
: "peg$currPos++;",
);
ip += 2;
break;
@ -976,7 +976,7 @@ function generateJS( ast, session, options ) {
default:
session.fatal(
"Rule '" + rule.name + "', position " + ip + ": "
+ "Invalid opcode " + bc[ ip ] + "."
+ "Invalid opcode " + bc[ ip ] + ".",
);
}
@ -1007,12 +1007,12 @@ function generateJS( ast, session, options ) {
parts.push( indent2( generateRuleHeader(
"\"" + util.stringEscape( rule.name ) + "\"",
ast.indexOfRule( rule.name )
ast.indexOfRule( rule.name ),
) ) );
parts.push( indent2( code ) );
parts.push( indent2( generateRuleFooter(
"\"" + util.stringEscape( rule.name ) + "\"",
s( 0 )
s( 0 ),
) ) );
parts.push( "}" );
@ -1746,7 +1746,7 @@ function generateJS( ast, session, options ) {
parts.push(
generateHeaderComment(),
""
"",
);
if ( dependencyVars.length > 0 ) {
@ -1769,7 +1769,7 @@ function generateJS( ast, session, options ) {
"export " + generateParserExports() + ";",
"",
"export default " + generateParserObject() + ";",
""
"",
);
return parts.join( "\n" );

@ -90,7 +90,7 @@ function inferenceMatchResult( ast, session ) {
session.error(
"Infinity cycle detected when trying to evaluate node match result",
node.location
node.location,
);
}

@ -43,7 +43,7 @@ function reportDuplicateLabels( ast, session ) {
session.error(
`Label "${ label }" is already defined at line ${ start.line }, column ${ start.column }.`,
node.location
node.location,
);
}

@ -18,7 +18,7 @@ function reportDuplicateRules( ast, session ) {
session.error(
`Rule "${ name }" is already defined at line ${ start.line }, column ${ start.column }.`,
node.location
node.location,
);
}

@ -44,7 +44,7 @@ function reportInfiniteRecursion( ast, session ) {
session.error(
`Possible infinite loop when parsing (left recursion: ${ rulePath }).`,
node.location
node.location,
);
}

@ -11,7 +11,7 @@ function reportInfiniteRepetition( ast, session ) {
session.error(
"Possible infinite loop when parsing (repetition used with an expression that may not consume any input).",
node.location
node.location,
);
}
@ -24,7 +24,7 @@ function reportInfiniteRepetition( ast, session ) {
session.error(
"Possible infinite loop when parsing (repetition used with an expression that may not consume any input).",
node.location
node.location,
);
}

@ -10,7 +10,7 @@ function reportUndefinedRules( ast, session, options ) {
session.error(
`Rule "${ node.name }" is not defined.`,
node.location
node.location,
);
}

@ -19,7 +19,7 @@ function reportUnusedRules( ast, session, options ) {
session.warn(
`Rule "${ rule.name }" is not referenced.`,
rule.location
rule.location,
);
}

@ -44,7 +44,7 @@ const peg = {
return compiler.compile(
session.parse( grammar, options.parser || {} ),
session,
options
options,
);
},

@ -39,7 +39,7 @@ const js = {
return sourceEscape(
s
.replace( /\\/g, "\\\\" ) // backslash
.replace( /"/g, "\\\"" ) // closing double quote
.replace( /"/g, "\\\"" ), // closing double quote
);
},
@ -57,7 +57,7 @@ const js = {
.replace( /\//g, "\\/" ) // closing slash
.replace( /]/g, "\\]" ) // closing bracket
.replace( /\^/g, "\\^" ) // caret
.replace( /-/g, "\\-" ) // dash
.replace( /-/g, "\\-" ), // dash
);
},

@ -29,7 +29,7 @@ describe( "generated parser behavior", function () {
block( peg.util.clone( variant ) );
}
},
);
} );
@ -71,7 +71,7 @@ describe( "generated parser behavior", function () {
"expected #{this} to not parse input as #{exp}",
expected,
result,
! utils.flag( this, "negate" )
! utils.flag( this, "negate" ),
);
}
@ -102,7 +102,7 @@ describe( "generated parser behavior", function () {
"expected #{this} to fail to parse input but got #{act}",
"expected #{this} to not fail to parse input but #{act} was thrown",
null,
result
result,
);
if ( ! passed && typeof props !== "undefined" ) {
@ -556,7 +556,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = a:'a' &{ return a === 'a'; }",
options
options,
);
expect( parser ).to.parse( "a" );
@ -567,7 +567,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = 'a' b:&{ return b === undefined; } 'c'",
options
options,
);
expect( parser ).to.failToParse( "ac" );
@ -578,7 +578,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = &{ return a === 'a'; } a:'a'",
options
options,
);
expect( parser ).to.failToParse( "a" );
@ -651,7 +651,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = a:'a' ('b' &{ return a === 'a'; })",
options
options,
);
expect( parser ).to.parse( "ab" );
@ -662,7 +662,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = 'a' b:('b' &{ return b === undefined; }) 'c'",
options
options,
);
expect( parser ).to.failToParse( "abc" );
@ -673,7 +673,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = ('a' &{ return b === 'b'; }) b:'b'",
options
options,
);
expect( parser ).to.failToParse( "ab" );
@ -815,7 +815,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = a:'a' !{ return a !== 'a'; }",
options
options,
);
expect( parser ).to.parse( "a" );
@ -826,7 +826,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = 'a' b:!{ return b !== undefined; } 'c'",
options
options,
);
expect( parser ).to.failToParse( "ac" );
@ -837,7 +837,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = !{ return a !== 'a'; } a:'a'",
options
options,
);
expect( parser ).to.failToParse( "a" );
@ -910,7 +910,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = a:'a' ('b' !{ return a !== 'a'; })",
options
options,
);
expect( parser ).to.parse( "ab" );
@ -921,7 +921,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = 'a' b:('b' !{ return b !== undefined; }) 'c'",
options
options,
);
expect( parser ).to.failToParse( "abc" );
@ -932,7 +932,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = ('a' !{ return b !== 'b'; }) b:'b'",
options
options,
);
expect( parser ).to.failToParse( "ab" );
@ -1482,7 +1482,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = a:'a' b:'b' c:'c' { return [a, b, c]; }",
options
options,
);
expect( parser ).to.parse( "abc", [ "a", "b", "c" ] );
@ -1555,7 +1555,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = a:'a' ('b' { return a; })",
options
options,
);
expect( parser ).to.parse( "ab", [ "a", "a" ] );
@ -1566,7 +1566,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = 'a' b:('b' { return b; }) c:'c'",
options
options,
);
expect( parser ).to.failToParse( "abc" );
@ -1577,7 +1577,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = ('a' { return b; }) b:'b'",
options
options,
);
expect( parser ).to.failToParse( "ab" );
@ -1620,7 +1620,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = 'a' { return options; }",
options
options,
);
expect( parser ).to.parse( "a", { a: 42 }, { a: 42 } );
@ -1631,7 +1631,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = 'a' { return text(); }",
options
options,
);
expect( parser ).to.parse( "a", "a" );
@ -1673,7 +1673,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = 'a' { expected('a'); }",
options
options,
);
expect( parser ).to.failToParse( "a", {
@ -1719,7 +1719,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = 'a' { error('a'); }",
options
options,
);
expect( parser ).to.failToParse( "a", {
@ -1777,7 +1777,7 @@ describe( "generated parser behavior", function () {
const parser = peg.generate(
"start = 'a' { throw 'Boom!'; } / 'b'",
options
options,
);
expect( parser ).to.parse( "b" );
@ -2195,7 +2195,7 @@ describe( "generated parser behavior", function () {
expect( parser ).to.parse( "(*(**)*)", "(*(**)*)" );
expect( parser ).to.parse(
"(*abc(*def*)ghi(*(*(*jkl*)*)*)mno*)",
"(*abc(*def*)ghi(*(*(*jkl*)*)*)mno*)"
"(*abc(*def*)ghi(*(*(*jkl*)*)*)mno*)",
);
} );

@ -1,5 +1,3 @@
/* eslint-disable function-call-argument-newline */
"use strict";
const chai = require( "chai" );
@ -63,7 +61,7 @@ describe( "compiler pass |generateBytecode|", function () {
{ type: "literal", value: "b", ignoreCase: false },
{ type: "literal", value: "c", ignoreCase: false },
],
[]
[],
) );
} );
@ -119,19 +117,19 @@ describe( "compiler pass |generateBytecode|", function () {
[],
[],
[ { type: "rule", value: "start" } ],
[]
[],
) );
expect( pass ).to.changeAST( grammar2, constsDetails(
[ "a" ],
[],
[ { type: "rule", value: "start" } ],
[]
[],
) );
expect( pass ).to.changeAST( grammar3, constsDetails(
[],
[ { value: [ "a" ], inverted: false, ignoreCase: false } ],
[ { type: "rule", value: "start" } ],
[]
[],
) );
} );
@ -209,7 +207,7 @@ describe( "compiler pass |generateBytecode|", function () {
[ "a" ],
[],
[ { type: "literal", value: "a", ignoreCase: false } ],
[ { predicate: false, params: [], body: " code " } ]
[ { predicate: false, params: [], body: " code " } ],
) );
} );
@ -239,7 +237,7 @@ describe( "compiler pass |generateBytecode|", function () {
[ "a" ],
[],
[ { type: "literal", value: "a", ignoreCase: false } ],
[ { predicate: false, params: [ "a" ], body: " code " } ]
[ { predicate: false, params: [ "a" ], body: " code " } ],
) );
} );
@ -285,7 +283,7 @@ describe( "compiler pass |generateBytecode|", function () {
{ type: "literal", value: "b", ignoreCase: false },
{ type: "literal", value: "c", ignoreCase: false },
],
[ { predicate: false, params: [ "a", "b", "c" ], body: " code " } ]
[ { predicate: false, params: [ "a", "b", "c" ], body: " code " } ],
) );
} );
@ -333,7 +331,7 @@ describe( "compiler pass |generateBytecode|", function () {
{ type: "literal", value: "b", ignoreCase: false },
{ type: "literal", value: "c", ignoreCase: false },
],
[]
[],
) );
} );
@ -441,7 +439,7 @@ describe( "compiler pass |generateBytecode|", function () {
[ "a" ],
[],
[ { type: "literal", value: "a", ignoreCase: false } ],
[]
[],
) );
} );
@ -476,7 +474,7 @@ describe( "compiler pass |generateBytecode|", function () {
[ "a" ],
[],
[ { type: "literal", value: "a", ignoreCase: false } ],
[]
[],
) );
} );
@ -504,7 +502,7 @@ describe( "compiler pass |generateBytecode|", function () {
[ "a" ],
[],
[ { type: "literal", value: "a", ignoreCase: false } ],
[]
[],
) );
} );
@ -534,7 +532,7 @@ describe( "compiler pass |generateBytecode|", function () {
[ "a" ],
[],
[ { type: "literal", value: "a", ignoreCase: false } ],
[]
[],
) );
} );
@ -568,7 +566,7 @@ describe( "compiler pass |generateBytecode|", function () {
[ "a" ],
[],
[ { type: "literal", value: "a", ignoreCase: false } ],
[]
[],
) );
} );
@ -593,7 +591,7 @@ describe( "compiler pass |generateBytecode|", function () {
[ "a" ],
[],
[ { type: "literal", value: "a", ignoreCase: false } ],
[]
[],
) );
} );
@ -624,7 +622,7 @@ describe( "compiler pass |generateBytecode|", function () {
expect( pass ).to.changeAST(
grammar,
constsDetails( [], [], [], [ { predicate: true, params: [], body: " code " } ] )
constsDetails( [], [], [], [ { predicate: true, params: [], body: " code " } ] ),
);
} );
@ -681,7 +679,7 @@ describe( "compiler pass |generateBytecode|", function () {
{ type: "literal", value: "b", ignoreCase: false },
{ type: "literal", value: "c", ignoreCase: false },
],
[ { predicate: true, params: [ "a", "b", "c" ], body: " code " } ]
[ { predicate: true, params: [ "a", "b", "c" ], body: " code " } ],
) );
} );
@ -714,7 +712,7 @@ describe( "compiler pass |generateBytecode|", function () {
expect( pass ).to.changeAST(
grammar,
constsDetails( [], [], [], [ { predicate: true, params: [], body: " code " } ] )
constsDetails( [], [], [], [ { predicate: true, params: [], body: " code " } ] ),
);
} );
@ -771,7 +769,7 @@ describe( "compiler pass |generateBytecode|", function () {
{ type: "literal", value: "b", ignoreCase: false },
{ type: "literal", value: "c", ignoreCase: false },
],
[ { predicate: true, params: [ "a", "b", "c" ], body: " code " } ]
[ { predicate: true, params: [ "a", "b", "c" ], body: " code " } ],
) );
} );
@ -845,7 +843,7 @@ describe( "compiler pass |generateBytecode|", function () {
[ "a" ],
[],
[ { type: "literal", value: "a", ignoreCase: false } ],
[]
[],
) );
} );
@ -873,7 +871,7 @@ describe( "compiler pass |generateBytecode|", function () {
[ "a" ],
[],
[ { type: "literal", value: "A", ignoreCase: true } ],
[]
[],
) );
} );
@ -975,7 +973,7 @@ describe( "compiler pass |generateBytecode|", function () {
[],
[ { value: [ "a" ], inverted: false, ignoreCase: false } ],
[ { type: "class", value: [ "a" ], inverted: false, ignoreCase: false } ],
[]
[],
) );
} );
@ -990,7 +988,7 @@ describe( "compiler pass |generateBytecode|", function () {
[],
[ { value: [ "a" ], inverted: true, ignoreCase: false } ],
[ { type: "class", value: [ "a" ], inverted: true, ignoreCase: false } ],
[]
[],
) );
} );
@ -1005,7 +1003,7 @@ describe( "compiler pass |generateBytecode|", function () {
[],
[ { value: [ "a" ], inverted: false, ignoreCase: true } ],
[ { type: "class", value: [ "a" ], inverted: false, ignoreCase: true } ],
[]
[],
) );
} );
@ -1033,7 +1031,7 @@ describe( "compiler pass |generateBytecode|", function () {
ignoreCase: false,
},
],
[]
[],
) );
} );
@ -1098,7 +1096,7 @@ describe( "compiler pass |generateBytecode|", function () {
},
],
[],
[]
[],
), {}, { reportFailures: false } );
} );
@ -1130,7 +1128,7 @@ describe( "compiler pass |generateBytecode|", function () {
expect( pass ).to.changeAST(
grammar,
constsDetails( [], [], [ { type: "any" } ], [] )
constsDetails( [], [], [ { type: "any" } ], [] ),
);
} );
@ -1157,7 +1155,7 @@ describe( "compiler pass |generateBytecode|", function () {
grammar,
constsDetails( [], [], [], [] ),
{},
{ reportFailures: false }
{ reportFailures: false },
);
} );

@ -67,7 +67,7 @@ module.exports = function ( chai, utils ) {
"expected #{this} to report an error but it didn't",
"expected #{this} to not report an error but #{act} was reported",
null,
result
result,
);
if ( ! passed && typeof props !== "undefined" ) {
@ -118,7 +118,7 @@ module.exports = function ( chai, utils ) {
`expected #{this} to report ${ warningsCount } warnings, but it reported ${ messagesCount } warnings`,
`expected #{this} to not report ${ warningsCount } warnings`,
warnings,
messages
messages,
);
warnings.forEach( warning => {
@ -127,7 +127,7 @@ module.exports = function ( chai, utils ) {
messages.indexOf( warning ) !== -1,
"expected #{this} to report the warning #{exp}, but it didn't",
"expected #{this} to not report the warning #{exp}",
warning
warning,
);
} );

@ -141,19 +141,19 @@ describe( "compiler pass |inferenceMatchResult|", function () {
[ "start = end", "end = . " ].join( "\n" ),
{ rules: [ { match: 0 }, { match: 0 } ] },
{},
{}
{},
);
expect( pass ).to.changeAST(
[ "start = end", "end = ''" ].join( "\n" ),
{ rules: [ { match: 1 }, { match: 1 } ] },
{},
{}
{},
);
expect( pass ).to.changeAST(
[ "start = end", "end = []" ].join( "\n" ),
{ rules: [ { match: -1 }, { match: -1 } ] },
{},
{}
{},
);
expect( pass ).to.changeAST( "start = . start", { rules: [ { match: 0 } ] }, {}, {} );

@ -29,7 +29,7 @@ describe( "compiler pass |removeProxyRules|", function () {
{ name: "proxied" },
],
},
{ allowedStartRules: [ "start" ] }
{ allowedStartRules: [ "start" ] },
);
} );
@ -59,7 +59,7 @@ describe( "compiler pass |removeProxyRules|", function () {
{ name: "proxied" },
],
},
{ allowedStartRules: [ "start", "proxy" ] }
{ allowedStartRules: [ "start", "proxy" ] },
);
} );

@ -31,7 +31,7 @@ describe( "compiler pass |reportUndefinedRules|", function () {
},
{
allowedStartRules: [ "missing" ],
}
},
);
} );

@ -17,7 +17,7 @@ describe( "compiler pass |reportUnusedRules|", function () {
start = .
unused = .
`,
`Rule "unused" is not referenced.`
`Rule "unused" is not referenced.`,
);
expect( pass ).to.reportWarning(
@ -29,7 +29,7 @@ describe( "compiler pass |reportUnusedRules|", function () {
[
`Rule "used" is not referenced.`,
`Rule "unused" is not referenced.`,
]
],
);
} );
@ -56,7 +56,7 @@ describe( "compiler pass |reportUnusedRules|", function () {
null,
{
allowedStartRules: [ "b", "c" ],
}
},
);
} );

@ -24,7 +24,7 @@ function varyParserOptions( block ) {
describe(
"with options " + chai.util.inspect( variant ),
() => block( variant )
() => block( variant ),
);
} );
@ -103,7 +103,7 @@ describe( "PEG.js grammar parser", function () {
function actionGrammar( code ) {
return oneRuleGrammar(
{ type: "action", expression: literalAbcd, code: code }
{ type: "action", expression: literalAbcd, code: code },
);
}
@ -111,7 +111,7 @@ describe( "PEG.js grammar parser", function () {
function literalGrammar( value, ignoreCase ) {
return oneRuleGrammar(
{ type: "literal", value: value, ignoreCase: ignoreCase }
{ type: "literal", value: value, ignoreCase: ignoreCase },
);
}
@ -260,7 +260,7 @@ describe( "PEG.js grammar parser", function () {
"expected #{this} to not parse as #{exp}",
expected,
result,
! utils.flag( this, "negate" )
! utils.flag( this, "negate" ),
);
} );
@ -292,7 +292,7 @@ describe( "PEG.js grammar parser", function () {
"expected #{this} to fail to parse but got #{act}",
"expected #{this} to not fail to parse but it failed with #{act}",
null,
result
result,
);
if ( ! passed && typeof props !== "undefined" ) {
@ -340,13 +340,13 @@ describe( "PEG.js grammar parser", function () {
it( "parses Grammar", function () {
expect( "\na = 'abcd';\n" ).to.parseAs(
{ type: "grammar", comments: null, initializer: null, rules: [ ruleA ] }
{ type: "grammar", comments: null, initializer: null, rules: [ ruleA ] },
);
expect( "\na = 'abcd';\nb = 'efgh';\nc = 'ijkl';\n" ).to.parseAs(
{ type: "grammar", comments: null, initializer: null, rules: [ ruleA, ruleB, ruleC ] }
{ type: "grammar", comments: null, initializer: null, rules: [ ruleA, ruleB, ruleC ] },
);
expect( "\n{ code };\na = 'abcd';\n" ).to.parseAs(
{ type: "grammar", comments: null, initializer: initializer, rules: [ ruleA ] }
{ type: "grammar", comments: null, initializer: initializer, rules: [ ruleA ] },
);
} );
@ -355,7 +355,7 @@ describe( "PEG.js grammar parser", function () {
it( "parses Initializer", function () {
expect( "{ code };start = 'abcd'" ).to.parseAs(
{ type: "grammar", comments: null, initializer: initializer, rules: [ ruleStart ] }
{ type: "grammar", comments: null, initializer: initializer, rules: [ ruleStart ] },
);
} );
@ -364,10 +364,10 @@ describe( "PEG.js grammar parser", function () {
it( "parses Rule", function () {
expect( "start\n=\n'abcd';" ).to.parseAs(
oneRuleGrammar( literalAbcd )
oneRuleGrammar( literalAbcd ),
);
expect( "start\n'start rule'\n=\n'abcd';" ).to.parseAs(
oneRuleGrammar( named )
oneRuleGrammar( named ),
);
} );
@ -376,7 +376,7 @@ describe( "PEG.js grammar parser", function () {
it( "parses Expression", function () {
expect( "start = 'abcd' / 'efgh' / 'ijkl'" ).to.parseAs(
oneRuleGrammar( choice )
oneRuleGrammar( choice ),
);
} );
@ -385,15 +385,15 @@ describe( "PEG.js grammar parser", function () {
it( "parses ChoiceExpression", function () {
expect( "start = 'abcd' { code }" ).to.parseAs(
oneRuleGrammar( actionAbcd )
oneRuleGrammar( actionAbcd ),
);
expect( "start = 'abcd' { code }\n/\n'efgh' { code }" ).to.parseAs(
oneRuleGrammar( choice2 )
oneRuleGrammar( choice2 ),
);
expect(
"start = 'abcd' { code }\n/\n'efgh' { code }\n/\n'ijkl' { code }\n/\n'mnop' { code }"
"start = 'abcd' { code }\n/\n'efgh' { code }\n/\n'ijkl' { code }\n/\n'mnop' { code }",
).to.parseAs(
oneRuleGrammar( choice4 )
oneRuleGrammar( choice4 ),
);
} );
@ -402,10 +402,10 @@ describe( "PEG.js grammar parser", function () {
it( "parses ActionExpression", function () {
expect( "start = 'abcd' 'efgh' 'ijkl'" ).to.parseAs(
oneRuleGrammar( sequence )
oneRuleGrammar( sequence ),
);
expect( "start = 'abcd' 'efgh' 'ijkl'\n{ code }" ).to.parseAs(
oneRuleGrammar( actionSequence )
oneRuleGrammar( actionSequence ),
);
} );
@ -414,13 +414,13 @@ describe( "PEG.js grammar parser", function () {
it( "parses SequenceExpression", function () {
expect( "start = a:'abcd'" ).to.parseAs(
oneRuleGrammar( labeledAbcd )
oneRuleGrammar( labeledAbcd ),
);
expect( "start = a:'abcd'\nb:'efgh'" ).to.parseAs(
oneRuleGrammar( sequence2 )
oneRuleGrammar( sequence2 ),
);
expect( "start = a:'abcd'\nb:'efgh'\nc:'ijkl'\nd:'mnop'" ).to.parseAs(
oneRuleGrammar( sequence4 )
oneRuleGrammar( sequence4 ),
);
} );
@ -448,22 +448,22 @@ describe( "PEG.js grammar parser", function () {
}
expect( "start = @'abcd'" ).to.parseAs(
$S( $P( null, literalAbcd ) )
$S( $P( null, literalAbcd ) ),
);
expect( "start = @a:'abcd'" ).to.parseAs(
$S( $P( "a", literalAbcd ) )
$S( $P( "a", literalAbcd ) ),
);
expect( "start = 'abcd' @'efgh'" ).to.parseAs(
$S( literalAbcd, $P( null, literalEfgh ) )
$S( literalAbcd, $P( null, literalEfgh ) ),
);
expect( "start = a:'abcd' @b:'efgh'" ).to.parseAs(
$S( labeledAbcd, $P( "b", literalEfgh ) )
$S( labeledAbcd, $P( "b", literalEfgh ) ),
);
expect( "start = @'abcd' b:'efgh'" ).to.parseAs(
$S( $P( null, literalAbcd ), labeledEfgh )
$S( $P( null, literalAbcd ), labeledEfgh ),
);
expect( "start = a:'abcd' @'efgh' 'ijkl' @d:'mnop'" ).to.parseAs(
$S( labeledAbcd, $P( null, literalEfgh ), literalIjkl, $P( "d", literalMnop ) )
$S( labeledAbcd, $P( null, literalEfgh ), literalIjkl, $P( "d", literalMnop ) ),
);
} );
@ -723,30 +723,30 @@ describe( "PEG.js grammar parser", function () {
it( "parses CharacterClassMatcher", function () {
expect( "start = []" ).to.parseAs(
classGrammar( [], false, false )
classGrammar( [], false, false ),
);
expect( "start = [a-d]" ).to.parseAs(
classGrammar( [ [ "a", "d" ] ], false, false )
classGrammar( [ [ "a", "d" ] ], false, false ),
);
expect( "start = [a]" ).to.parseAs(
classGrammar( [ "a" ], false, false )
classGrammar( [ "a" ], false, false ),
);
expect( "start = [a-de-hi-l]" ).to.parseAs(
classGrammar(
[ [ "a", "d" ], [ "e", "h" ], [ "i", "l" ] ],
false,
false
)
false,
),
);
expect( "start = [^a-d]" ).to.parseAs(
classGrammar( [ [ "a", "d" ] ], true, false )
classGrammar( [ [ "a", "d" ] ], true, false ),
);
expect( "start = [a-d]i" ).to.parseAs(
classGrammar( [ [ "a", "d" ] ], false, true )
classGrammar( [ [ "a", "d" ] ], false, true ),
);
expect( "start = [\\\n]" ).to.parseAs(
classGrammar( [], false, false )
classGrammar( [], false, false ),
);
} );

@ -98,7 +98,7 @@ $( "#run" ).click( () => {
test.title,
`https://github.com/pegjs/pegjs/blob/${ BRANCH }/tools/benchmark/${ benchmark.id }/${ test.file }`,
inputSize,
parseTime
parseTime,
);
},
@ -122,7 +122,7 @@ $( "#run" ).click( () => {
benchmark.title + " total",
null,
inputSize,
parseTime
parseTime,
);
},
@ -143,7 +143,7 @@ $( "#run" ).click( () => {
"Total",
null,
inputSize,
parseTime
parseTime,
);
$.scrollTo( "max", { axis: "y", duration: 500 } );

@ -68,7 +68,7 @@ function writeResult( title, inputSize, parseTime ) {
padLeft( parseTime.toFixed( 2 ), 7 ) +
" ms │ " +
padLeft( ( ( inputSize / KB ) / ( parseTime / MS_IN_S ) ).toFixed( 2 ), 7 ) +
" kB/s │"
" kB/s │",
);
}

@ -70,7 +70,7 @@ const Runner = {
state.parser = peg.generate(
callbacks.readFile( "examples/" + benchmark.id + ".pegjs" ),
options
options,
);
state.benchmarkInputSize = 0;
state.benchmarkParseTime = 0;
@ -113,7 +113,7 @@ const Runner = {
callbacks.benchmarkFinish(
benchmark,
state.benchmarkInputSize,
state.benchmarkParseTime
state.benchmarkParseTime,
);
state.totalInputSize += state.benchmarkInputSize;

@ -73,7 +73,7 @@ function runBenchmark() {
// Trim the whitespaces and remove ` kB/s` from the end
.trim()
.slice( 0, -5 )
.slice( 0, -5 ),
);
}

Loading…
取消
儲存