Upped version number, made m() and match() aliases. Should be no noticeable changes to API.

This commit is contained in:
Elf M. Sternberg 2013-05-10 21:25:33 -07:00
parent 2d4324d22b
commit ed406281f6
4 changed files with 10 additions and 3 deletions

View File

@ -9,8 +9,8 @@ class EmailAddress extends ReParse
bareAddress: => @seq(@word, '@', @word).join "" bareAddress: => @seq(@word, '@', @word).join ""
phrase: => @many @word phrase: => @many @word
word: => @skip(/^\s+/).choice @quoted, @dottedAtom word: => @skip(/^\s+/).choice @quoted, @dottedAtom
quoted: => @m /^"(?:\\.|[^"\r\n])+"/m quoted: => @match /^"(?:\\.|[^"\r\n])+"/m
dottedAtom: => @m /^[!#\$%&'\*\+\-\/\w=\?\^`\{\|\}~]+(?:\.[!#\$%&'\*\+\-\/\w=\?\^`\{\|\}~]+)*/m dottedAtom: => @match /^[!#\$%&'\*\+\-\/\w=\?\^`\{\|\}~]+(?:\.[!#\$%&'\*\+\-\/\w=\?\^`\{\|\}~]+)*/m
parse: => parse: =>
super super

View File

@ -24,6 +24,7 @@
this.between = __bind(this.between, this); this.between = __bind(this.between, this);
this.option = __bind(this.option, this); this.option = __bind(this.option, this);
this.maybe = __bind(this.maybe, this); this.maybe = __bind(this.maybe, this);
this.match = __bind(this.match, this);
this.m = __bind(this.m, this); this.m = __bind(this.m, this);
this.start = __bind(this.start, this); this.start = __bind(this.start, this);
this.produce = __bind(this.produce, 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) { ReParse.prototype.maybe = function(method) {
var input; var input;
input = this.input; input = this.input;

View File

@ -4,7 +4,7 @@
"author": { "author": {
"name": "Elf M. Sternberg" "name": "Elf M. Sternberg"
}, },
"version": "0.0.1", "version": "0.0.2",
"keywords": ["parser", "coffeescript"], "keywords": ["parser", "coffeescript"],
"licenses": [{ "licenses": [{
"type": "MIT", "type": "MIT",

View File

@ -90,6 +90,8 @@ exports.ReParse = class ReParse
@input = @input.substr (if probe[1]? and putback then probe[1].length else probe[0].length) @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] 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, # Attempts to apply the method and produce a value. If it fails,
# restores the input to the previous state. # restores the input to the previous state.