Convert PEG.js code to strict mode

* Issues #323
redux
Arlo Breault 9 years ago
parent 1a32ae7bd0
commit 12c169e7b5

@ -13,6 +13,7 @@
"node": true, "node": true,
"noempty": true, "noempty": true,
"nonew": true, "nonew": true,
"strict": true,
"trailing": true, "trailing": true,
"validthis": true, "validthis": true,
"-W082": false "-W082": false

@ -79,6 +79,8 @@ browser:
echo ' * Licensed under the MIT license.' >> $(BROWSER_FILE_DEV) echo ' * Licensed under the MIT license.' >> $(BROWSER_FILE_DEV)
echo ' */' >> $(BROWSER_FILE_DEV) echo ' */' >> $(BROWSER_FILE_DEV)
echo 'var PEG = (function(undefined) {' >> $(BROWSER_FILE_DEV) echo 'var PEG = (function(undefined) {' >> $(BROWSER_FILE_DEV)
echo ' "use strict";' >> $(BROWSER_FILE_DEV)
echo '' >> $(BROWSER_FILE_DEV)
echo ' var modules = {' >> $(BROWSER_FILE_DEV) echo ' var modules = {' >> $(BROWSER_FILE_DEV)
echo ' define: function(name, factory) {' >> $(BROWSER_FILE_DEV) echo ' define: function(name, factory) {' >> $(BROWSER_FILE_DEV)
echo ' var dir = name.replace(/(^|\/)[^/]+$$/, "$$1"),' >> $(BROWSER_FILE_DEV) echo ' var dir = name.replace(/(^|\/)[^/]+$$/, "$$1"),' >> $(BROWSER_FILE_DEV)

