From 8962dcfd164b0ace24bfe0a53cb2c8cba0f07f70 Mon Sep 17 00:00:00 2001 From: David Majda Date: Sat, 6 Aug 2016 17:51:49 +0200 Subject: [PATCH] Rename the "global" module format to "globals" I think the new name is more widely used when describing the pattern. --- README.md | 6 +++--- bin/pegjs | 10 +++++----- lib/compiler/passes/generate-js.js | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index b44cc89..0ee3d45 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ You can tweak the generated parser with several options: `peg.generate` * `--extra-options-file` — file with additional options (in JSON format) to pass to `peg.generate` - * `--format` — format of the generated parser: `amd`, `global`, `node`, `umd` + * `--format` — format of the generated parser: `amd`, `globals`, `node`, `umd` (default: `node`) * `--optimize` — selects between optimizing the generated parser for parsing speed (`speed`) or code size (`size`) (default: `speed`) @@ -146,8 +146,8 @@ object to `peg.generate`. The following options are supported: `"umd"` (default: `{}`) * `exportVar` — name of a global variable into which the parser object is assigned to when no module loader is detected; valid only when `format` is - set to `"global"` or `"umd"` (default: `null`) - * `format` — format of the genreated parser (`"amd"`, `"bare"`, `"global"`, + set to `"globals"` or `"umd"` (default: `null`) + * `format` — format of the genreated parser (`"amd"`, `"bare"`, `"globals"`, `"node"`, or `"umd"`); valid only when `output` is set to `"source"` (default: `"bare"`) * `optimize`— selects between optimizing the generated parser for parsing diff --git a/bin/pegjs b/bin/pegjs index e1c045f..c83da16 100755 --- a/bin/pegjs +++ b/bin/pegjs @@ -31,8 +31,8 @@ function printHelp() { console.log(" to peg.generate"); console.log(" --extra-options-file file with additional options (in JSON"); console.log(" format) to pass to peg.generate"); - console.log(" --format format of the generated parser: amd, global,"); - console.log(" node, umd (default: node)"); + console.log(" --format format of the generated parser: amd,"); + console.log(" globals, node, umd (default: node)"); console.log(" -h, --help print help and exit"); console.log(" -O, --optimize select optimization for speed or size"); console.log(" (default: speed)"); @@ -186,8 +186,8 @@ while (args.length > 0 && isOption(args[0])) { if (args.length === 0) { abort("Missing parameter of the --format option."); } - if (args[0] !== "amd" && args[0] !== "global" && args[0] !== "node" && args[0] !== "umd") { - abort("Module format must be one of \"amd\", \"global\", \"node\", and \"umd\"."); + if (args[0] !== "amd" && args[0] !== "globals" && args[0] !== "node" && args[0] !== "umd") { + abort("Module format must be one of \"amd\", \"globals\", \"node\", and \"umd\"."); } options.format = args[0]; break; @@ -263,7 +263,7 @@ if (objects.keys(options.dependencies).length > 0) { } if (options.exportVar !== null) { - if (options.format !== "global" && options.format !== "umd") { + if (options.format !== "globals" && options.format !== "umd") { abort("Can't use the -e/--export-var option with the \"" + options.format + "\" module format."); } } diff --git a/lib/compiler/passes/generate-js.js b/lib/compiler/passes/generate-js.js index aafc4e5..6bfb214 100644 --- a/lib/compiler/passes/generate-js.js +++ b/lib/compiler/passes/generate-js.js @@ -1323,7 +1323,7 @@ function generateJS(ast, options) { ].join('\n'); }, - global: function() { + globals: function() { return [ generateGeneratedByComment(), '(function(root) {',