Code style: Make all static "require" calls global

The "global-require" rule is disabled in ESLint configuration used by
PEG.js, but the idea is not bad, so let's make all static "require"
calls global.

Follow-up to #407.
redux
David Majda 8 years ago
parent f4df9ddde1
commit 83d748d522

@ -1,5 +1,15 @@
"use strict";
let generateBytecode = require("./passes/generate-bytecode");
let generateJS = require("./passes/generate-js");
let removeProxyRules = require("./passes/remove-proxy-rules");
let reportDuplicateLabels = require("./passes/report-duplicate-labels");
let reportDuplicateRules = require("./passes/report-duplicate-rules");
let reportInfiniteRecursion = require("./passes/report-infinite-recursion");
let reportInfiniteRepetition = require("./passes/report-infinite-repetition");
let reportUndefinedRules = require("./passes/report-undefined-rules");
let visitor = require("./visitor");
function processOptions(options, defaults) {
let processedOptions = {};
@ -19,7 +29,7 @@ function processOptions(options, defaults) {
let compiler = {
// AST node visitor builder. Useful mainly for plugins which manipulate the
// AST.
visitor: require("./visitor"),
visitor: visitor,
// Compiler passes.
//
@ -28,18 +38,18 @@ let compiler = {
// |peg.GrammarError|.
passes: {
check: {
reportUndefinedRules: require("./passes/report-undefined-rules"),
reportDuplicateRules: require("./passes/report-duplicate-rules"),
reportDuplicateLabels: require("./passes/report-duplicate-labels"),
reportInfiniteRecursion: require("./passes/report-infinite-recursion"),
reportInfiniteRepetition: require("./passes/report-infinite-repetition")
reportUndefinedRules: reportUndefinedRules,
reportDuplicateRules: reportDuplicateRules,
reportDuplicateLabels: reportDuplicateLabels,
reportInfiniteRecursion: reportInfiniteRecursion,
reportInfiniteRepetition: reportInfiniteRepetition
},
transform: {
removeProxyRules: require("./passes/remove-proxy-rules")
removeProxyRules: removeProxyRules
},
generate: {
generateBytecode: require("./passes/generate-bytecode"),
generateJS: require("./passes/generate-js")
generateBytecode: generateBytecode,
generateJS: generateJS
}
},

@ -1,12 +1,16 @@
"use strict";
let GrammarError = require("./grammar-error");
let compiler = require("./compiler");
let parser = require("./parser");
let peg = {
// PEG.js version (uses semantic versioning).
VERSION: "0.10.0",
GrammarError: require("./grammar-error"),
parser: require("./parser"),
compiler: require("./compiler"),
GrammarError: GrammarError,
parser: parser,
compiler: compiler,
// Generates a parser from a specified grammar and returns it.
//

Loading…
Cancel
Save