diff --git a/peg.js b/peg.js index 89e5341..44226a9 100644 --- a/peg.js +++ b/peg.js @@ -69,13 +69,15 @@ Peg.Use = function (getPattern) { * @return {Peg.Pattern} */ Peg.Regex = function (regex) { - return Peg.WrapPattern(function (source, index) { + /** @type {Peg.Pattern} */ + const pattern = Peg.WrapPattern(function (source, index) { regex.lastIndex = index; const matches = regex.exec(source); return matches ? [true, matches, regex.lastIndex] - : [false, index, regex.source]; + : [false, index, pattern.expectLabel]; }).expects(regex.source); + return pattern; }; /**