Do not modify |options| passed to |PEG.buildParser|

Modifying |options| can lead to subtle bugs.
redux
David Majda 12 years ago
parent 75a78c083c
commit 6a1ec7631f

@ -1,12 +1,10 @@
/* Generates the parser code. */
PEG.compiler.passes.generateCode = function(ast, options) {
options = options || {};
if (options.cache === undefined) {
options.cache = false;
}
if (options.trackLineAndColumn === undefined) {
options.trackLineAndColumn = false;
}
options = clone(options) || {};
defaults(options, {
cache: false,
trackLineAndColumn: false
});
/*
* Codie 1.1.0

@ -71,6 +71,22 @@ function values(object) {
return result;
}
function clone(object) {
var result = {};
for (var key in object) {
result[key] = object[key];
}
return result;
}
function defaults(object, defaults) {
for (var key in defaults) {
if (object[key] === undefined) {
object[key] = defaults[key];
}
}
}
/*
* Returns a string padded on the left to a desired length with a character.
*

Loading…
Cancel
Save