From 0847a69643fd17427cf2956ddffa07caf73cdfe1 Mon Sep 17 00:00:00 2001 From: David Majda Date: Wed, 4 May 2016 12:37:13 +0200 Subject: [PATCH] Rename the "PEG" variable to "peg" So far, PEG.js was exported in a "PEG" global variable when no module loader was detected. The same variable name was also conventionally used when requiring it in Node.js or otherwise referring to it. This was reflected in various places in the code, documentation, examples, etc. This commit changes the variable name to "peg" and fixes all relevant occurrences. The main reason for the change is that in Node.js, modules are generally referred to by lower-case variable names, so "PEG" was sticking out when used in Node.js projects. --- Makefile | 2 +- README.md | 14 +- benchmark/run | 4 +- benchmark/runner.js | 6 +- bin/pegjs | 10 +- lib/compiler.js | 4 +- lib/peg.js | 8 +- spec/api/generated-parser-api.spec.js | 12 +- spec/api/pegjs-api.spec.js | 36 +-- spec/api/plugin-api.spec.js | 16 +- .../generated-parser-behavior.spec.js | 238 +++++++++--------- spec/helpers.js | 2 +- .../compiler/passes/generate-bytecode.spec.js | 4 +- spec/unit/compiler/passes/helpers.js | 6 +- .../passes/remove-proxy-rules.spec.js | 4 +- .../passes/report-infinite-loops.spec.js | 4 +- .../passes/report-left-recursion.spec.js | 4 +- .../passes/report-missing-rules.spec.js | 4 +- spec/unit/parser.spec.js | 6 +- 19 files changed, 192 insertions(+), 192 deletions(-) diff --git a/Makefile b/Makefile index fd225e4..a1e2480 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ browser: echo ' * Licensed under the MIT license.' >> $(BROWSER_FILE_DEV) echo ' */' >> $(BROWSER_FILE_DEV) - $(BROWSERIFY) --standalone PEG $(MAIN_FILE) >> $(BROWSER_FILE_DEV) + $(BROWSERIFY) --standalone peg $(MAIN_FILE) >> $(BROWSER_FILE_DEV) $(UGLIFYJS) \ --mangle \ diff --git a/README.md b/README.md index 676cac9..07163ce 100644 --- a/README.md +++ b/README.md @@ -87,25 +87,25 @@ You can tweak the generated parser with several options: * `--plugin` — makes PEG.js use a specified plugin (can be specified multiple times) * `--extra-options` — additional options (in JSON format) to pass to - `PEG.buildParser` + `peg.buildParser` * `--extra-options-file` — file with additional options (in JSON format) to - pass to `PEG.buildParser` + pass to `peg.buildParser` * `--trace` — makes the parser trace its progress ### JavaScript API In Node.js, require the PEG.js parser generator module: - var PEG = require("pegjs"); + var peg = require("pegjs"); In browser, include the PEG.js library in your web page or application using the `