Code style: Fix ESLint "object-shorthand" errors

Part of #407.
redux
David Majda 8 years ago
parent 6f34b542b4
commit 1870308afb

@ -72,7 +72,7 @@ $("#run").click(() => {
} }
Runner.run(benchmarks, runCount, options, { Runner.run(benchmarks, runCount, options, {
readFile: function(file) { readFile(file) {
return $.ajax({ return $.ajax({
type: "GET", type: "GET",
url: file, url: file,
@ -81,11 +81,11 @@ $("#run").click(() => {
}).responseText; }).responseText;
}, },
testStart: function() { testStart() {
// Nothing to do. // Nothing to do.
}, },
testFinish: function(benchmark, test, inputSize, parseTime) { testFinish(benchmark, test, inputSize, parseTime) {
appendResult( appendResult(
"individual", "individual",
test.title, test.title,
@ -95,11 +95,11 @@ $("#run").click(() => {
); );
}, },
benchmarkStart: function(benchmark) { benchmarkStart(benchmark) {
appendHeading(benchmark.title); appendHeading(benchmark.title);
}, },
benchmarkFinish: function(benchmark, inputSize, parseTime) { benchmarkFinish(benchmark, inputSize, parseTime) {
appendResult( appendResult(
"benchmark-total", "benchmark-total",
benchmark.title + " total", benchmark.title + " total",
@ -109,14 +109,14 @@ $("#run").click(() => {
); );
}, },
start: function() { start() {
$("#run-count, #cache, #run").attr("disabled", "disabled"); $("#run-count, #cache, #run").attr("disabled", "disabled");
resultsTable.show(); resultsTable.show();
$("#results-table tr").slice(1).remove(); $("#results-table tr").slice(1).remove();
}, },
finish: function(inputSize, parseTime) { finish(inputSize, parseTime) {
appendResult( appendResult(
"total", "total",
"Total", "Total",

@ -163,32 +163,32 @@ if (args.length > 0) {
} }
Runner.run(benchmarks, runCount, options, { Runner.run(benchmarks, runCount, options, {
readFile: function(file) { readFile(file) {
return fs.readFileSync(__dirname + "/" + file, "utf8"); return fs.readFileSync(__dirname + "/" + file, "utf8");
}, },
testStart: function() { testStart() {
// Nothing to do. // Nothing to do.
}, },
testFinish: function(benchmark, test, inputSize, parseTime) { testFinish(benchmark, test, inputSize, parseTime) {
writeResult(test.title, inputSize, parseTime); writeResult(test.title, inputSize, parseTime);
}, },
benchmarkStart: function(benchmark) { benchmarkStart(benchmark) {
writeHeading(benchmark.title); writeHeading(benchmark.title);
}, },
benchmarkFinish: function(benchmark, inputSize, parseTime) { benchmarkFinish(benchmark, inputSize, parseTime) {
writeSeparator(); writeSeparator();
writeResult(benchmark.title + " total", inputSize, parseTime); writeResult(benchmark.title + " total", inputSize, parseTime);
}, },
start: function() { start() {
writeTableHeader(); writeTableHeader();
}, },
finish: function(inputSize, parseTime) { finish(inputSize, parseTime) {
writeSeparator(); writeSeparator();
writeResult("Total", inputSize, parseTime); writeResult("Total", inputSize, parseTime);
writeTableFooter(); writeTableFooter();

@ -5,17 +5,17 @@
let peg = require("../lib/peg"); let peg = require("../lib/peg");
let Runner = { let Runner = {
run: function(benchmarks, runCount, options, callbacks) { run(benchmarks, runCount, options, callbacks) {
// Queue // Queue
let Q = { let Q = {
functions: [], functions: [],
add: function(f) { add(f) {
this.functions.push(f); this.functions.push(f);
}, },
run: function() { run() {
if (this.functions.length > 0) { if (this.functions.length > 0) {
this.functions.shift()(); this.functions.shift()();

@ -4,7 +4,7 @@ let visitor = require("./visitor");
// AST utilities. // AST utilities.
let asts = { let asts = {
findRule: function(ast, name) { findRule(ast, name) {
for (let i = 0; i < ast.rules.length; i++) { for (let i = 0; i < ast.rules.length; i++) {
if (ast.rules[i].name === name) { if (ast.rules[i].name === name) {
return ast.rules[i]; return ast.rules[i];
@ -14,7 +14,7 @@ let asts = {
return undefined; return undefined;
}, },
indexOfRule: function(ast, name) { indexOfRule(ast, name) {
for (let i = 0; i < ast.rules.length; i++) { for (let i = 0; i < ast.rules.length; i++) {
if (ast.rules[i].name === name) { if (ast.rules[i].name === name) {
return i; return i;
@ -24,7 +24,7 @@ let asts = {
return -1; return -1;
}, },
alwaysConsumesOnSuccess: function(ast, node) { alwaysConsumesOnSuccess(ast, node) {
function consumesTrue() { return true; } function consumesTrue() { return true; }
function consumesFalse() { return false; } function consumesFalse() { return false; }
@ -36,13 +36,13 @@ let asts = {
rule: consumesExpression, rule: consumesExpression,
named: consumesExpression, named: consumesExpression,
choice: function(node) { choice(node) {
return node.alternatives.every(consumes); return node.alternatives.every(consumes);
}, },
action: consumesExpression, action: consumesExpression,
sequence: function(node) { sequence(node) {
return node.elements.some(consumes); return node.elements.some(consumes);
}, },
@ -57,11 +57,11 @@ let asts = {
semantic_and: consumesFalse, semantic_and: consumesFalse,
semantic_not: consumesFalse, semantic_not: consumesFalse,
rule_ref: function(node) { rule_ref(node) {
return consumes(asts.findRule(ast, node.name)); return consumes(asts.findRule(ast, node.name));
}, },
literal: function(node) { literal(node) {
return node.value !== ""; return node.value !== "";
}, },

@ -47,7 +47,7 @@ let compiler = {
// if the AST contains a semantic error. Note that not all errors are detected // if the AST contains a semantic error. Note that not all errors are detected
// during the generation and some may protrude to the generated parser and // during the generation and some may protrude to the generated parser and
// cause its malfunction. // cause its malfunction.
compile: function(ast, passes, options) { compile(ast, passes, options) {
options = options !== undefined ? options : {}; options = options !== undefined ? options : {};
options = processOptions(options, { options = processOptions(options, {

@ -4,7 +4,7 @@ function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
// JavaScript code generation helpers. // JavaScript code generation helpers.
let js = { let js = {
stringEscape: function(s) { stringEscape(s) {
// ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a string // ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a string
// literal except for the closing quote character, backslash, carriage // literal except for the closing quote character, backslash, carriage
// return, line separator, paragraph separator, and line feed. Any character // return, line separator, paragraph separator, and line feed. Any character
@ -27,7 +27,7 @@ let js = {
.replace(/[\u1000-\uFFFF]/g, ch => "\\u" + hex(ch)); .replace(/[\u1000-\uFFFF]/g, ch => "\\u" + hex(ch));
}, },
regexpClassEscape: function(s) { regexpClassEscape(s) {
// Based on ECMA-262, 5th ed., 7.8.5 & 15.10.1. // Based on ECMA-262, 5th ed., 7.8.5 & 15.10.1.
// //
// For portability, we also escape all control and non-ASCII characters. // For portability, we also escape all control and non-ASCII characters.

@ -288,13 +288,13 @@ function generateBytecode(ast) {
} }
let generate = visitor.build({ let generate = visitor.build({
grammar: function(node) { grammar(node) {
node.rules.forEach(generate); node.rules.forEach(generate);
node.consts = consts; node.consts = consts;
}, },
rule: function(node) { rule(node) {
node.bytecode = generate(node.expression, { node.bytecode = generate(node.expression, {
sp: -1, // stack pointer sp: -1, // stack pointer
env: { }, // mapping of label names to stack positions env: { }, // mapping of label names to stack positions
@ -302,7 +302,7 @@ function generateBytecode(ast) {
}); });
}, },
named: function(node, context) { named(node, context) {
let nameIndex = addConst( let nameIndex = addConst(
"peg$otherExpectation(\"" + js.stringEscape(node.name) + "\")" "peg$otherExpectation(\"" + js.stringEscape(node.name) + "\")"
); );
@ -319,7 +319,7 @@ function generateBytecode(ast) {
); );
}, },
choice: function(node, context) { choice(node, context) {
function buildAlternativesCode(alternatives, context) { function buildAlternativesCode(alternatives, context) {
return buildSequence( return buildSequence(
generate(alternatives[0], { generate(alternatives[0], {
@ -343,7 +343,7 @@ function generateBytecode(ast) {
return buildAlternativesCode(node.alternatives, context); return buildAlternativesCode(node.alternatives, context);
}, },
action: function(node, context) { action(node, context) {
let env = cloneEnv(context.env); let env = cloneEnv(context.env);
let emitCall = node.expression.type !== "sequence" let emitCall = node.expression.type !== "sequence"
|| node.expression.elements.length === 0; || node.expression.elements.length === 0;
@ -371,7 +371,7 @@ function generateBytecode(ast) {
: expressionCode; : expressionCode;
}, },
sequence: function(node, context) { sequence(node, context) {
function buildElementsCode(elements, context) { function buildElementsCode(elements, context) {
if (elements.length > 0) { if (elements.length > 0) {
let processedCount = node.elements.length - elements.slice(1).length; let processedCount = node.elements.length - elements.slice(1).length;
@ -429,7 +429,7 @@ function generateBytecode(ast) {
); );
}, },
labeled: function(node, context) { labeled(node, context) {
let env = cloneEnv(context.env); let env = cloneEnv(context.env);
context.env[node.label] = context.sp + 1; context.env[node.label] = context.sp + 1;
@ -441,7 +441,7 @@ function generateBytecode(ast) {
}); });
}, },
text: function(node, context) { text(node, context) {
return buildSequence( return buildSequence(
[op.PUSH_CURR_POS], [op.PUSH_CURR_POS],
generate(node.expression, { generate(node.expression, {
@ -457,15 +457,15 @@ function generateBytecode(ast) {
); );
}, },
simple_and: function(node, context) { simple_and(node, context) {
return buildSimplePredicate(node.expression, false, context); return buildSimplePredicate(node.expression, false, context);
}, },
simple_not: function(node, context) { simple_not(node, context) {
return buildSimplePredicate(node.expression, true, context); return buildSimplePredicate(node.expression, true, context);
}, },
optional: function(node, context) { optional(node, context) {
return buildSequence( return buildSequence(
generate(node.expression, { generate(node.expression, {
sp: context.sp, sp: context.sp,
@ -480,7 +480,7 @@ function generateBytecode(ast) {
); );
}, },
zero_or_more: function(node, context) { zero_or_more(node, context) {
let expressionCode = generate(node.expression, { let expressionCode = generate(node.expression, {
sp: context.sp + 1, sp: context.sp + 1,
env: cloneEnv(context.env), env: cloneEnv(context.env),
@ -495,7 +495,7 @@ function generateBytecode(ast) {
); );
}, },
one_or_more: function(node, context) { one_or_more(node, context) {
let expressionCode = generate(node.expression, { let expressionCode = generate(node.expression, {
sp: context.sp + 1, sp: context.sp + 1,
env: cloneEnv(context.env), env: cloneEnv(context.env),
@ -513,7 +513,7 @@ function generateBytecode(ast) {
); );
}, },
group: function(node, context) { group(node, context) {
return generate(node.expression, { return generate(node.expression, {
sp: context.sp, sp: context.sp,
env: cloneEnv(context.env), env: cloneEnv(context.env),
@ -521,19 +521,19 @@ function generateBytecode(ast) {
}); });
}, },
semantic_and: function(node, context) { semantic_and(node, context) {
return buildSemanticPredicate(node.code, false, context); return buildSemanticPredicate(node.code, false, context);
}, },
semantic_not: function(node, context) { semantic_not(node, context) {
return buildSemanticPredicate(node.code, true, context); return buildSemanticPredicate(node.code, true, context);
}, },
rule_ref: function(node) { rule_ref(node) {
return [op.RULE, asts.indexOfRule(ast, node.name)]; return [op.RULE, asts.indexOfRule(ast, node.name)];
}, },
literal: function(node) { literal(node) {
if (node.value.length > 0) { if (node.value.length > 0) {
let stringIndex = addConst("\"" let stringIndex = addConst("\""
+ js.stringEscape( + js.stringEscape(
@ -567,7 +567,7 @@ function generateBytecode(ast) {
} }
}, },
class: function(node) { class(node) {
let regexp = "/^[" let regexp = "/^["
+ (node.inverted ? "^" : "") + (node.inverted ? "^" : "")
+ node.parts.map(part => + node.parts.map(part =>
@ -601,7 +601,7 @@ function generateBytecode(ast) {
); );
}, },
any: function() { any() {
let expectedIndex = addConst("peg$anyExpectation()"); let expectedIndex = addConst("peg$anyExpectation()");
return buildCondition( return buildCondition(

@ -414,7 +414,7 @@ function generateJS(ast, options) {
sp: -1, sp: -1,
maxSp: -1, maxSp: -1,
push: function(exprCode) { push(exprCode) {
let code = s(++this.sp) + " = " + exprCode + ";"; let code = s(++this.sp) + " = " + exprCode + ";";
if (this.sp > this.maxSp) { this.maxSp = this.sp; } if (this.sp > this.maxSp) { this.maxSp = this.sp; }
@ -422,7 +422,7 @@ function generateJS(ast, options) {
return code; return code;
}, },
pop: function(n) { pop(n) {
if (n === undefined) { if (n === undefined) {
return s(this.sp--); return s(this.sp--);
} else { } else {
@ -438,11 +438,11 @@ function generateJS(ast, options) {
} }
}, },
top: function() { top() {
return s(this.sp); return s(this.sp);
}, },
index: function(i) { index(i) {
return s(this.sp - i); return s(this.sp - i);
} }
}; };
@ -1223,7 +1223,7 @@ function generateJS(ast, options) {
} }
let generators = { let generators = {
bare: function() { bare() {
return [ return [
generateGeneratedByComment(), generateGeneratedByComment(),
"(function() {", "(function() {",
@ -1236,7 +1236,7 @@ function generateJS(ast, options) {
].join("\n"); ].join("\n");
}, },
commonjs: function() { commonjs() {
let parts = []; let parts = [];
let dependencyVars = Object.keys(options.dependencies); let dependencyVars = Object.keys(options.dependencies);
@ -1268,7 +1268,7 @@ function generateJS(ast, options) {
return parts.join("\n"); return parts.join("\n");
}, },
amd: function() { amd() {
let dependencyVars = Object.keys(options.dependencies); let dependencyVars = Object.keys(options.dependencies);
let dependencyIds = dependencyIds.map(v => options.dependencies[v]); let dependencyIds = dependencyIds.map(v => options.dependencies[v]);
let dependencies = "[" let dependencies = "["
@ -1291,7 +1291,7 @@ function generateJS(ast, options) {
].join("\n"); ].join("\n");
}, },
globals: function() { globals() {
return [ return [
generateGeneratedByComment(), generateGeneratedByComment(),
"(function(root) {", "(function(root) {",
@ -1305,7 +1305,7 @@ function generateJS(ast, options) {
].join("\n"); ].join("\n");
}, },
umd: function() { umd() {
let parts = []; let parts = [];
let dependencyVars = Object.keys(options.dependencies); let dependencyVars = Object.keys(options.dependencies);
let dependencyIds = dependencyIds.map(v => options.dependencies[v]); let dependencyIds = dependencyIds.map(v => options.dependencies[v]);

@ -10,7 +10,7 @@ function removeProxyRules(ast, options) {
function replaceRuleRefs(ast, from, to) { function replaceRuleRefs(ast, from, to) {
let replace = visitor.build({ let replace = visitor.build({
rule_ref: function(node) { rule_ref(node) {
if (node.name === from) { if (node.name === from) {
node.name = to; node.name = to;
} }

@ -20,11 +20,11 @@ function reportDuplicateLabels(ast) {
} }
let check = visitor.build({ let check = visitor.build({
rule: function(node) { rule(node) {
check(node.expression, { }); check(node.expression, { });
}, },
choice: function(node, env) { choice(node, env) {
node.alternatives.forEach(alternative => { node.alternatives.forEach(alternative => {
check(alternative, cloneEnv(env)); check(alternative, cloneEnv(env));
}); });
@ -32,7 +32,7 @@ function reportDuplicateLabels(ast) {
action: checkExpressionWithClonedEnv, action: checkExpressionWithClonedEnv,
labeled: function(node, env) { labeled(node, env) {
if (env.hasOwnProperty(node.label)) { if (env.hasOwnProperty(node.label)) {
throw new GrammarError( throw new GrammarError(
"Label \"" + node.label + "\" is already defined " "Label \"" + node.label + "\" is already defined "

@ -8,7 +8,7 @@ function reportDuplicateRules(ast) {
let rules = {}; let rules = {};
let check = visitor.build({ let check = visitor.build({
rule: function(node) { rule(node) {
if (rules.hasOwnProperty(node.name)) { if (rules.hasOwnProperty(node.name)) {
throw new GrammarError( throw new GrammarError(
"Rule \"" + node.name + "\" is already defined " "Rule \"" + node.name + "\" is already defined "

@ -18,13 +18,13 @@ function reportInfiniteRecursion(ast) {
let visitedRules = []; let visitedRules = [];
let check = visitor.build({ let check = visitor.build({
rule: function(node) { rule(node) {
visitedRules.push(node.name); visitedRules.push(node.name);
check(node.expression); check(node.expression);
visitedRules.pop(node.name); visitedRules.pop(node.name);
}, },
sequence: function(node) { sequence(node) {
node.elements.every(element => { node.elements.every(element => {
check(element); check(element);
@ -32,7 +32,7 @@ function reportInfiniteRecursion(ast) {
}); });
}, },
rule_ref: function(node) { rule_ref(node) {
if (visitedRules.indexOf(node.name) !== -1) { if (visitedRules.indexOf(node.name) !== -1) {
visitedRules.push(node.name); visitedRules.push(node.name);

@ -8,7 +8,7 @@ let visitor = require("../visitor");
// grammar, which prevents infinite loops in the generated parser. // grammar, which prevents infinite loops in the generated parser.
function reportInfiniteRepetition(ast) { function reportInfiniteRepetition(ast) {
let check = visitor.build({ let check = visitor.build({
zero_or_more: function(node) { zero_or_more(node) {
if (!asts.alwaysConsumesOnSuccess(ast, node.expression)) { if (!asts.alwaysConsumesOnSuccess(ast, node.expression)) {
throw new GrammarError( throw new GrammarError(
"Possible infinite loop when parsing (repetition used with an expression that may not consume any input).", "Possible infinite loop when parsing (repetition used with an expression that may not consume any input).",
@ -17,7 +17,7 @@ function reportInfiniteRepetition(ast) {
} }
}, },
one_or_more: function(node) { one_or_more(node) {
if (!asts.alwaysConsumesOnSuccess(ast, node.expression)) { if (!asts.alwaysConsumesOnSuccess(ast, node.expression)) {
throw new GrammarError( throw new GrammarError(
"Possible infinite loop when parsing (repetition used with an expression that may not consume any input).", "Possible infinite loop when parsing (repetition used with an expression that may not consume any input).",

@ -7,7 +7,7 @@ let visitor = require("../visitor");
// Checks that all referenced rules exist. // Checks that all referenced rules exist.
function reportUndefinedRules(ast) { function reportUndefinedRules(ast) {
let check = visitor.build({ let check = visitor.build({
rule_ref: function(node) { rule_ref(node) {
if (!asts.findRule(ast, node.name)) { if (!asts.findRule(ast, node.name)) {
throw new GrammarError( throw new GrammarError(
"Rule \"" + node.name + "\" is not defined.", "Rule \"" + node.name + "\" is not defined.",

@ -2,7 +2,7 @@
// Simple AST node visitor builder. // Simple AST node visitor builder.
let visitor = { let visitor = {
build: function(functions) { build(functions) {
function visit(node) { function visit(node) {
return functions[node.type].apply(null, arguments); return functions[node.type].apply(null, arguments);
} }
@ -26,7 +26,7 @@ let visitor = {
} }
const DEFAULT_FUNCTIONS = { const DEFAULT_FUNCTIONS = {
grammar: function(node) { grammar(node) {
let extraArgs = Array.prototype.slice.call(arguments, 1); let extraArgs = Array.prototype.slice.call(arguments, 1);
if (node.initializer) { if (node.initializer) {

@ -17,7 +17,7 @@ let peg = {
// |peg.GrammarError| if it contains a semantic error. Note that not all // |peg.GrammarError| if it contains a semantic error. Note that not all
// errors are detected during the generation and some may protrude to the // errors are detected during the generation and some may protrude to the
// generated parser and cause its malfunction. // generated parser and cause its malfunction.
generate: function(grammar, options) { generate(grammar, options) {
options = options !== undefined ? options : {}; options = options !== undefined ? options : {};
function convertPasses(passes) { function convertPasses(passes) {

@ -5,7 +5,7 @@ let peg = require("../../lib/peg");
describe("plugin API", function() { describe("plugin API", function() {
beforeEach(function() { beforeEach(function() {
this.addMatchers({ this.addMatchers({
toBeObject: function() { toBeObject() {
this.message = () => this.message = () =>
"Expected " + jasmine.pp(this.actual) + " " "Expected " + jasmine.pp(this.actual) + " "
+ (this.isNot ? "not " : "") + (this.isNot ? "not " : "")
@ -14,7 +14,7 @@ describe("plugin API", function() {
return this.actual !== null && typeof this.actual === "object"; return this.actual !== null && typeof this.actual === "object";
}, },
toBeArray: function() { toBeArray() {
this.message = () => this.message = () =>
"Expected " + jasmine.pp(this.actual) + " " "Expected " + jasmine.pp(this.actual) + " "
+ (this.isNot ? "not " : "") + (this.isNot ? "not " : "")
@ -23,7 +23,7 @@ describe("plugin API", function() {
return Object.prototype.toString.apply(this.actual) === "[object Array]"; return Object.prototype.toString.apply(this.actual) === "[object Array]";
}, },
toBeFunction: function() { toBeFunction() {
this.message = () => this.message = () =>
"Expected " + jasmine.pp(this.actual) + " " "Expected " + jasmine.pp(this.actual) + " "
+ (this.isNot ? "not " : "") + (this.isNot ? "not " : "")
@ -40,9 +40,9 @@ describe("plugin API", function() {
it("is called for each plugin", function() { it("is called for each plugin", function() {
let pluginsUsed = [false, false, false]; let pluginsUsed = [false, false, false];
let plugins = [ let plugins = [
{ use: function() { pluginsUsed[0] = true; } }, { use() { pluginsUsed[0] = true; } },
{ use: function() { pluginsUsed[1] = true; } }, { use() { pluginsUsed[1] = true; } },
{ use: function() { pluginsUsed[2] = true; } } { use() { pluginsUsed[2] = true; } }
]; ];
peg.generate(grammar, { plugins: plugins }); peg.generate(grammar, { plugins: plugins });
@ -52,7 +52,7 @@ describe("plugin API", function() {
it("receives configuration", function() { it("receives configuration", function() {
let plugin = { let plugin = {
use: function(config) { use(config) {
expect(config).toBeObject(); expect(config).toBeObject();
expect(config.parser).toBeObject(); expect(config.parser).toBeObject();
@ -82,7 +82,7 @@ describe("plugin API", function() {
it("receives options", function() { it("receives options", function() {
let plugin = { let plugin = {
use: function(config, options) { use(config, options) {
expect(options).toEqual(generateOptions); expect(options).toEqual(generateOptions);
} }
}; };
@ -93,7 +93,7 @@ describe("plugin API", function() {
it("can replace parser", function() { it("can replace parser", function() {
let plugin = { let plugin = {
use: function(config) { use(config) {
let parser = peg.generate([ let parser = peg.generate([
"start = .* {", "start = .* {",
" return {", " return {",
@ -119,7 +119,7 @@ describe("plugin API", function() {
it("can change compiler passes", function() { it("can change compiler passes", function() {
let plugin = { let plugin = {
use: function(config) { use(config) {
let pass = ast => { let pass = ast => {
ast.code = "({ parse: function() { return 42; } })"; ast.code = "({ parse: function() { return 42; } })";
}; };
@ -139,7 +139,7 @@ describe("plugin API", function() {
"c = 'x'" "c = 'x'"
].join("\n"); ].join("\n");
let plugin = { let plugin = {
use: function(config, options) { use(config, options) {
options.allowedStartRules = ["b", "c"]; options.allowedStartRules = ["b", "c"];
} }
}; };

@ -38,7 +38,7 @@ describe("generated parser behavior", function() {
beforeEach(function() { beforeEach(function() {
this.addMatchers({ this.addMatchers({
toParse: function(input, expected, options) { toParse(input, expected, options) {
options = options !== undefined ? options : {}; options = options !== undefined ? options : {};
let result; let result;
@ -70,7 +70,7 @@ describe("generated parser behavior", function() {
} }
}, },
toFailToParse: function(input, details, options) { toFailToParse(input, details, options) {
options = options !== undefined ? options : {}; options = options !== undefined ? options : {};
let result; let result;

@ -4,7 +4,7 @@ let peg = require("../../../../lib/peg");
beforeEach(function() { beforeEach(function() {
this.addMatchers({ this.addMatchers({
toChangeAST: function(grammar, details, options) { toChangeAST(grammar, details, options) {
options = options !== undefined ? options : {}; options = options !== undefined ? options : {};
function matchDetails(value, details) { function matchDetails(value, details) {
@ -58,7 +58,7 @@ beforeEach(function() {
return matchDetails(ast, details); return matchDetails(ast, details);
}, },
toReportError: function(grammar, details) { toReportError(grammar, details) {
let ast = peg.parser.parse(grammar); let ast = peg.parser.parse(grammar);
try { try {

@ -129,7 +129,7 @@ describe("PEG.js grammar parser", function() {
} }
let strip = buildVisitor({ let strip = buildVisitor({
grammar: function(node) { grammar(node) {
delete node.location; delete node.location;
if (node.initializer) { if (node.initializer) {
@ -165,7 +165,7 @@ describe("PEG.js grammar parser", function() {
beforeEach(function() { beforeEach(function() {
this.addMatchers({ this.addMatchers({
toParseAs: function(expected) { toParseAs(expected) {
let result; let result;
try { try {
@ -191,7 +191,7 @@ describe("PEG.js grammar parser", function() {
return this.env.equals_(result, expected); return this.env.equals_(result, expected);
}, },
toFailToParse: function(details) { toFailToParse(details) {
let result; let result;
try { try {

Loading…
Cancel
Save