From ed406281f6de2c7a9f2b7af2d8c8eb4b7989e523 Mon Sep 17 00:00:00 2001 From: "Elf M. Sternberg" Date: Fri, 10 May 2013 21:25:33 -0700 Subject: [PATCH] Upped version number, made m() and match() aliases. Should be no noticeable changes to API. --- examples/email-address.coffee | 4 ++-- lib/reparse.js | 5 +++++ package.json | 2 +- src/reparse.coffee | 2 ++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/email-address.coffee b/examples/email-address.coffee index 359ef30..900f43e 100644 --- a/examples/email-address.coffee +++ b/examples/email-address.coffee @@ -9,8 +9,8 @@ class EmailAddress extends ReParse bareAddress: => @seq(@word, '@', @word).join "" phrase: => @many @word word: => @skip(/^\s+/).choice @quoted, @dottedAtom - quoted: => @m /^"(?:\\.|[^"\r\n])+"/m - dottedAtom: => @m /^[!#\$%&'\*\+\-\/\w=\?\^`\{\|\}~]+(?:\.[!#\$%&'\*\+\-\/\w=\?\^`\{\|\}~]+)*/m + quoted: => @match /^"(?:\\.|[^"\r\n])+"/m + dottedAtom: => @match /^[!#\$%&'\*\+\-\/\w=\?\^`\{\|\}~]+(?:\.[!#\$%&'\*\+\-\/\w=\?\^`\{\|\}~]+)*/m parse: => super diff --git a/lib/reparse.js b/lib/reparse.js index c786647..7587f86 100644 --- a/lib/reparse.js +++ b/lib/reparse.js @@ -24,6 +24,7 @@ this.between = __bind(this.between, this); this.option = __bind(this.option, this); this.maybe = __bind(this.maybe, this); + this.match = __bind(this.match, this); this.m = __bind(this.m, this); this.start = __bind(this.start, this); this.produce = __bind(this.produce, this); @@ -99,6 +100,10 @@ } }; + ReParse.prototype.match = function() { + return this.m.apply(this, arguments); + }; + ReParse.prototype.maybe = function(method) { var input; input = this.input; diff --git a/package.json b/package.json index 0483bd6..364ec8f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "author": { "name": "Elf M. Sternberg" }, - "version": "0.0.1", + "version": "0.0.2", "keywords": ["parser", "coffeescript"], "licenses": [{ "type": "MIT", diff --git a/src/reparse.coffee b/src/reparse.coffee index e81a02c..5fd9cd8 100644 --- a/src/reparse.coffee +++ b/src/reparse.coffee @@ -90,6 +90,8 @@ exports.ReParse = class ReParse @input = @input.substr (if probe[1]? and putback then probe[1].length else probe[0].length) if probe[1] is `undefined` then probe[0] else probe[1] + match: => @m.apply this, arguments + # Attempts to apply the method and produce a value. If it fails, # restores the input to the previous state.