|
|
|
@ -64,9 +64,9 @@ PEG.Grammar.GrammarError.prototype = Error.prototype;
|
|
|
|
|
|
|
|
|
|
/* ===== PEG.Grammar.* ===== */
|
|
|
|
|
|
|
|
|
|
PEG.Grammar.Rule = function(name, humanName, expression) {
|
|
|
|
|
PEG.Grammar.Rule = function(name, displayName, expression) {
|
|
|
|
|
this._name = name;
|
|
|
|
|
this._humanName = humanName;
|
|
|
|
|
this._displayName = displayName;
|
|
|
|
|
this._expression = expression;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -239,7 +239,7 @@ PEG.Compiler = {
|
|
|
|
|
PEG.Grammar.Rule.prototype.compile = function() {
|
|
|
|
|
var resultVar = PEG.Compiler.generateUniqueIdentifier("result");
|
|
|
|
|
|
|
|
|
|
if (this._humanName !== null) {
|
|
|
|
|
if (this._displayName !== null) {
|
|
|
|
|
var setReportMatchFailuresCode = PEG.Compiler.formatCode(
|
|
|
|
|
"var savedReportMatchFailures = context.reportMatchFailures;",
|
|
|
|
|
"context.reportMatchFailures = false;"
|
|
|
|
@ -249,10 +249,10 @@ PEG.Grammar.Rule.prototype.compile = function() {
|
|
|
|
|
);
|
|
|
|
|
var reportMatchFailureCode = PEG.Compiler.formatCode(
|
|
|
|
|
"if (context.reportMatchFailures && ${resultVar} === null) {",
|
|
|
|
|
" this._matchFailed(new PEG.Parser.NamedRuleMatchFailure(${humanName|string}));",
|
|
|
|
|
" this._matchFailed(new PEG.Parser.NamedRuleMatchFailure(${displayName|string}));",
|
|
|
|
|
"}",
|
|
|
|
|
{
|
|
|
|
|
humanName: this._humanName,
|
|
|
|
|
displayName: this._displayName,
|
|
|
|
|
resultVar: resultVar
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|