|
|
|
@ -200,6 +200,8 @@ PEG.Grammar.Choice = function(alternatives) {
|
|
|
|
|
|
|
|
|
|
PEG.Grammar.ZeroOrMore = function(element) { this._element = element; };
|
|
|
|
|
|
|
|
|
|
PEG.Grammar.OneOrMore = function(element) { this._element = element; };
|
|
|
|
|
|
|
|
|
|
PEG.Grammar.NotPredicate = function(expression) {
|
|
|
|
|
this._expression = expression;
|
|
|
|
|
};
|
|
|
|
@ -240,6 +242,9 @@ PEG.Grammar.extendNodes("checkReferencedRulesExist", {
|
|
|
|
|
ZeroOrMore:
|
|
|
|
|
function(grammar) { this._element.checkReferencedRulesExist(grammar); },
|
|
|
|
|
|
|
|
|
|
OneOrMore:
|
|
|
|
|
function(grammar) { this._element.checkReferencedRulesExist(grammar); },
|
|
|
|
|
|
|
|
|
|
NotPredicate:
|
|
|
|
|
function(grammar) { this._expression.checkReferencedRulesExist(grammar); },
|
|
|
|
|
|
|
|
|
@ -288,6 +293,11 @@ PEG.Grammar.extendNodes("checkNoLeftRecursion", {
|
|
|
|
|
this._element.checkNoLeftRecursion(grammar, appliedRules);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
OneOrMore:
|
|
|
|
|
function(grammar, appliedRules) {
|
|
|
|
|
this._element.checkNoLeftRecursion(grammar, appliedRules);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
NotPredicate:
|
|
|
|
|
function(grammar, appliedRules) {
|
|
|
|
|
this._expression.checkNoLeftRecursion(grammar, appliedRules);
|
|
|
|
@ -858,6 +868,28 @@ PEG.Grammar.ZeroOrMore.prototype.compile = function(resultVar) {
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PEG.Grammar.OneOrMore.prototype.compile = function(resultVar) {
|
|
|
|
|
var elementResultVar = PEG.Compiler.generateUniqueIdentifier("result");
|
|
|
|
|
|
|
|
|
|
return PEG.Compiler.formatCode(
|
|
|
|
|
"${elementCode}",
|
|
|
|
|
"if (${elementResultVar} !== null) {",
|
|
|
|
|
" var ${resultVar} = [];",
|
|
|
|
|
" while (${elementResultVar} !== null) {",
|
|
|
|
|
" ${resultVar}.push(${elementResultVar});",
|
|
|
|
|
" ${elementCode}",
|
|
|
|
|
" }",
|
|
|
|
|
"} else {",
|
|
|
|
|
" var ${resultVar} = null;",
|
|
|
|
|
"}",
|
|
|
|
|
{
|
|
|
|
|
elementCode: this._element.compile(elementResultVar),
|
|
|
|
|
elementResultVar: elementResultVar,
|
|
|
|
|
resultVar: resultVar
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PEG.Grammar.NotPredicate.prototype.compile = function(resultVar) {
|
|
|
|
|
var savedPosVar = PEG.Compiler.generateUniqueIdentifier("savedPos");
|
|
|
|
|
var savedReportMatchFailuresVar = PEG.Compiler.generateUniqueIdentifier("savedReportMatchFailuresVar");
|
|
|
|
|