Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "parsimmon", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "A monadic LL(infinity) parser combinator library", | ||
@@ -9,3 +9,3 @@ "keywords": ["parsing", "parse", "parser combinators"], | ||
"files": ["index.js", "src", "test", "Makefile", "package.json"], | ||
"files": ["index.js", "src", "test", "Makefile", "package.json", "build/parsimmon.commonjs.js"], | ||
"main": "index.js", | ||
@@ -18,8 +18,8 @@ "devDependencies": { | ||
"dependencies": { | ||
"pjs": "3.x" | ||
"pjs": "5.x" | ||
}, | ||
"scripts": { | ||
"install": "make commonjs", | ||
"prepublish": "make commonjs", | ||
"test": "make test" | ||
} | ||
} |
@@ -71,9 +71,3 @@ var Parsimmon = {}; | ||
_.or = function(alternative) { | ||
var self = this; | ||
return Parser(function(stream, i) { | ||
var result = self._(stream, i); | ||
return result.status ? result : furthestBacktrackFor(alternative._(stream, i), result); | ||
}); | ||
return alt([this, alternative]); | ||
}; | ||
@@ -172,3 +166,3 @@ | ||
for (; times < max && result; times += 1) { | ||
for (; times < max; times += 1) { | ||
result = self._(stream, i); | ||
@@ -308,4 +302,15 @@ prevResult = furthestBacktrackFor(result, prevResult); | ||
}); | ||
} | ||
}; | ||
var alt = Parsimmon.alt = function(parsers) { | ||
return Parser(function(stream, i) { | ||
var result; | ||
for (var j = 0; j < parsers.length; j += 1) { | ||
result = furthestBacktrackFor(parsers[j]._(stream, i), result); | ||
if (result.status) return result; | ||
} | ||
return result; | ||
}); | ||
}; | ||
var index = Parsimmon.index = Parser(function(stream, i) { | ||
@@ -317,4 +322,5 @@ return makeSuccess(i, i); | ||
//- Semigroup | ||
_.concat = _.then; | ||
//- Monoid (Alternative, really) | ||
_.concat = _.or; | ||
_.empty = fail('empty') | ||
@@ -321,0 +327,0 @@ //- Applicative |
@@ -185,2 +185,11 @@ suite('parser', function() { | ||
test('atMost', function() { | ||
var atMostTwo = letter.atMost(2); | ||
debugger | ||
assertEqualArray(atMostTwo.parse(''), []); | ||
assertEqualArray(atMostTwo.parse('a'), ['a']); | ||
assertEqualArray(atMostTwo.parse('ab'), ['a', 'b']); | ||
assert.throws(function() { atMostTwo.parse('abc'); }); | ||
}); | ||
test('atLeast', function() { | ||
@@ -187,0 +196,0 @@ var atLeastTwo = letter.atLeast(2); |
Sorry, the diff of this file is not supported yet
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
984220
14
835
0