@ -1,3 +1,5 @@
"use strict";
(function(root, factory) { (function(root, factory) {
if (typeof module !== 'undefined' && module.exports) { if (typeof module !== 'undefined' && module.exports) {
module.exports = factory(); module.exports = factory();

@ -1,6 +1,8 @@
/* jshint node:false */ /* jshint node:false */
/* global $, alert, benchmarks, document, Runner */
$("#run").click(function() { $("#run").click(function() {
"use strict";
/* Results Table Manipulation */ /* Results Table Manipulation */
@ -132,5 +134,7 @@ $("#run").click(function() {
}); });
$(document).ready(function() { $(document).ready(function() {
"use strict";
$("#run").focus(); $("#run").focus();
}); });

@ -1,5 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
"use strict";
var util = require("util"); var util = require("util");
var fs = require("fs"); var fs = require("fs");
var PEG = require("../lib/peg"); var PEG = require("../lib/peg");

@ -1,3 +1,5 @@
"use strict";
(function(root, factory) { (function(root, factory) {
if (typeof module !== 'undefined' && module.exports) { if (typeof module !== 'undefined' && module.exports) {
module.exports = factory; module.exports = factory;

@ -1,5 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
"use strict";
var util = require("util"); var util = require("util");
var fs = require("fs"); var fs = require("fs");
var path = require("path"); var path = require("path");

@ -1,3 +1,5 @@
"use strict";
var arrays = require("./utils/arrays"), var arrays = require("./utils/arrays"),
objects = require("./utils/objects"); objects = require("./utils/objects");

@ -1,3 +1,5 @@
"use strict";
var arrays = require("../utils/arrays"), var arrays = require("../utils/arrays"),
visitor = require("./visitor"); visitor = require("./visitor");

@ -1,3 +1,5 @@
"use strict";
function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
/* JavaScript code generation helpers. */ /* JavaScript code generation helpers. */

@ -1,3 +1,5 @@
"use strict";
/* Bytecode instruction opcodes. */ /* Bytecode instruction opcodes. */
var opcodes = { var opcodes = {
/* Stack Manipulation */ /* Stack Manipulation */

@ -1,3 +1,5 @@
"use strict";
var arrays = require("../../utils/arrays"), var arrays = require("../../utils/arrays"),
objects = require("../../utils/objects"), objects = require("../../utils/objects"),
asts = require("../asts"), asts = require("../asts"),

@ -1,3 +1,5 @@
"use strict";
var arrays = require("../../utils/arrays"), var arrays = require("../../utils/arrays"),
asts = require("../asts"), asts = require("../asts"),
op = require("../opcodes"), op = require("../opcodes"),

@ -1,3 +1,5 @@
"use strict";
var arrays = require("../../utils/arrays"), var arrays = require("../../utils/arrays"),
visitor = require("../visitor"); visitor = require("../visitor");

@ -1,3 +1,5 @@
"use strict";
var GrammarError = require("../../grammar-error"), var GrammarError = require("../../grammar-error"),
asts = require("../asts"), asts = require("../asts"),
visitor = require("../visitor"); visitor = require("../visitor");

@ -1,3 +1,5 @@
"use strict";
var arrays = require("../../utils/arrays"), var arrays = require("../../utils/arrays"),
GrammarError = require("../../grammar-error"), GrammarError = require("../../grammar-error"),
asts = require("../asts"), asts = require("../asts"),

@ -1,3 +1,5 @@
"use strict";
var GrammarError = require("../../grammar-error"), var GrammarError = require("../../grammar-error"),
asts = require("../asts"), asts = require("../asts"),
visitor = require("../visitor"); visitor = require("../visitor");

@ -1,3 +1,5 @@
"use strict";
var objects = require("../utils/objects"), var objects = require("../utils/objects"),
arrays = require("../utils/arrays"); arrays = require("../utils/arrays");

@ -1,3 +1,5 @@
"use strict";
var classes = require("./utils/classes"); var classes = require("./utils/classes");
/* Thrown when the grammar contains an error. */ /* Thrown when the grammar contains an error. */

@ -1,3 +1,5 @@
"use strict";
var arrays = require("./utils/arrays"), var arrays = require("./utils/arrays"),
objects = require("./utils/objects"); objects = require("./utils/objects");

@ -1,3 +1,5 @@
"use strict";
/* Array utilities. */ /* Array utilities. */
var arrays = { var arrays = {
range: function(start, stop) { range: function(start, stop) {

@ -1,3 +1,5 @@
"use strict";
/* Class utilities */ /* Class utilities */
var classes = { var classes = {
subclass: function(child, parent) { subclass: function(child, parent) {

@ -1,3 +1,5 @@
"use strict";
/* Object utilities. */ /* Object utilities. */
var objects = { var objects = {
keys: function(object) { keys: function(object) {

@ -1,3 +1,7 @@
/* global describe, expect, it, PEG, spyOn */
"use strict";
describe("generated parser API", function() { describe("generated parser API", function() {
describe("parse", function() { describe("parse", function() {
it("parses input", function() { it("parses input", function() {

@ -1,3 +1,7 @@
/* global describe, expect, it, PEG, spyOn */
"use strict";
describe("PEG.js API", function() { describe("PEG.js API", function() {
describe("buildParser", function() { describe("buildParser", function() {
it("builds a parser", function() { it("builds a parser", function() {

@ -1,3 +1,7 @@
/* global beforeEach, describe, expect, it, jasmine, PEG */
"use strict";
describe("plugin API", function() { describe("plugin API", function() {
beforeEach(function() { beforeEach(function() {
this.addMatchers({ this.addMatchers({

@ -1,3 +1,7 @@
/* global beforeEach, describe, expect, it, jasmine, PEG */
"use strict";
describe("generated parser behavior", function() { describe("generated parser behavior", function() {
function varyOptimizationOptions(block) { function varyOptimizationOptions(block) {
function clone(object) { function clone(object) {

@ -1,3 +1,5 @@
"use strict";
(function(root) { (function(root) {
if (typeof module !== 'undefined') { if (typeof module !== 'undefined') {
root.PEG = require("../lib/peg.js"); root.PEG = require("../lib/peg.js");

@ -1,3 +1,7 @@
/* global describe, expect, it, PEG */
"use strict";
describe("compiler pass |generateBytecode|", function() { describe("compiler pass |generateBytecode|", function() {
var pass = PEG.compiler.passes.generate.generateBytecode; var pass = PEG.compiler.passes.generate.generateBytecode;

@ -1,3 +1,7 @@
/* global beforeEach, jasmine, PEG */
"use strict";
beforeEach(function() { beforeEach(function() {
this.addMatchers({ this.addMatchers({
toChangeAST: function(grammar) { toChangeAST: function(grammar) {

@ -1,3 +1,7 @@
/* global describe, expect, it, PEG */
"use strict";
describe("compiler pass |removeProxyRules|", function() { describe("compiler pass |removeProxyRules|", function() {
var pass = PEG.compiler.passes.transform.removeProxyRules; var pass = PEG.compiler.passes.transform.removeProxyRules;

@ -1,3 +1,7 @@
/* global describe, expect, it, PEG */
"use strict";
describe("compiler pass |reportLeftRecursion|", function() { describe("compiler pass |reportLeftRecursion|", function() {
var pass = PEG.compiler.passes.check.reportInfiniteLoops; var pass = PEG.compiler.passes.check.reportInfiniteLoops;

@ -1,3 +1,7 @@
/* global describe, expect, it, PEG */
"use strict";
describe("compiler pass |reportLeftRecursion|", function() { describe("compiler pass |reportLeftRecursion|", function() {
var pass = PEG.compiler.passes.check.reportLeftRecursion; var pass = PEG.compiler.passes.check.reportLeftRecursion;

@ -1,3 +1,7 @@
/* global describe, expect, it, PEG */
"use strict";
describe("compiler pass |reportMissingRules|", function() { describe("compiler pass |reportMissingRules|", function() {
var pass = PEG.compiler.passes.check.reportMissingRules; var pass = PEG.compiler.passes.check.reportMissingRules;

@ -1,3 +1,7 @@
/* global beforeEach, describe, expect, it, jasmine, PEG */
"use strict";
describe("PEG.js grammar parser", function() { describe("PEG.js grammar parser", function() {
var literalAbcd = { type: "literal", value: "abcd", ignoreCase: false }, var literalAbcd = { type: "literal", value: "abcd", ignoreCase: false },
literalEfgh = { type: "literal", value: "efgh", ignoreCase: false }, literalEfgh = { type: "literal", value: "efgh", ignoreCase: false },

Loading…
Cancel
Save