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.
redux
David Majda 8 years ago
parent 057a93fbc7
commit 0847a69643

@ -74,7 +74,7 @@ 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)
$(BROWSERIFY) --standalone PEG $(MAIN_FILE) >> $(BROWSER_FILE_DEV) $(BROWSERIFY) --standalone peg $(MAIN_FILE) >> $(BROWSER_FILE_DEV)
$(UGLIFYJS) \ $(UGLIFYJS) \
--mangle \ --mangle \

@ -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 * `--plugin` — makes PEG.js use a specified plugin (can be specified multiple
times) times)
* `--extra-options` — additional options (in JSON format) to pass to * `--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 * `--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 * `--trace` — makes the parser trace its progress
### JavaScript API ### JavaScript API
In Node.js, require the PEG.js parser generator module: 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 In browser, include the PEG.js library in your web page or application using the
`<script>` tag. If PEG.js detects an AMD loader, it will define itself as a `<script>` tag. If PEG.js detects an AMD loader, it will define itself as a
module, otherwise the API will be available in the `PEG` global object. module, otherwise the API will be available in the `peg` global object.
To generate a parser, call the `PEG.buildParser` method and pass your grammar as To generate a parser, call the `peg.buildParser` method and pass your grammar as
a parameter: a parameter:
var parser = PEG.buildParser("start = ('a' / 'b')+"); var parser = peg.buildParser("start = ('a' / 'b')+");
The method will return generated parser object or its source code as a string The method will return generated parser object or its source code as a string
(depending on the value of the `output` option — see below). It will throw an (depending on the value of the `output` option — see below). It will throw an
@ -113,7 +113,7 @@ exception if the grammar is invalid. The exception will contain `message`
property with more details about the error. property with more details about the error.
You can tweak the generated parser by passing a second parameter with an options You can tweak the generated parser by passing a second parameter with an options
object to `PEG.buildParser`. The following options are supported: object to `peg.buildParser`. The following options are supported:
* `cache` — if `true`, makes the parser cache results, avoiding exponential * `cache` — if `true`, makes the parser cache results, avoiding exponential
parsing time in pathological cases but making the parser slower (default: parsing time in pathological cases but making the parser slower (default:

@ -6,10 +6,10 @@
"use strict"; "use strict";
var fs = require("fs"); var fs = require("fs");
var PEG = require("../lib/peg"); var peg = require("../lib/peg");
var benchmarks = require("./benchmarks.js"); var benchmarks = require("./benchmarks.js");
var Runner = require("./runner.js")(PEG); var Runner = require("./runner.js")(peg);
/* Results Table Manipulation */ /* Results Table Manipulation */

@ -6,9 +6,9 @@
if (typeof module !== 'undefined' && module.exports) { if (typeof module !== 'undefined' && module.exports) {
module.exports = factory; module.exports = factory;
} else { } else {
root.Runner = factory(root.PEG); root.Runner = factory(root.peg);
} }
}(this, function(PEG) { }(this, function(peg) {
return { return {
run: function(benchmarks, runCount, options, callbacks) { run: function(benchmarks, runCount, options, callbacks) {
@ -63,7 +63,7 @@
return function() { return function() {
callbacks.benchmarkStart(benchmarks[i]); callbacks.benchmarkStart(benchmarks[i]);
state.parser = PEG.buildParser( state.parser = peg.buildParser(
callbacks.readFile("../examples/" + benchmarks[i].id + ".pegjs"), callbacks.readFile("../examples/" + benchmarks[i].id + ".pegjs"),
options options
); );

@ -4,12 +4,12 @@
var fs = require("fs"); var fs = require("fs");
var path = require("path"); var path = require("path");
var PEG = require("../lib/peg"); var peg = require("../lib/peg");
/* Helpers */ /* Helpers */
function printVersion() { function printVersion() {
console.log("PEG.js " + PEG.VERSION); console.log("PEG.js " + peg.VERSION);
} }
function printHelp() { function printHelp() {
@ -39,9 +39,9 @@ function printHelp() {
console.log(" --plugin <plugin> use a specified plugin (can be specified"); console.log(" --plugin <plugin> use a specified plugin (can be specified");
console.log(" multiple times)"); console.log(" multiple times)");
console.log(" --extra-options <options> additional options (in JSON format) to pass"); console.log(" --extra-options <options> additional options (in JSON format) to pass");
console.log(" to PEG.buildParser"); console.log(" to peg.buildParser");
console.log(" --extra-options-file <file> file with additional options (in JSON"); console.log(" --extra-options-file <file> file with additional options (in JSON");
console.log(" format) to pass to PEG.buildParser"); console.log(" format) to pass to peg.buildParser");
console.log(" -v, --version print version information and exit"); console.log(" -v, --version print version information and exit");
console.log(" -h, --help print help and exit"); console.log(" -h, --help print help and exit");
} }
@ -272,7 +272,7 @@ readStream(inputStream, function(input) {
var source; var source;
try { try {
source = PEG.buildParser(input, options); source = peg.buildParser(input, options);
} catch (e) { } catch (e) {
if (e.location !== undefined) { if (e.location !== undefined) {
abort(e.location.start.line + ":" + e.location.start.column + ": " + e.message); abort(e.location.start.line + ":" + e.location.start.column + ": " + e.message);

@ -15,7 +15,7 @@ var compiler = {
* *
* Each pass is a function that is passed the AST. It can perform checks on it * Each pass is a function that is passed the AST. It can perform checks on it
* or modify it as needed. If the pass encounters a semantic error, it throws * or modify it as needed. If the pass encounters a semantic error, it throws
* |PEG.GrammarError|. * |peg.GrammarError|.
*/ */
passes: { passes: {
check: { check: {
@ -33,7 +33,7 @@ var compiler = {
}, },
/* /*
* Generates a parser from a specified grammar AST. Throws |PEG.GrammarError| * Generates a parser from a specified grammar AST. Throws |peg.GrammarError|
* 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.

@ -3,7 +3,7 @@
var arrays = require("./utils/arrays"), var arrays = require("./utils/arrays"),
objects = require("./utils/objects"); objects = require("./utils/objects");
var PEG = { var peg = {
/* PEG.js version (uses semantic versioning). */ /* PEG.js version (uses semantic versioning). */
VERSION: "0.9.0", VERSION: "0.9.0",
@ -17,8 +17,8 @@ var PEG = {
* The grammar must be a string in the format described by the metagramar in * The grammar must be a string in the format described by the metagramar in
* the parser.pegjs file. * the parser.pegjs file.
* *
* Throws |PEG.parser.SyntaxError| if the grammar contains a syntax error or * Throws |peg.parser.SyntaxError| if the grammar contains a syntax error or
* |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.
*/ */
@ -55,4 +55,4 @@ var PEG = {
} }
}; };
module.exports = PEG; module.exports = peg;

@ -1,24 +1,24 @@
/* eslint no-console: 0 */ /* eslint no-console: 0 */
/* global PEG, console */ /* global peg, console */
"use strict"; "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() {
var parser = PEG.buildParser('start = "a"'); var parser = peg.buildParser('start = "a"');
expect(parser.parse("a")).toBe("a"); expect(parser.parse("a")).toBe("a");
}); });
it("throws an exception on syntax error", function() { it("throws an exception on syntax error", function() {
var parser = PEG.buildParser('start = "a"'); var parser = peg.buildParser('start = "a"');
expect(function() { parser.parse("b"); }).toThrow(); expect(function() { parser.parse("b"); }).toThrow();
}); });
describe("start rule", function() { describe("start rule", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'a = "x" { return "a"; }', 'a = "x" { return "a"; }',
'b = "x" { return "b"; }', 'b = "x" { return "b"; }',
'c = "x" { return "c"; }' 'c = "x" { return "c"; }'
@ -47,7 +47,7 @@ describe("generated parser API", function() {
}); });
describe("tracing", function() { describe("tracing", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'start = a / b', 'start = a / b',
'a = "a"', 'a = "a"',
'b = "b"' 'b = "b"'
@ -135,7 +135,7 @@ describe("generated parser API", function() {
}); });
it("accepts custom options", function() { it("accepts custom options", function() {
var parser = PEG.buildParser('start = "a"'); var parser = peg.buildParser('start = "a"');
parser.parse("a", { foo: 42 }); parser.parse("a", { foo: 42 });
}); });

@ -1,22 +1,22 @@
/* global PEG */ /* global peg */
"use strict"; "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() {
var parser = PEG.buildParser('start = "a"'); var parser = peg.buildParser('start = "a"');
expect(typeof parser).toBe("object"); expect(typeof parser).toBe("object");
expect(parser.parse("a")).toBe("a"); expect(parser.parse("a")).toBe("a");
}); });
it("throws an exception on syntax error", function() { it("throws an exception on syntax error", function() {
expect(function() { PEG.buildParser('start = @'); }).toThrow(); expect(function() { peg.buildParser('start = @'); }).toThrow();
}); });
it("throws an exception on semantic error", function() { it("throws an exception on semantic error", function() {
expect(function() { PEG.buildParser('start = missing'); }).toThrow(); expect(function() { peg.buildParser('start = missing'); }).toThrow();
}); });
describe("allowed start rules", function() { describe("allowed start rules", function() {
@ -34,7 +34,7 @@ describe("PEG.js API", function() {
describe("when optimizing for parsing speed", function() { describe("when optimizing for parsing speed", function() {
describe("when |allowedStartRules| is not set", function() { describe("when |allowedStartRules| is not set", function() {
it("generated parser can start only from the first rule", function() { it("generated parser can start only from the first rule", function() {
var parser = PEG.buildParser(grammar, { optimize: "speed" }); var parser = peg.buildParser(grammar, { optimize: "speed" });
expect(parser.parse("x", { startRule: "a" })).toBe("x"); expect(parser.parse("x", { startRule: "a" })).toBe("x");
expect( expect(
@ -48,7 +48,7 @@ describe("PEG.js API", function() {
describe("when |allowedStartRules| is set", function() { describe("when |allowedStartRules| is set", function() {
it("generated parser can start only from specified rules", function() { it("generated parser can start only from specified rules", function() {
var parser = PEG.buildParser(grammar, { var parser = peg.buildParser(grammar, {
optimize: "speed", optimize: "speed",
allowedStartRules: ["b", "c"] allowedStartRules: ["b", "c"]
}); });
@ -65,7 +65,7 @@ describe("PEG.js API", function() {
describe("when optimizing for code size", function() { describe("when optimizing for code size", function() {
describe("when |allowedStartRules| is not set", function() { describe("when |allowedStartRules| is not set", function() {
it("generated parser can start only from the first rule", function() { it("generated parser can start only from the first rule", function() {
var parser = PEG.buildParser(grammar, { optimize: "size" }); var parser = peg.buildParser(grammar, { optimize: "size" });
expect(parser.parse("x", { startRule: "a" })).toBe("x"); expect(parser.parse("x", { startRule: "a" })).toBe("x");
expect( expect(
@ -79,7 +79,7 @@ describe("PEG.js API", function() {
describe("when |allowedStartRules| is set", function() { describe("when |allowedStartRules| is set", function() {
it("generated parser can start only from specified rules", function() { it("generated parser can start only from specified rules", function() {
var parser = PEG.buildParser(grammar, { var parser = peg.buildParser(grammar, {
optimize: "size", optimize: "size",
allowedStartRules: ["b", "c"] allowedStartRules: ["b", "c"]
}); });
@ -103,7 +103,7 @@ describe("PEG.js API", function() {
describe("when |cache| is not set", function() { describe("when |cache| is not set", function() {
it("generated parser doesn't cache intermediate parse results", function() { it("generated parser doesn't cache intermediate parse results", function() {
var parser = PEG.buildParser(grammar); var parser = peg.buildParser(grammar);
expect(parser.parse("ac")).toBe(2); expect(parser.parse("ac")).toBe(2);
}); });
@ -111,7 +111,7 @@ describe("PEG.js API", function() {
describe("when |cache| is set to |false|", function() { describe("when |cache| is set to |false|", function() {
it("generated parser doesn't cache intermediate parse results", function() { it("generated parser doesn't cache intermediate parse results", function() {
var parser = PEG.buildParser(grammar, { cache: false }); var parser = peg.buildParser(grammar, { cache: false });
expect(parser.parse("ac")).toBe(2); expect(parser.parse("ac")).toBe(2);
}); });
@ -119,7 +119,7 @@ describe("PEG.js API", function() {
describe("when |cache| is set to |true|", function() { describe("when |cache| is set to |true|", function() {
it("generated parser caches intermediate parse results", function() { it("generated parser caches intermediate parse results", function() {
var parser = PEG.buildParser(grammar, { cache: true }); var parser = peg.buildParser(grammar, { cache: true });
expect(parser.parse("ac")).toBe(1); expect(parser.parse("ac")).toBe(1);
}); });
@ -131,7 +131,7 @@ describe("PEG.js API", function() {
describe("when |trace| is not set", function() { describe("when |trace| is not set", function() {
it("generated parser doesn't trace", function() { it("generated parser doesn't trace", function() {
var parser = PEG.buildParser(grammar), var parser = peg.buildParser(grammar),
tracer = jasmine.createSpyObj("tracer", ["trace"]); tracer = jasmine.createSpyObj("tracer", ["trace"]);
parser.parse("a", { tracer: tracer }); parser.parse("a", { tracer: tracer });
@ -142,7 +142,7 @@ describe("PEG.js API", function() {
describe("when |trace| is set to |false|", function() { describe("when |trace| is set to |false|", function() {
it("generated parser doesn't trace", function() { it("generated parser doesn't trace", function() {
var parser = PEG.buildParser(grammar, { trace: false }), var parser = peg.buildParser(grammar, { trace: false }),
tracer = jasmine.createSpyObj("tracer", ["trace"]); tracer = jasmine.createSpyObj("tracer", ["trace"]);
parser.parse("a", { tracer: tracer }); parser.parse("a", { tracer: tracer });
@ -153,7 +153,7 @@ describe("PEG.js API", function() {
describe("when |trace| is set to |true|", function() { describe("when |trace| is set to |true|", function() {
it("generated parser traces", function() { it("generated parser traces", function() {
var parser = PEG.buildParser(grammar, { trace: true }), var parser = peg.buildParser(grammar, { trace: true }),
tracer = jasmine.createSpyObj("tracer", ["trace"]); tracer = jasmine.createSpyObj("tracer", ["trace"]);
parser.parse("a", { tracer: tracer }); parser.parse("a", { tracer: tracer });
@ -173,7 +173,7 @@ describe("PEG.js API", function() {
describe("when |output| is not set", function() { describe("when |output| is not set", function() {
it("returns generated parser object", function() { it("returns generated parser object", function() {
var parser = PEG.buildParser(grammar); var parser = peg.buildParser(grammar);
expect(typeof parser).toBe("object"); expect(typeof parser).toBe("object");
expect(parser.parse("a")).toBe("a"); expect(parser.parse("a")).toBe("a");
@ -182,7 +182,7 @@ describe("PEG.js API", function() {
describe("when |output| is set to |\"parser\"|", function() { describe("when |output| is set to |\"parser\"|", function() {
it("returns generated parser object", function() { it("returns generated parser object", function() {
var parser = PEG.buildParser(grammar, { output: "parser" }); var parser = peg.buildParser(grammar, { output: "parser" });
expect(typeof parser).toBe("object"); expect(typeof parser).toBe("object");
expect(parser.parse("a")).toBe("a"); expect(parser.parse("a")).toBe("a");
@ -191,7 +191,7 @@ describe("PEG.js API", function() {
describe("when |output| is set to |\"source\"|", function() { describe("when |output| is set to |\"source\"|", function() {
it("returns generated parser source code", function() { it("returns generated parser source code", function() {
var source = PEG.buildParser(grammar, { output: "source" }); var source = peg.buildParser(grammar, { output: "source" });
expect(typeof source).toBe("string"); expect(typeof source).toBe("string");
expect(eval(source).parse("a")).toBe("a"); expect(eval(source).parse("a")).toBe("a");
@ -208,7 +208,7 @@ describe("PEG.js API", function() {
/* The |plugins| option is tested in plugin API specs. */ /* The |plugins| option is tested in plugin API specs. */
it("accepts custom options", function() { it("accepts custom options", function() {
PEG.buildParser('start = "a"', { foo: 42 }); peg.buildParser('start = "a"', { foo: 42 });
}); });
}); });
}); });

@ -1,4 +1,4 @@
/* global PEG */ /* global peg */
"use strict"; "use strict";
@ -48,7 +48,7 @@ describe("plugin API", function() {
{ use: function() { pluginsUsed[2] = true; } } { use: function() { pluginsUsed[2] = true; } }
]; ];
PEG.buildParser(grammar, { plugins: plugins }); peg.buildParser(grammar, { plugins: plugins });
expect(pluginsUsed).toEqual([true, true, true]); expect(pluginsUsed).toEqual([true, true, true]);
}); });
@ -82,7 +82,7 @@ describe("plugin API", function() {
} }
}; };
PEG.buildParser(grammar, { plugins: [plugin] }); peg.buildParser(grammar, { plugins: [plugin] });
}); });
it("receives options", function() { it("receives options", function() {
@ -93,13 +93,13 @@ describe("plugin API", function() {
}, },
buildParserOptions = { plugins: [plugin], foo: 42 }; buildParserOptions = { plugins: [plugin], foo: 42 };
PEG.buildParser(grammar, buildParserOptions); peg.buildParser(grammar, buildParserOptions);
}); });
it("can replace parser", function() { it("can replace parser", function() {
var plugin = { var plugin = {
use: function(config) { use: function(config) {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'start = .* {', 'start = .* {',
' return {', ' return {',
' type: "grammar",', ' type: "grammar",',
@ -117,7 +117,7 @@ describe("plugin API", function() {
config.parser = parser; config.parser = parser;
} }
}, },
parser = PEG.buildParser('a', { plugins: [plugin] }); parser = peg.buildParser('a', { plugins: [plugin] });
expect(parser.parse("a")).toBe("a"); expect(parser.parse("a")).toBe("a");
}); });
@ -132,7 +132,7 @@ describe("plugin API", function() {
config.passes.generate = [pass]; config.passes.generate = [pass];
} }
}, },
parser = PEG.buildParser(grammar, { plugins: [plugin] }); parser = peg.buildParser(grammar, { plugins: [plugin] });
expect(parser.parse("a")).toBe(42); expect(parser.parse("a")).toBe(42);
}); });
@ -148,7 +148,7 @@ describe("plugin API", function() {
options.allowedStartRules = ["b", "c"]; options.allowedStartRules = ["b", "c"];
} }
}, },
parser = PEG.buildParser(grammar, { parser = peg.buildParser(grammar, {
allowedStartRules: ["a"], allowedStartRules: ["a"],
plugins: [plugin] plugins: [plugin]
}); });

@ -1,4 +1,4 @@
/* global PEG */ /* global peg */
"use strict"; "use strict";
@ -130,7 +130,7 @@ describe("generated parser behavior", function() {
varyOptimizationOptions(function(options) { varyOptimizationOptions(function(options) {
describe("initializer", function() { describe("initializer", function() {
it("executes the code before parsing starts", function() { it("executes the code before parsing starts", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var result = 42; }', '{ var result = 42; }',
'start = "a" { return result; }' 'start = "a" { return result; }'
].join("\n"), options); ].join("\n"), options);
@ -140,7 +140,7 @@ describe("generated parser behavior", function() {
describe("available variables and functions", function() { describe("available variables and functions", function() {
it("|parser| contains the parser object", function() { it("|parser| contains the parser object", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var result = parser; }', '{ var result = parser; }',
'start = "a" { return result; }' 'start = "a" { return result; }'
].join("\n"), options); ].join("\n"), options);
@ -149,7 +149,7 @@ describe("generated parser behavior", function() {
}); });
it("|options| contains options", function() { it("|options| contains options", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var result = options; }', '{ var result = options; }',
'start = "a" { return result; }' 'start = "a" { return result; }'
].join("\n"), options); ].join("\n"), options);
@ -162,7 +162,7 @@ describe("generated parser behavior", function() {
describe("rule", function() { describe("rule", function() {
if (options.cache) { if (options.cache) {
it("caches rule match results", function() { it("caches rule match results", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var n = 0; }', '{ var n = 0; }',
'start = (a "b") / (a "c") { return n; }', 'start = (a "b") / (a "c") { return n; }',
'a = "a" { n++; }' 'a = "a" { n++; }'
@ -172,7 +172,7 @@ describe("generated parser behavior", function() {
}); });
} else { } else {
it("doesn't cache rule match results", function() { it("doesn't cache rule match results", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var n = 0; }', '{ var n = 0; }',
'start = (a "b") / (a "c") { return n; }', 'start = (a "b") / (a "c") { return n; }',
'a = "a" { n++; }' 'a = "a" { n++; }'
@ -184,7 +184,7 @@ describe("generated parser behavior", function() {
describe("when the expression matches", function() { describe("when the expression matches", function() {
it("returns its match result", function() { it("returns its match result", function() {
var parser = PEG.buildParser('start = "a"'); var parser = peg.buildParser('start = "a"');
expect(parser).toParse("a", "a"); expect(parser).toParse("a", "a");
}); });
@ -193,7 +193,7 @@ describe("generated parser behavior", function() {
describe("when the expression doesn't match", function() { describe("when the expression doesn't match", function() {
describe("without display name", function() { describe("without display name", function() {
it("reports match failure and doesn't record any expectation", function() { it("reports match failure and doesn't record any expectation", function() {
var parser = PEG.buildParser('start = "a"'); var parser = peg.buildParser('start = "a"');
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
expected: [{ type: "literal", value: "a", description: '"a"' }] expected: [{ type: "literal", value: "a", description: '"a"' }]
@ -203,7 +203,7 @@ describe("generated parser behavior", function() {
describe("with display name", function() { describe("with display name", function() {
it("reports match failure and records an expectation of type \"other\"", function() { it("reports match failure and records an expectation of type \"other\"", function() {
var parser = PEG.buildParser('start "start" = "a"'); var parser = peg.buildParser('start "start" = "a"');
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
expected: [{ type: "other", description: "start" }] expected: [{ type: "other", description: "start" }]
@ -211,7 +211,7 @@ describe("generated parser behavior", function() {
}); });
it("discards any expectations recorded when matching the expression", function() { it("discards any expectations recorded when matching the expression", function() {
var parser = PEG.buildParser('start "start" = "a"'); var parser = peg.buildParser('start "start" = "a"');
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
expected: [{ type: "other", description: "start" }] expected: [{ type: "other", description: "start" }]
@ -224,34 +224,34 @@ describe("generated parser behavior", function() {
describe("literal", function() { describe("literal", function() {
describe("matching", function() { describe("matching", function() {
it("matches empty literals", function() { it("matches empty literals", function() {
var parser = PEG.buildParser('start = ""', options); var parser = peg.buildParser('start = ""', options);
expect(parser).toParse(""); expect(parser).toParse("");
}); });
it("matches one-character literals", function() { it("matches one-character literals", function() {
var parser = PEG.buildParser('start = "a"', options); var parser = peg.buildParser('start = "a"', options);
expect(parser).toParse("a"); expect(parser).toParse("a");
expect(parser).toFailToParse("b"); expect(parser).toFailToParse("b");
}); });
it("matches multi-character literals", function() { it("matches multi-character literals", function() {
var parser = PEG.buildParser('start = "abcd"', options); var parser = peg.buildParser('start = "abcd"', options);
expect(parser).toParse("abcd"); expect(parser).toParse("abcd");
expect(parser).toFailToParse("efgh"); expect(parser).toFailToParse("efgh");
}); });
it("is case sensitive without the \"i\" flag", function() { it("is case sensitive without the \"i\" flag", function() {
var parser = PEG.buildParser('start = "a"', options); var parser = peg.buildParser('start = "a"', options);
expect(parser).toParse("a"); expect(parser).toParse("a");
expect(parser).toFailToParse("A"); expect(parser).toFailToParse("A");
}); });
it("is case insensitive with the \"i\" flag", function() { it("is case insensitive with the \"i\" flag", function() {
var parser = PEG.buildParser('start = "a"i', options); var parser = peg.buildParser('start = "a"i', options);
expect(parser).toParse("a"); expect(parser).toParse("a");
expect(parser).toParse("A"); expect(parser).toParse("A");
@ -260,13 +260,13 @@ describe("generated parser behavior", function() {
describe("when it matches", function() { describe("when it matches", function() {
it("returns the matched text", function() { it("returns the matched text", function() {
var parser = PEG.buildParser('start = "a"', options); var parser = peg.buildParser('start = "a"', options);
expect(parser).toParse("a", "a"); expect(parser).toParse("a", "a");
}); });
it("consumes the matched text", function() { it("consumes the matched text", function() {
var parser = PEG.buildParser('start = "a" .', options); var parser = peg.buildParser('start = "a" .', options);
expect(parser).toParse("ab"); expect(parser).toParse("ab");
}); });
@ -274,7 +274,7 @@ describe("generated parser behavior", function() {
describe("when it doesn't match", function() { describe("when it doesn't match", function() {
it("reports match failure and records an expectation of type \"literal\"", function() { it("reports match failure and records an expectation of type \"literal\"", function() {
var parser = PEG.buildParser('start = "a"', options); var parser = peg.buildParser('start = "a"', options);
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
expected: [{ type: "literal", value: "a", description: '"a"' }] expected: [{ type: "literal", value: "a", description: '"a"' }]
@ -286,13 +286,13 @@ describe("generated parser behavior", function() {
describe("character class", function() { describe("character class", function() {
describe("matching", function() { describe("matching", function() {
it("matches empty classes", function() { it("matches empty classes", function() {
var parser = PEG.buildParser('start = []', options); var parser = peg.buildParser('start = []', options);
expect(parser).toFailToParse("a"); expect(parser).toFailToParse("a");
}); });
it("matches classes with a character list", function() { it("matches classes with a character list", function() {
var parser = PEG.buildParser('start = [abc]', options); var parser = peg.buildParser('start = [abc]', options);
expect(parser).toParse("a"); expect(parser).toParse("a");
expect(parser).toParse("b"); expect(parser).toParse("b");
@ -301,7 +301,7 @@ describe("generated parser behavior", function() {
}); });
it("matches classes with a character range", function() { it("matches classes with a character range", function() {
var parser = PEG.buildParser('start = [a-c]', options); var parser = peg.buildParser('start = [a-c]', options);
expect(parser).toParse("a"); expect(parser).toParse("a");
expect(parser).toParse("b"); expect(parser).toParse("b");
@ -310,21 +310,21 @@ describe("generated parser behavior", function() {
}); });
it("matches inverted classes", function() { it("matches inverted classes", function() {
var parser = PEG.buildParser('start = [^a]', options); var parser = peg.buildParser('start = [^a]', options);
expect(parser).toFailToParse("a"); expect(parser).toFailToParse("a");
expect(parser).toParse("b"); expect(parser).toParse("b");
}); });
it("is case sensitive without the \"i\" flag", function() { it("is case sensitive without the \"i\" flag", function() {
var parser = PEG.buildParser('start = [a]', options); var parser = peg.buildParser('start = [a]', options);
expect(parser).toParse("a"); expect(parser).toParse("a");
expect(parser).toFailToParse("A"); expect(parser).toFailToParse("A");
}); });
it("is case insensitive with the \"i\" flag", function() { it("is case insensitive with the \"i\" flag", function() {
var parser = PEG.buildParser('start = [a]i', options); var parser = peg.buildParser('start = [a]i', options);
expect(parser).toParse("a"); expect(parser).toParse("a");
expect(parser).toParse("A"); expect(parser).toParse("A");
@ -333,13 +333,13 @@ describe("generated parser behavior", function() {
describe("when it matches", function() { describe("when it matches", function() {
it("returns the matched character", function() { it("returns the matched character", function() {
var parser = PEG.buildParser('start = [a]', options); var parser = peg.buildParser('start = [a]', options);
expect(parser).toParse("a", "a"); expect(parser).toParse("a", "a");
}); });
it("consumes the matched character", function() { it("consumes the matched character", function() {
var parser = PEG.buildParser('start = [a] .', options); var parser = peg.buildParser('start = [a] .', options);
expect(parser).toParse("ab"); expect(parser).toParse("ab");
}); });
@ -347,7 +347,7 @@ describe("generated parser behavior", function() {
describe("when it doesn't match", function() { describe("when it doesn't match", function() {
it("reports match failure and records an expectation of type \"class\"", function() { it("reports match failure and records an expectation of type \"class\"", function() {
var parser = PEG.buildParser('start = [a]', options); var parser = peg.buildParser('start = [a]', options);
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
expected: [{ type: "class", value: "[a]", description: "[a]" }] expected: [{ type: "class", value: "[a]", description: "[a]" }]
@ -359,7 +359,7 @@ describe("generated parser behavior", function() {
describe("dot", function() { describe("dot", function() {
describe("matching", function() { describe("matching", function() {
it("matches any character", function() { it("matches any character", function() {
var parser = PEG.buildParser('start = .', options); var parser = peg.buildParser('start = .', options);
expect(parser).toParse("a"); expect(parser).toParse("a");
expect(parser).toParse("b"); expect(parser).toParse("b");
@ -369,13 +369,13 @@ describe("generated parser behavior", function() {
describe("when it matches", function() { describe("when it matches", function() {
it("returns the matched character", function() { it("returns the matched character", function() {
var parser = PEG.buildParser('start = .', options); var parser = peg.buildParser('start = .', options);
expect(parser).toParse("a", "a"); expect(parser).toParse("a", "a");
}); });
it("consumes the matched character", function() { it("consumes the matched character", function() {
var parser = PEG.buildParser('start = . .', options); var parser = peg.buildParser('start = . .', options);
expect(parser).toParse("ab"); expect(parser).toParse("ab");
}); });
@ -383,7 +383,7 @@ describe("generated parser behavior", function() {
describe("when it doesn't match", function() { describe("when it doesn't match", function() {
it("reports match failure and records an expectation of type \"any\"", function() { it("reports match failure and records an expectation of type \"any\"", function() {
var parser = PEG.buildParser('start = .', options); var parser = peg.buildParser('start = .', options);
expect(parser).toFailToParse("", { expect(parser).toFailToParse("", {
expected: [{ type: "any", description: "any character" }] expected: [{ type: "any", description: "any character" }]
@ -395,7 +395,7 @@ describe("generated parser behavior", function() {
describe("rule reference", function() { describe("rule reference", function() {
describe("when referenced rule's expression matches", function() { describe("when referenced rule's expression matches", function() {
it("returns its result", function() { it("returns its result", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'start = a', 'start = a',
'a = "a"' 'a = "a"'
].join("\n"), options); ].join("\n"), options);
@ -406,7 +406,7 @@ describe("generated parser behavior", function() {
describe("when referenced rule's expression doesn't match", function() { describe("when referenced rule's expression doesn't match", function() {
it("reports match failure", function() { it("reports match failure", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'start = a', 'start = a',
'a = "a"' 'a = "a"'
].join("\n"), options); ].join("\n"), options);
@ -424,7 +424,7 @@ describe("generated parser behavior", function() {
* |undefined| which we can't compare against in |toParse| due to the * |undefined| which we can't compare against in |toParse| due to the
* way optional parameters work. * way optional parameters work.
*/ */
var parser = PEG.buildParser('start = &{ return true; } ""', options); var parser = peg.buildParser('start = &{ return true; } ""', options);
expect(parser).toParse("", [undefined, ""]); expect(parser).toParse("", [undefined, ""]);
}); });
@ -432,7 +432,7 @@ describe("generated parser behavior", function() {
describe("when the code returns a falsey value", function() { describe("when the code returns a falsey value", function() {
it("reports match failure", function() { it("reports match failure", function() {
var parser = PEG.buildParser('start = &{ return false; }', options); var parser = peg.buildParser('start = &{ return false; }', options);
expect(parser).toFailToParse(""); expect(parser).toFailToParse("");
}); });
@ -441,7 +441,7 @@ describe("generated parser behavior", function() {
describe("label variables", function() { describe("label variables", function() {
describe("in containing sequence", function() { describe("in containing sequence", function() {
it("can access variables defined by preceding labeled elements", function() { it("can access variables defined by preceding labeled elements", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = a:"a" &{ return a === "a"; }', 'start = a:"a" &{ return a === "a"; }',
options options
); );
@ -450,7 +450,7 @@ describe("generated parser behavior", function() {
}); });
it("cannot access variable defined by labeled predicate element", function() { it("cannot access variable defined by labeled predicate element", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = "a" b:&{ return b === undefined; } "c"', 'start = "a" b:&{ return b === undefined; } "c"',
options options
); );
@ -459,7 +459,7 @@ describe("generated parser behavior", function() {
}); });
it("cannot access variables defined by following labeled elements", function() { it("cannot access variables defined by following labeled elements", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = &{ return a === "a"; } a:"a"', 'start = &{ return a === "a"; } a:"a"',
options options
); );
@ -517,7 +517,7 @@ describe("generated parser behavior", function() {
parser, i; parser, i;
for (i = 0; i < testcases.length; i++) { for (i = 0; i < testcases.length; i++) {
parser = PEG.buildParser(testcases[i].grammar, options); parser = peg.buildParser(testcases[i].grammar, options);
expect(parser).toFailToParse(testcases[i].input); expect(parser).toFailToParse(testcases[i].input);
} }
}); });
@ -525,7 +525,7 @@ describe("generated parser behavior", function() {
describe("in outer sequence", function() { describe("in outer sequence", function() {
it("can access variables defined by preceding labeled elements", function() { it("can access variables defined by preceding labeled elements", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = a:"a" ("b" &{ return a === "a"; })', 'start = a:"a" ("b" &{ return a === "a"; })',
options options
); );
@ -534,7 +534,7 @@ describe("generated parser behavior", function() {
}); });
it("cannot access variable defined by labeled predicate element", function() { it("cannot access variable defined by labeled predicate element", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = "a" b:("b" &{ return b === undefined; }) "c"', 'start = "a" b:("b" &{ return b === undefined; }) "c"',
options options
); );
@ -543,7 +543,7 @@ describe("generated parser behavior", function() {
}); });
it("cannot access variables defined by following labeled elements", function() { it("cannot access variables defined by following labeled elements", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = ("a" &{ return b === "b"; }) b:"b"', 'start = ("a" &{ return b === "b"; }) b:"b"',
options options
); );
@ -555,7 +555,7 @@ describe("generated parser behavior", function() {
describe("initializer variables & functions", function() { describe("initializer variables & functions", function() {
it("can access variables defined in the initializer", function() { it("can access variables defined in the initializer", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var v = 42 }', '{ var v = 42 }',
'start = &{ return v === 42; }' 'start = &{ return v === 42; }'
].join("\n"), options); ].join("\n"), options);
@ -564,7 +564,7 @@ describe("generated parser behavior", function() {
}); });
it("can access functions defined in the initializer", function() { it("can access functions defined in the initializer", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ function f() { return 42; } }', '{ function f() { return 42; } }',
'start = &{ return f() === 42; }' 'start = &{ return f() === 42; }'
].join("\n"), options); ].join("\n"), options);
@ -575,7 +575,7 @@ describe("generated parser behavior", function() {
describe("available variables & functions", function() { describe("available variables & functions", function() {
it("|parser| contains the parser object", function() { it("|parser| contains the parser object", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var result; }', '{ var result; }',
'start = &{ result = parser; return true; } { return result; }' 'start = &{ result = parser; return true; } { return result; }'
].join("\n"), options); ].join("\n"), options);
@ -584,7 +584,7 @@ describe("generated parser behavior", function() {
}); });
it("|options| contains options", function() { it("|options| contains options", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var result; }', '{ var result; }',
'start = &{ result = options; return true; } { return result; }' 'start = &{ result = options; return true; } { return result; }'
].join("\n"), options); ].join("\n"), options);
@ -593,7 +593,7 @@ describe("generated parser behavior", function() {
}); });
it("|location| returns current location info", function() { it("|location| returns current location info", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var result; }', '{ var result; }',
'start = line (nl+ line)* { return result; }', 'start = line (nl+ line)* { return result; }',
'line = thing (" "+ thing)*', 'line = thing (" "+ thing)*',
@ -629,7 +629,7 @@ describe("generated parser behavior", function() {
* |undefined| which we can't compare against in |toParse| due to the * |undefined| which we can't compare against in |toParse| due to the
* way optional parameters work. * way optional parameters work.
*/ */
var parser = PEG.buildParser('start = !{ return false; } ""', options); var parser = peg.buildParser('start = !{ return false; } ""', options);
expect(parser).toParse("", [undefined, ""]); expect(parser).toParse("", [undefined, ""]);
}); });
@ -637,7 +637,7 @@ describe("generated parser behavior", function() {
describe("when the code returns a truthy value", function() { describe("when the code returns a truthy value", function() {
it("reports match failure", function() { it("reports match failure", function() {
var parser = PEG.buildParser('start = !{ return true; }', options); var parser = peg.buildParser('start = !{ return true; }', options);
expect(parser).toFailToParse(""); expect(parser).toFailToParse("");
}); });
@ -646,7 +646,7 @@ describe("generated parser behavior", function() {
describe("label variables", function() { describe("label variables", function() {
describe("in containing sequence", function() { describe("in containing sequence", function() {
it("can access variables defined by preceding labeled elements", function() { it("can access variables defined by preceding labeled elements", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = a:"a" !{ return a !== "a"; }', 'start = a:"a" !{ return a !== "a"; }',
options options
); );
@ -655,7 +655,7 @@ describe("generated parser behavior", function() {
}); });
it("cannot access variable defined by labeled predicate element", function() { it("cannot access variable defined by labeled predicate element", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = "a" b:!{ return b !== undefined; } "c"', 'start = "a" b:!{ return b !== undefined; } "c"',
options options
); );
@ -664,7 +664,7 @@ describe("generated parser behavior", function() {
}); });
it("cannot access variables defined by following labeled elements", function() { it("cannot access variables defined by following labeled elements", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = !{ return a !== "a"; } a:"a"', 'start = !{ return a !== "a"; } a:"a"',
options options
); );
@ -722,7 +722,7 @@ describe("generated parser behavior", function() {
parser, i; parser, i;
for (i = 0; i < testcases.length; i++) { for (i = 0; i < testcases.length; i++) {
parser = PEG.buildParser(testcases[i].grammar, options); parser = peg.buildParser(testcases[i].grammar, options);
expect(parser).toFailToParse(testcases[i].input); expect(parser).toFailToParse(testcases[i].input);
} }
}); });
@ -730,7 +730,7 @@ describe("generated parser behavior", function() {
describe("in outer sequence", function() { describe("in outer sequence", function() {
it("can access variables defined by preceding labeled elements", function() { it("can access variables defined by preceding labeled elements", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = a:"a" ("b" !{ return a !== "a"; })', 'start = a:"a" ("b" !{ return a !== "a"; })',
options options
); );
@ -739,7 +739,7 @@ describe("generated parser behavior", function() {
}); });
it("cannot access variable defined by labeled predicate element", function() { it("cannot access variable defined by labeled predicate element", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = "a" b:("b" !{ return b !== undefined; }) "c"', 'start = "a" b:("b" !{ return b !== undefined; }) "c"',
options options
); );
@ -748,7 +748,7 @@ describe("generated parser behavior", function() {
}); });
it("cannot access variables defined by following labeled elements", function() { it("cannot access variables defined by following labeled elements", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = ("a" !{ return b !== "b"; }) b:"b"', 'start = ("a" !{ return b !== "b"; }) b:"b"',
options options
); );
@ -760,7 +760,7 @@ describe("generated parser behavior", function() {
describe("initializer variables & functions", function() { describe("initializer variables & functions", function() {
it("can access variables defined in the initializer", function() { it("can access variables defined in the initializer", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var v = 42 }', '{ var v = 42 }',
'start = !{ return v !== 42; }' 'start = !{ return v !== 42; }'
].join("\n"), options); ].join("\n"), options);
@ -769,7 +769,7 @@ describe("generated parser behavior", function() {
}); });
it("can access functions defined in the initializer", function() { it("can access functions defined in the initializer", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ function f() { return 42; } }', '{ function f() { return 42; } }',
'start = !{ return f() !== 42; }' 'start = !{ return f() !== 42; }'
].join("\n"), options); ].join("\n"), options);
@ -780,7 +780,7 @@ describe("generated parser behavior", function() {
describe("available variables & functions", function() { describe("available variables & functions", function() {
it("|parser| contains the parser object", function() { it("|parser| contains the parser object", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var result; }', '{ var result; }',
'start = !{ result = parser; return false; } { return result; }' 'start = !{ result = parser; return false; } { return result; }'
].join("\n"), options); ].join("\n"), options);
@ -789,7 +789,7 @@ describe("generated parser behavior", function() {
}); });
it("|options| contains options", function() { it("|options| contains options", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var result; }', '{ var result; }',
'start = !{ result = options; return false; } { return result; }' 'start = !{ result = options; return false; } { return result; }'
].join("\n"), options); ].join("\n"), options);
@ -798,7 +798,7 @@ describe("generated parser behavior", function() {
}); });
it("|location| returns current location info", function() { it("|location| returns current location info", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var result; }', '{ var result; }',
'start = line (nl+ line)* { return result; }', 'start = line (nl+ line)* { return result; }',
'line = thing (" "+ thing)*', 'line = thing (" "+ thing)*',
@ -829,7 +829,7 @@ describe("generated parser behavior", function() {
describe("group", function() { describe("group", function() {
describe("when the expression matches", function() { describe("when the expression matches", function() {
it("returns its match result", function() { it("returns its match result", function() {
var parser = PEG.buildParser('start = ("a")', options); var parser = peg.buildParser('start = ("a")', options);
expect(parser).toParse("a", "a"); expect(parser).toParse("a", "a");
}); });
@ -837,7 +837,7 @@ describe("generated parser behavior", function() {
describe("when the expression doesn't match", function() { describe("when the expression doesn't match", function() {
it("reports match failure", function() { it("reports match failure", function() {
var parser = PEG.buildParser('start = ("a")', options); var parser = peg.buildParser('start = ("a")', options);
expect(parser).toFailToParse("b"); expect(parser).toFailToParse("b");
}); });
@ -847,7 +847,7 @@ describe("generated parser behavior", function() {
describe("optional", function() { describe("optional", function() {
describe("when the expression matches", function() { describe("when the expression matches", function() {
it("returns its match result", function() { it("returns its match result", function() {
var parser = PEG.buildParser('start = "a"?', options); var parser = peg.buildParser('start = "a"?', options);
expect(parser).toParse("a", "a"); expect(parser).toParse("a", "a");
}); });
@ -855,7 +855,7 @@ describe("generated parser behavior", function() {
describe("when the expression doesn't match", function() { describe("when the expression doesn't match", function() {
it("returns |null|", function() { it("returns |null|", function() {
var parser = PEG.buildParser('start = "a"?', options); var parser = peg.buildParser('start = "a"?', options);
expect(parser).toParse("", null); expect(parser).toParse("", null);
}); });
@ -865,7 +865,7 @@ describe("generated parser behavior", function() {
describe("zero or more", function() { describe("zero or more", function() {
describe("when the expression matches zero or more times", function() { describe("when the expression matches zero or more times", function() {
it("returns an array of its match results", function() { it("returns an array of its match results", function() {
var parser = PEG.buildParser('start = "a"*', options); var parser = peg.buildParser('start = "a"*', options);
expect(parser).toParse("", []); expect(parser).toParse("", []);
expect(parser).toParse("a", ["a"]); expect(parser).toParse("a", ["a"]);
@ -877,7 +877,7 @@ describe("generated parser behavior", function() {
describe("one or more", function() { describe("one or more", function() {
describe("when the expression matches one or more times", function() { describe("when the expression matches one or more times", function() {
it("returns an array of its match results", function() { it("returns an array of its match results", function() {
var parser = PEG.buildParser('start = "a"+', options); var parser = peg.buildParser('start = "a"+', options);
expect(parser).toParse("a", ["a"]); expect(parser).toParse("a", ["a"]);
expect(parser).toParse("aaa", ["a", "a", "a"]); expect(parser).toParse("aaa", ["a", "a", "a"]);
@ -886,7 +886,7 @@ describe("generated parser behavior", function() {
describe("when the expression doesn't match", function() { describe("when the expression doesn't match", function() {
it("reports match failure", function() { it("reports match failure", function() {
var parser = PEG.buildParser('start = "a"+', options); var parser = peg.buildParser('start = "a"+', options);
expect(parser).toFailToParse(""); expect(parser).toFailToParse("");
}); });
@ -896,7 +896,7 @@ describe("generated parser behavior", function() {
describe("text", function() { describe("text", function() {
describe("when the expression matches", function() { describe("when the expression matches", function() {
it("returns the matched text", function() { it("returns the matched text", function() {
var parser = PEG.buildParser('start = $("a" "b" "c")', options); var parser = peg.buildParser('start = $("a" "b" "c")', options);
expect(parser).toParse("abc", "abc"); expect(parser).toParse("abc", "abc");
}); });
@ -904,7 +904,7 @@ describe("generated parser behavior", function() {
describe("when the expression doesn't match", function() { describe("when the expression doesn't match", function() {
it("reports match failure", function() { it("reports match failure", function() {
var parser = PEG.buildParser('start = $("a")', options); var parser = peg.buildParser('start = $("a")', options);
expect(parser).toFailToParse("b"); expect(parser).toFailToParse("b");
}); });
@ -914,13 +914,13 @@ describe("generated parser behavior", function() {
describe("positive simple predicate", function() { describe("positive simple predicate", function() {
describe("when the expression matches", function() { describe("when the expression matches", function() {
it("returns |undefined|", function() { it("returns |undefined|", function() {
var parser = PEG.buildParser('start = &"a" "a"', options); var parser = peg.buildParser('start = &"a" "a"', options);
expect(parser).toParse("a", [undefined, "a"]); expect(parser).toParse("a", [undefined, "a"]);
}); });
it("resets parse position", function() { it("resets parse position", function() {
var parser = PEG.buildParser('start = &"a" "a"', options); var parser = peg.buildParser('start = &"a" "a"', options);
expect(parser).toParse("a"); expect(parser).toParse("a");
}); });
@ -928,13 +928,13 @@ describe("generated parser behavior", function() {
describe("when the expression doesn't match", function() { describe("when the expression doesn't match", function() {
it("reports match failure", function() { it("reports match failure", function() {
var parser = PEG.buildParser('start = &"a"', options); var parser = peg.buildParser('start = &"a"', options);
expect(parser).toFailToParse("b"); expect(parser).toFailToParse("b");
}); });
it("discards any expectations recorded when matching the expression", function() { it("discards any expectations recorded when matching the expression", function() {
var parser = PEG.buildParser('start = "a" / &"b" / "c"', options); var parser = peg.buildParser('start = "a" / &"b" / "c"', options);
expect(parser).toFailToParse("d", { expect(parser).toFailToParse("d", {
expected: [ expected: [
@ -949,7 +949,7 @@ describe("generated parser behavior", function() {
describe("negative simple predicate", function() { describe("negative simple predicate", function() {
describe("when the expression matches", function() { describe("when the expression matches", function() {
it("reports match failure", function() { it("reports match failure", function() {
var parser = PEG.buildParser('start = !"a"', options); var parser = peg.buildParser('start = !"a"', options);
expect(parser).toFailToParse("a"); expect(parser).toFailToParse("a");
}); });
@ -957,19 +957,19 @@ describe("generated parser behavior", function() {
describe("when the expression doesn't match", function() { describe("when the expression doesn't match", function() {
it("returns |undefined|", function() { it("returns |undefined|", function() {
var parser = PEG.buildParser('start = !"a" "b"', options); var parser = peg.buildParser('start = !"a" "b"', options);
expect(parser).toParse("b", [undefined, "b"]); expect(parser).toParse("b", [undefined, "b"]);
}); });
it("resets parse position", function() { it("resets parse position", function() {
var parser = PEG.buildParser('start = !"a" "b"', options); var parser = peg.buildParser('start = !"a" "b"', options);
expect(parser).toParse("b"); expect(parser).toParse("b");
}); });
it("discards any expectations recorded when matching the expression", function() { it("discards any expectations recorded when matching the expression", function() {
var parser = PEG.buildParser('start = "a" / !"b" / "c"', options); var parser = peg.buildParser('start = "a" / !"b" / "c"', options);
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
expected: [ expected: [
@ -984,7 +984,7 @@ describe("generated parser behavior", function() {
describe("label", function() { describe("label", function() {
describe("when the expression matches", function() { describe("when the expression matches", function() {
it("returns its match result", function() { it("returns its match result", function() {
var parser = PEG.buildParser('start = a:"a"', options); var parser = peg.buildParser('start = a:"a"', options);
expect(parser).toParse("a", "a"); expect(parser).toParse("a", "a");
}); });
@ -992,7 +992,7 @@ describe("generated parser behavior", function() {
describe("when the expression doesn't match", function() { describe("when the expression doesn't match", function() {
it("reports match failure", function() { it("reports match failure", function() {
var parser = PEG.buildParser('start = a:"a"', options); var parser = peg.buildParser('start = a:"a"', options);
expect(parser).toFailToParse("b"); expect(parser).toFailToParse("b");
}); });
@ -1002,7 +1002,7 @@ describe("generated parser behavior", function() {
describe("sequence", function() { describe("sequence", function() {
describe("when all expressions match", function() { describe("when all expressions match", function() {
it("returns an array of their match results", function() { it("returns an array of their match results", function() {
var parser = PEG.buildParser('start = "a" "b" "c"', options); var parser = peg.buildParser('start = "a" "b" "c"', options);
expect(parser).toParse("abc", ["a", "b", "c"]); expect(parser).toParse("abc", ["a", "b", "c"]);
}); });
@ -1010,7 +1010,7 @@ describe("generated parser behavior", function() {
describe("when any expression doesn't match", function() { describe("when any expression doesn't match", function() {
it("reports match failure", function() { it("reports match failure", function() {
var parser = PEG.buildParser('start = "a" "b" "c"', options); var parser = peg.buildParser('start = "a" "b" "c"', options);
expect(parser).toFailToParse("dbc"); expect(parser).toFailToParse("dbc");
expect(parser).toFailToParse("adc"); expect(parser).toFailToParse("adc");
@ -1018,7 +1018,7 @@ describe("generated parser behavior", function() {
}); });
it("resets parse position", function() { it("resets parse position", function() {
var parser = PEG.buildParser('start = "a" "b" / "a"', options); var parser = peg.buildParser('start = "a" "b" / "a"', options);
expect(parser).toParse("a", "a"); expect(parser).toParse("a", "a");
}); });
@ -1028,7 +1028,7 @@ describe("generated parser behavior", function() {
describe("action", function() { describe("action", function() {
describe("when the expression matches", function() { describe("when the expression matches", function() {
it("returns the value returned by the code", function() { it("returns the value returned by the code", function() {
var parser = PEG.buildParser('start = "a" { return 42; }', options); var parser = peg.buildParser('start = "a" { return 42; }', options);
expect(parser).toParse("a", 42); expect(parser).toParse("a", 42);
}); });
@ -1036,13 +1036,13 @@ describe("generated parser behavior", function() {
describe("label variables", function() { describe("label variables", function() {
describe("in the expression", function() { describe("in the expression", function() {
it("can access variable defined by labeled expression", function() { it("can access variable defined by labeled expression", function() {
var parser = PEG.buildParser('start = a:"a" { return a; }', options); var parser = peg.buildParser('start = a:"a" { return a; }', options);
expect(parser).toParse("a", "a"); expect(parser).toParse("a", "a");
}); });
it("can access variables defined by labeled sequence elements", function() { it("can access variables defined by labeled sequence elements", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = a:"a" b:"b" c:"c" { return [a, b, c]; }', 'start = a:"a" b:"b" c:"c" { return [a, b, c]; }',
options options
); );
@ -1100,7 +1100,7 @@ describe("generated parser behavior", function() {
parser, i; parser, i;
for (i = 0; i < testcases.length; i++) { for (i = 0; i < testcases.length; i++) {
parser = PEG.buildParser(testcases[i].grammar, options); parser = peg.buildParser(testcases[i].grammar, options);
expect(parser).toFailToParse(testcases[i].input); expect(parser).toFailToParse(testcases[i].input);
} }
}); });
@ -1108,7 +1108,7 @@ describe("generated parser behavior", function() {
describe("in outer sequence", function() { describe("in outer sequence", function() {
it("can access variables defined by preceding labeled elements", function() { it("can access variables defined by preceding labeled elements", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = a:"a" ("b" { return a; })', 'start = a:"a" ("b" { return a; })',
options options
); );
@ -1117,7 +1117,7 @@ describe("generated parser behavior", function() {
}); });
it("cannot access variable defined by labeled action element", function() { it("cannot access variable defined by labeled action element", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = "a" b:("b" { return b; }) c:"c"', 'start = "a" b:("b" { return b; }) c:"c"',
options options
); );
@ -1126,7 +1126,7 @@ describe("generated parser behavior", function() {
}); });
it("cannot access variables defined by following labeled elements", function() { it("cannot access variables defined by following labeled elements", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = ("a" { return b; }) b:"b"', 'start = ("a" { return b; }) b:"b"',
options options
); );
@ -1138,7 +1138,7 @@ describe("generated parser behavior", function() {
describe("initializer variables & functions", function() { describe("initializer variables & functions", function() {
it("can access variables defined in the initializer", function() { it("can access variables defined in the initializer", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var v = 42 }', '{ var v = 42 }',
'start = "a" { return v; }' 'start = "a" { return v; }'
].join("\n"), options); ].join("\n"), options);
@ -1147,7 +1147,7 @@ describe("generated parser behavior", function() {
}); });
it("can access functions defined in the initializer", function() { it("can access functions defined in the initializer", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ function f() { return 42; } }', '{ function f() { return 42; } }',
'start = "a" { return f(); }' 'start = "a" { return f(); }'
].join("\n"), options); ].join("\n"), options);
@ -1158,7 +1158,7 @@ describe("generated parser behavior", function() {
describe("available variables & functions", function() { describe("available variables & functions", function() {
it("|parser| contains the parser object", function() { it("|parser| contains the parser object", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = "a" { return parser; }', 'start = "a" { return parser; }',
options options
); );
@ -1167,7 +1167,7 @@ describe("generated parser behavior", function() {
}); });
it("|options| contains options", function() { it("|options| contains options", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = "a" { return options; }', 'start = "a" { return options; }',
options options
); );
@ -1176,7 +1176,7 @@ describe("generated parser behavior", function() {
}); });
it("|text| returns text matched by the expression", function() { it("|text| returns text matched by the expression", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = "a" { return text(); }', 'start = "a" { return text(); }',
options options
); );
@ -1185,7 +1185,7 @@ describe("generated parser behavior", function() {
}); });
it("|location| returns location info of the expression", function() { it("|location| returns location info of the expression", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'{ var result; }', '{ var result; }',
'start = line (nl+ line)* { return result; }', 'start = line (nl+ line)* { return result; }',
'line = thing (" "+ thing)*', 'line = thing (" "+ thing)*',
@ -1213,7 +1213,7 @@ describe("generated parser behavior", function() {
describe("|expected|", function() { describe("|expected|", function() {
it("terminates parsing and throws an exception", function() { it("terminates parsing and throws an exception", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = "a" { expected("a"); }', 'start = "a" { expected("a"); }',
options options
); );
@ -1229,7 +1229,7 @@ describe("generated parser behavior", function() {
}); });
it("allows to set custom location info", function() { it("allows to set custom location info", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'start = "a" {', 'start = "a" {',
' expected("a", {', ' expected("a", {',
' start: { offset: 1, line: 1, column: 2 },', ' start: { offset: 1, line: 1, column: 2 },',
@ -1251,7 +1251,7 @@ describe("generated parser behavior", function() {
describe("|error|", function() { describe("|error|", function() {
it("terminates parsing and throws an exception", function() { it("terminates parsing and throws an exception", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = "a" { error("a"); }', 'start = "a" { error("a"); }',
options options
); );
@ -1267,7 +1267,7 @@ describe("generated parser behavior", function() {
}); });
it("allows to set custom location info", function() { it("allows to set custom location info", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'start = "a" {', 'start = "a" {',
' error("a", {', ' error("a", {',
' start: { offset: 1, line: 1, column: 2 },', ' start: { offset: 1, line: 1, column: 2 },',
@ -1291,13 +1291,13 @@ describe("generated parser behavior", function() {
describe("when the expression doesn't match", function() { describe("when the expression doesn't match", function() {
it("reports match failure", function() { it("reports match failure", function() {
var parser = PEG.buildParser('start = "a" { return 42; }', options); var parser = peg.buildParser('start = "a" { return 42; }', options);
expect(parser).toFailToParse("b"); expect(parser).toFailToParse("b");
}); });
it("doesn't execute the code", function() { it("doesn't execute the code", function() {
var parser = PEG.buildParser( var parser = peg.buildParser(
'start = "a" { throw "Boom!"; } / "b"', 'start = "a" { throw "Boom!"; } / "b"',
options options
); );
@ -1310,7 +1310,7 @@ describe("generated parser behavior", function() {
describe("choice", function() { describe("choice", function() {
describe("when any expression matches", function() { describe("when any expression matches", function() {
it("returns its match result", function() { it("returns its match result", function() {
var parser = PEG.buildParser('start = "a" / "b" / "c"', options); var parser = peg.buildParser('start = "a" / "b" / "c"', options);
expect(parser).toParse("a", "a"); expect(parser).toParse("a", "a");
expect(parser).toParse("b", "b"); expect(parser).toParse("b", "b");
@ -1320,7 +1320,7 @@ describe("generated parser behavior", function() {
describe("when all expressions don't match", function() { describe("when all expressions don't match", function() {
it("reports match failure", function() { it("reports match failure", function() {
var parser = PEG.buildParser('start = "a" / "b" / "c"', options); var parser = peg.buildParser('start = "a" / "b" / "c"', options);
expect(parser).toFailToParse("d"); expect(parser).toFailToParse("d");
}); });
@ -1330,7 +1330,7 @@ describe("generated parser behavior", function() {
describe("error reporting", function() { describe("error reporting", function() {
describe("behavior", function() { describe("behavior", function() {
it("reports only the rightmost error", function() { it("reports only the rightmost error", function() {
var parser = PEG.buildParser('start = "a" "b" / "a" "c" "d"', options); var parser = peg.buildParser('start = "a" "b" / "a" "c" "d"', options);
expect(parser).toFailToParse("ace", { expect(parser).toFailToParse("ace", {
expected: [{ type: "literal", value: "d", description: '"d"' }] expected: [{ type: "literal", value: "d", description: '"d"' }]
@ -1340,7 +1340,7 @@ describe("generated parser behavior", function() {
describe("expectations reporting", function() { describe("expectations reporting", function() {
it("reports expectations correctly with no alternative", function() { it("reports expectations correctly with no alternative", function() {
var parser = PEG.buildParser('start = "a"', options); var parser = peg.buildParser('start = "a"', options);
expect(parser).toFailToParse("ab", { expect(parser).toFailToParse("ab", {
expected: [{ type: "end", description: "end of input" }] expected: [{ type: "end", description: "end of input" }]
@ -1348,7 +1348,7 @@ describe("generated parser behavior", function() {
}); });
it("reports expectations correctly with one alternative", function() { it("reports expectations correctly with one alternative", function() {
var parser = PEG.buildParser('start = "a"', options); var parser = peg.buildParser('start = "a"', options);
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
expected: [{ type: "literal", value: "a", description: '"a"' }] expected: [{ type: "literal", value: "a", description: '"a"' }]
@ -1356,7 +1356,7 @@ describe("generated parser behavior", function() {
}); });
it("reports expectations correctly with multiple alternatives", function() { it("reports expectations correctly with multiple alternatives", function() {
var parser = PEG.buildParser('start = "a" / "b" / "c"', options); var parser = peg.buildParser('start = "a" / "b" / "c"', options);
expect(parser).toFailToParse("d", { expect(parser).toFailToParse("d", {
expected: [ expected: [
@ -1375,7 +1375,7 @@ describe("generated parser behavior", function() {
* *
* See https://github.com/pegjs/pegjs/pull/146. * See https://github.com/pegjs/pegjs/pull/146.
*/ */
var parser = PEG.buildParser('start = "a" / "a" / "a"', options); var parser = peg.buildParser('start = "a" / "a" / "a"', options);
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
expected: [{ type: "literal", value: "a", description: '"a"' }] expected: [{ type: "literal", value: "a", description: '"a"' }]
@ -1383,7 +1383,7 @@ describe("generated parser behavior", function() {
}); });
it("sorts expectations", function() { it("sorts expectations", function() {
var parser = PEG.buildParser('start = "c" / "b" / "a"', options); var parser = peg.buildParser('start = "c" / "b" / "a"', options);
expect(parser).toFailToParse("d", { expect(parser).toFailToParse("d", {
expected: [ expected: [
@ -1397,7 +1397,7 @@ describe("generated parser behavior", function() {
describe("message building", function() { describe("message building", function() {
it("builds message correctly with no alternative", function() { it("builds message correctly with no alternative", function() {
var parser = PEG.buildParser('start = "a"', options); var parser = peg.buildParser('start = "a"', options);
expect(parser).toFailToParse("ab", { expect(parser).toFailToParse("ab", {
message: 'Expected end of input.' message: 'Expected end of input.'
@ -1405,7 +1405,7 @@ describe("generated parser behavior", function() {
}); });
it("builds message correctly with one alternative", function() { it("builds message correctly with one alternative", function() {
var parser = PEG.buildParser('start = "a"', options); var parser = peg.buildParser('start = "a"', options);
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
message: 'Expected "a".' message: 'Expected "a".'
@ -1413,7 +1413,7 @@ describe("generated parser behavior", function() {
}); });
it("builds message correctly with multiple alternatives", function() { it("builds message correctly with multiple alternatives", function() {
var parser = PEG.buildParser('start = "a" / "b" / "c"', options); var parser = peg.buildParser('start = "a" / "b" / "c"', options);
expect(parser).toFailToParse("d", { expect(parser).toFailToParse("d", {
message: 'Expected "a", "b" or "c".' message: 'Expected "a", "b" or "c".'
@ -1423,7 +1423,7 @@ describe("generated parser behavior", function() {
describe("position reporting", function() { describe("position reporting", function() {
it("reports position correctly with no trailing input", function() { it("reports position correctly with no trailing input", function() {
var parser = PEG.buildParser('start = "a"', options); var parser = peg.buildParser('start = "a"', options);
expect(parser).toFailToParse("b", { expect(parser).toFailToParse("b", {
location: { location: {
@ -1434,7 +1434,7 @@ describe("generated parser behavior", function() {
}); });
it("reports position correctly with trailing input", function() { it("reports position correctly with trailing input", function() {
var parser = PEG.buildParser('start = "a"', options); var parser = peg.buildParser('start = "a"', options);
expect(parser).toFailToParse("aa", { expect(parser).toFailToParse("aa", {
location: { location: {
@ -1445,7 +1445,7 @@ describe("generated parser behavior", function() {
}); });
it("reports position correctly in complex cases", function() { it("reports position correctly in complex cases", function() {
var parser = PEG.buildParser([ var parser = peg.buildParser([
'start = line (nl+ line)*', 'start = line (nl+ line)*',
'line = digit (" "+ digit)*', 'line = digit (" "+ digit)*',
'digit = [0-9]', 'digit = [0-9]',
@ -1488,7 +1488,7 @@ describe("generated parser behavior", function() {
* Sum Product (('+' / '-') Product)* * Sum Product (('+' / '-') Product)*
* Expr Sum * Expr Sum
*/ */
var parser = PEG.buildParser([ var parser = peg.buildParser([
'Expr = Sum', 'Expr = Sum',
'Sum = first:Product rest:(("+" / "-") Product)* {', 'Sum = first:Product rest:(("+" / "-") Product)* {',
' var result = first, i;', ' var result = first, i;',
@ -1544,7 +1544,7 @@ describe("generated parser behavior", function() {
* A a A? b * A a A? b
* B b B? c * B b B? c
*/ */
var parser = PEG.buildParser([ var parser = peg.buildParser([
'S = &(A "c") a:"a"+ B:B !("a" / "b" / "c") { return a.join("") + B; }', 'S = &(A "c") a:"a"+ B:B !("a" / "b" / "c") { return a.join("") + B; }',
'A = a:"a" A:A? b:"b" { return [a, A, b].join(""); }', 'A = a:"a" A:A? b:"b" { return [a, A, b].join(""); }',
'B = b:"b" B:B? c:"c" { return [b, B, c].join(""); }' 'B = b:"b" B:B? c:"c" { return [b, B, c].join(""); }'
@ -1568,7 +1568,7 @@ describe("generated parser behavior", function() {
* N C / (!Begin !End Z) * N C / (!Begin !End Z)
* Z any single character * Z any single character
*/ */
var parser = PEG.buildParser([ var parser = peg.buildParser([
'C = begin:Begin ns:N* end:End { return begin + ns.join("") + end; }', 'C = begin:Begin ns:N* end:End { return begin + ns.join("") + end; }',
'N = C', 'N = C',
' / !Begin !End z:Z { return z; }', ' / !Begin !End z:Z { return z; }',

@ -4,6 +4,6 @@
(function(root) { (function(root) {
if (typeof module !== 'undefined') { if (typeof module !== 'undefined') {
root.PEG = require("../lib/peg.js"); root.peg = require("../lib/peg.js");
} }
}(this)); }(this));

@ -1,9 +1,9 @@
/* global PEG */ /* global peg */
"use strict"; "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;
function bytecodeDetails(bytecode) { function bytecodeDetails(bytecode) {
return { return {

@ -1,4 +1,4 @@
/* global PEG */ /* global peg */
"use strict"; "use strict";
@ -44,7 +44,7 @@ beforeEach(function() {
} }
} }
var ast = PEG.parser.parse(grammar); var ast = peg.parser.parse(grammar);
this.actual(ast, options); this.actual(ast, options);
@ -61,7 +61,7 @@ beforeEach(function() {
}, },
toReportError: function(grammar, details) { toReportError: function(grammar, details) {
var ast = PEG.parser.parse(grammar); var ast = peg.parser.parse(grammar);
try { try {
this.actual(ast); this.actual(ast);

@ -1,9 +1,9 @@
/* global PEG */ /* global peg */
"use strict"; "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;
describe("when a proxy rule isn't listed in |allowedStartRules|", function() { describe("when a proxy rule isn't listed in |allowedStartRules|", function() {
it("updates references and removes it", function() { it("updates references and removes it", function() {

@ -1,9 +1,9 @@
/* global PEG */ /* global peg */
"use strict"; "use strict";
describe("compiler pass |reportInfiniteLoops|", function() { describe("compiler pass |reportInfiniteLoops|", function() {
var pass = PEG.compiler.passes.check.reportInfiniteLoops; var pass = peg.compiler.passes.check.reportInfiniteLoops;
it("reports infinite loops for zero_or_more", function() { it("reports infinite loops for zero_or_more", function() {
expect(pass).toReportError('start = ("")*', { expect(pass).toReportError('start = ("")*', {

@ -1,9 +1,9 @@
/* global PEG */ /* global peg */
"use strict"; "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;
it("reports direct left recursion", function() { it("reports direct left recursion", function() {
expect(pass).toReportError('start = start', { expect(pass).toReportError('start = start', {

@ -1,9 +1,9 @@
/* global PEG */ /* global peg */
"use strict"; "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;
it("reports missing rules", function() { it("reports missing rules", function() {
expect(pass).toReportError('start = missing', { expect(pass).toReportError('start = missing', {

@ -1,4 +1,4 @@
/* global PEG */ /* global peg */
"use strict"; "use strict";
@ -182,7 +182,7 @@ describe("PEG.js grammar parser", function() {
var result; var result;
try { try {
result = PEG.parser.parse(this.actual); result = peg.parser.parse(this.actual);
stripLocation(result); stripLocation(result);
@ -210,7 +210,7 @@ describe("PEG.js grammar parser", function() {
var result; var result;
try { try {
result = PEG.parser.parse(this.actual); result = peg.parser.parse(this.actual);
stripLocation(result); stripLocation(result);

Loading…
Cancel
Save