|
|
|
@ -190,6 +190,10 @@ PEG.Compiler = {
|
|
|
|
|
|
|
|
|
|
_uniqueIdentifierCounters: {},
|
|
|
|
|
|
|
|
|
|
_resetUniqueIdentifierCounters: function() {
|
|
|
|
|
this._uniqueIdentifierCounters = {};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/* Generates a unique identifier with specified prefix. */
|
|
|
|
|
generateUniqueIdentifier: function(prefix) {
|
|
|
|
|
this._uniqueIdentifierCounters[prefix]
|
|
|
|
@ -201,6 +205,12 @@ PEG.Compiler = {
|
|
|
|
|
* Generates a parser from a specified grammar and start rule.
|
|
|
|
|
*/
|
|
|
|
|
compileParser: function(grammar, startRule) {
|
|
|
|
|
/*
|
|
|
|
|
* This ensures that the same grammar and start rule always generate exactly
|
|
|
|
|
* the same parser.
|
|
|
|
|
*/
|
|
|
|
|
this._resetUniqueIdentifierCounters();
|
|
|
|
|
|
|
|
|
|
var parseFunctionDefinitions = [];
|
|
|
|
|
for (var key in grammar) {
|
|
|
|
|
parseFunctionDefinitions.push(grammar[key].compile());
|
|
|
|
|