Socket
Socket
Sign inDemoInstall

parsimmon

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parsimmon - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

146

build/parsimmon.browser.js

@@ -1,78 +0,7 @@

var Parsimmon = (function(undefined) {
var P = (function(prototype, ownProperty, undefined) {
return function P(_superclass /* = Object */, definition) {
// handle the case where no superclass is given
if (definition === undefined) {
definition = _superclass;
_superclass = Object;
}
// C is the class to be returned.
//
// When called, creates and initializes an instance of C, unless
// `this` is already an instance of C, then just initializes `this`;
// either way, returns the instance of C that was initialized.
//
// TODO: the Chrome inspector shows all created objects as `C`
// rather than `Object`. Setting the .name property seems to
// have no effect. Is there a way to override this behavior?
function C() {
var self = this instanceof C ? this : new Bare;
self.init.apply(self, arguments);
return self;
}
// C.Bare is a class with a noop constructor. Its prototype will be
// the same as C, so that instances of C.Bare are instances of C.
// `new MyClass.Bare` then creates new instances of C without
// calling .init().
function Bare() {}
C.Bare = Bare;
// Extend the prototype chain: first use Bare to create an
// uninitialized instance of the superclass, then set up Bare
// to create instances of this class.
var _super = Bare[prototype] = _superclass[prototype];
var proto = Bare[prototype] = C[prototype] = C.p = new Bare;
// pre-declaring the iteration variable for the loop below to save
// a `var` keyword after minification
var key;
// set the constructor property on the prototype, for convenience
proto.constructor = C;
C.extend = function(def) { return P(C, def); }
return (C.open = function(def) {
if (typeof def === 'function') {
// call the defining function with all the arguments you need
// extensions captures the return value.
def = def.call(C, proto, _super, C, _superclass);
}
// ...and extend it
if (typeof def === 'object') {
for (key in def) {
if (ownProperty.call(def, key)) {
proto[key] = def[key];
}
}
}
// if no init, assume we're inheriting from a non-Pjs class, so
// default to using the superclass constructor.
if (!('init' in proto)) proto.init = _superclass;
return C;
})(definition);
}
// as a minifier optimization, we've closured in a few helper functions
// and the string 'prototype' (C[p] is much shorter than C.prototype)
})('prototype', ({}).hasOwnProperty);
// pass
var Parsimmon = {};
Parsimmon.Parser = P(function(_, _super, Parser) {
Parsimmon.Parser = (function() {
"use strict";
// The Parser object is a wrapper for a parser function.

@@ -84,3 +13,9 @@ // Externally, you use one to parse a string by calling

// parser combinator methods.
function Parser(action) {
if (!(this instanceof Parser)) return new Parser(action);
this._ = action;
};
var _ = Parser.prototype;
function makeSuccess(index, value) {

@@ -139,4 +74,2 @@ return {

_.init = function(body) { this._ = body; };
_.parse = function(stream) {

@@ -175,2 +108,11 @@ var result = this.skip(eof)._(stream, 0);

var seqMap = Parsimmon.seqMap = function() {
var args = [].slice.call(arguments);
var mapper = args.pop();
return seq.apply(null, args).map(function(results) {
return mapper.apply(null, results);
});
};
/**

@@ -205,3 +147,3 @@ * Allows to add custom primitive parsers

if (typeof next === 'function') {
throw new Error('chaining features of .then are no longer supported');
throw new Error('chaining features of .then are no longer supported, use .chain instead');
}

@@ -286,5 +228,3 @@

}
else {
return prevResult;
}
else return prevResult;
}

@@ -299,5 +239,3 @@

}
else {
break;
}
else break;
}

@@ -310,8 +248,8 @@

// -*- higher-level combinators -*- //
_.result = function(res) { return this.then(succeed(res)); };
_.result = function(res) { return this.map(function(_) { return res; }); };
_.atMost = function(n) { return this.times(0, n); };
_.atLeast = function(n) {
var self = this;
return seq(this.times(n), this.many()).map(function(results) {
return results[0].concat(results[1]);
return seqMap(this.times(n), this.many(), function(init, rest) {
return init.concat(rest);
});

@@ -334,4 +272,4 @@ };

_.mark = function() {
return seq(index, this, index).map(function(results) {
return { start: results[0], value: results[1], end: results[2] };
return seqMap(index, this, index, function(start, value, end) {
return { start: start, value: value, end: end };
});

@@ -361,4 +299,5 @@ };

var regex = Parsimmon.regex = function(re) {
var regex = Parsimmon.regex = function(re, group) {
var anchored = RegExp('^(?:'+re.source+')', (''+re).slice((''+re).lastIndexOf('/')+1));
if (group == null) group = 0;

@@ -369,8 +308,8 @@ return Parser(function(stream, i) {

if (match) {
var result = match[0];
return makeSuccess(i+result.length, result);
var fullMatch = match[0];
var groupMatch = match[group];
if (groupMatch != null) return makeSuccess(i+fullMatch.length, groupMatch);
}
else {
return makeFailure(i, re);
}
return makeFailure(i, re);
});

@@ -424,2 +363,10 @@ };

var oneOf = Parsimmon.oneOf = function(str) {
return test(function(ch) { return str.indexOf(ch) >= 0; });
};
var noneOf = Parsimmon.noneOf = function(str) {
return test(function(ch) { return str.indexOf(ch) < 0; });
};
var takeWhile = Parsimmon.takeWhile = function(predicate) {

@@ -463,5 +410,3 @@ return Parser(function(stream, i) {

_.ap = function(other) {
return seq(this, other).map(function(results) {
return results[0](results[1]);
});
return seqMap(this, other, function(f, x) { return f(x); })
};

@@ -479,4 +424,5 @@

};
});
return Parsimmon;
})()
return Parser;
})();
// pass

@@ -1,1 +0,1 @@

var Parsimmon=function(t){var r=function(t,r,n){return function e(u,a){if(a===n){a=u;u=Object}function i(){var t=this instanceof i?this:new s;t.init.apply(t,arguments);return t}function s(){}i.Bare=s;var c=s[t]=u[t];var f=s[t]=i[t]=i.p=new s;var o;f.constructor=i;i.extend=function(t){return e(i,t)};return(i.open=function(t){if(typeof t==="function"){t=t.call(i,f,c,i,u)}if(typeof t==="object"){for(o in t){if(r.call(t,o)){f[o]=t[o]}}}if(!("init"in f))f.init=u;return i})(a)}}("prototype",{}.hasOwnProperty);var n={};n.Parser=r(function(r,e,u){"use strict";function a(t,r){return{status:true,index:t,value:r,furthest:-1,expected:""}}function i(t,r){return{status:false,index:-1,value:null,furthest:t,expected:r}}function s(t,r){if(!r)return t;if(t.furthest>=r.furthest)return t;return{status:t.status,index:t.index,value:t.value,furthest:r.furthest,expected:r.expected}}function c(t){if(!(t instanceof u))throw new Error("not a parser: "+t)}var f=n.formatError=function(t,r){var n=r.expected;var e=r.index;if(e===t.length){return"expected "+n+", got the end of the string"}var u=e>0?"'...":"'";var a=t.length-e>12?"...'":"'";return"expected "+n+" at character "+e+", got "+u+t.slice(e,e+12)+a};r.init=function(t){this._=t};r.parse=function(t){var r=this.skip(A)._(t,0);return r.status?{status:true,value:r.value}:{status:false,index:r.furthest,expected:r.expected}};var o=n.seq=function(){var t=[].slice.call(arguments);var r=t.length;return u(function(n,e){var u;var i=new Array(r);for(var c=0;c<r;c+=1){u=s(t[c]._(n,e),u);if(!u.status)return u;i[c]=u.value;e=u.index}return s(a(e,i),u)})};var v=n.custom=function(t){return u(t(a,i))};var l=n.alt=function(){var t=[].slice.call(arguments);var r=t.length;if(r===0)return g("zero alternates");return u(function(r,n){var e;for(var u=0;u<t.length;u+=1){e=s(t[u]._(r,n),e);if(e.status)return e}return e})};r.or=function(t){return l(this,t)};r.then=function(t){if(typeof t==="function"){throw new Error("chaining features of .then are no longer supported")}c(t);return o(this,t).map(function(t){return t[1]})};r.many=function(){var t=this;return u(function(r,n){var e=[];var u;var i;for(;;){u=s(t._(r,n),u);if(u.status){n=u.index;e.push(u.value)}else{return s(a(n,e),u)}}})};r.times=function(t,r){if(arguments.length<2)r=t;var n=this;return u(function(e,u){var i=[];var c=u;var f;var o;for(var v=0;v<t;v+=1){f=n._(e,u);o=s(f,o);if(f.status){u=f.index;i.push(f.value)}else{return o}}for(;v<r;v+=1){f=n._(e,u);o=s(f,o);if(f.status){u=f.index;i.push(f.value)}else{break}}return s(a(u,i),o)})};r.result=function(t){return this.then(d(t))};r.atMost=function(t){return this.times(0,t)};r.atLeast=function(t){var r=this;return o(this.times(t),this.many()).map(function(t){return t[0].concat(t[1])})};r.map=function(t){var r=this;return u(function(n,e){var u=r._(n,e);if(!u.status)return u;return s(a(u.index,t(u.value)),u)})};r.skip=function(t){return o(this,t).map(function(t){return t[0]})};r.mark=function(){return o(j,this,j).map(function(t){return{start:t[0],value:t[1],end:t[2]}})};r.desc=function(t){return this.or(g(t))};var h=n.string=function(t){var r=t.length;var n="'"+t+"'";return u(function(e,u){var s=e.slice(u,u+r);if(s===t){return a(u+r,s)}else{return i(u,n)}})};var p=n.regex=function(t){var r=RegExp("^(?:"+t.source+")",(""+t).slice((""+t).lastIndexOf("/")+1));return u(function(n,e){var u=r.exec(n.slice(e));if(u){var s=u[0];return a(e+s.length,s)}else{return i(e,t)}})};var d=n.succeed=function(t){return u(function(r,n){return a(n,t)})};var g=n.fail=function(t){return u(function(r,n){return i(n,t)})};var x=n.letter=p(/[a-z]/i).desc("a letter");var m=n.letters=p(/[a-z]*/i);var y=n.digit=p(/[0-9]/).desc("a digit");var _=n.digits=p(/[0-9]*/);var w=n.whitespace=p(/\s+/).desc("whitespace");var k=n.optWhitespace=p(/\s*/);var E=n.any=u(function(t,r){if(r>=t.length)return i(r,"any character");return a(r+1,t.charAt(r))});var z=n.all=u(function(t,r){return a(t.length,t.slice(r))});var A=n.eof=u(function(t,r){if(r<t.length)return i(r,"EOF");return a(r,null)});var O=n.test=function(t){return u(function(r,n){var e=r.charAt(n);if(n<r.length&&t(e)){return a(n+1,e)}else{return i(n,"a character matching "+t)}})};var b=n.takeWhile=function(t){return u(function(r,n){var e=n;while(e<r.length&&t(r.charAt(e)))e+=1;return a(e,r.slice(n,e))})};var P=n.lazy=function(r,n){if(arguments.length<2){n=r;r=t}var e=u(function(t,r){e._=n()._;return e._(t,r)});if(r)e=e.desc(r);return e};var j=n.index=u(function(t,r){return a(r,r)});r.concat=r.or;r.empty=g("empty");r.of=u.of=n.of=d;r.ap=function(t){return o(this,t).map(function(t){return t[0](t[1])})};r.chain=function(t){var r=this;return u(function(n,e){var u=r._(n,e);if(!u.status)return u;var a=t(u.value);return s(a._(n,u.index),u)})}});return n}();
var Parsimmon={};Parsimmon.Parser=function(){"use strict";function r(n){if(!(this instanceof r))return new r(n);this._=n}var n=r.prototype;function t(r,n){return{status:true,index:r,value:n,furthest:-1,expected:""}}function e(r,n){return{status:false,index:-1,value:null,furthest:r,expected:n}}function a(r,n){if(!n)return r;if(r.furthest>=n.furthest)return r;return{status:r.status,index:r.index,value:r.value,furthest:n.furthest,expected:n.expected}}function u(n){if(!(n instanceof r))throw new Error("not a parser: "+n)}var i=Parsimmon.formatError=function(r,n){var t=n.expected;var e=n.index;if(e===r.length){return"expected "+t+", got the end of the string"}var a=e>0?"'...":"'";var u=r.length-e>12?"...'":"'";return"expected "+t+" at character "+e+", got "+a+r.slice(e,e+12)+u};n.parse=function(r){var n=this.skip(O)._(r,0);return n.status?{status:true,value:n.value}:{status:false,index:n.furthest,expected:n.expected}};var s=Parsimmon.seq=function(){var n=[].slice.call(arguments);var e=n.length;return r(function(r,u){var i;var s=new Array(e);for(var o=0;o<e;o+=1){i=a(n[o]._(r,u),i);if(!i.status)return i;s[o]=i.value;u=i.index}return a(t(u,s),i)})};var o=Parsimmon.seqMap=function(){var r=[].slice.call(arguments);var n=r.pop();return s.apply(null,r).map(function(r){return n.apply(null,r)})};var f=Parsimmon.custom=function(n){return r(n(t,e))};var c=Parsimmon.alt=function(){var n=[].slice.call(arguments);var t=n.length;if(t===0)return h("zero alternates");return r(function(r,t){var e;for(var u=0;u<n.length;u+=1){e=a(n[u]._(r,t),e);if(e.status)return e}return e})};n.or=function(r){return c(this,r)};n.then=function(r){if(typeof r==="function"){throw new Error("chaining features of .then are no longer supported, use .chain instead")}u(r);return s(this,r).map(function(r){return r[1]})};n.many=function(){var n=this;return r(function(r,e){var u=[];var i;var s;for(;;){i=a(n._(r,e),i);if(i.status){e=i.index;u.push(i.value)}else{return a(t(e,u),i)}}})};n.times=function(n,e){if(arguments.length<2)e=n;var u=this;return r(function(r,i){var s=[];var o=i;var f;var c;for(var v=0;v<n;v+=1){f=u._(r,i);c=a(f,c);if(f.status){i=f.index;s.push(f.value)}else return c}for(;v<e;v+=1){f=u._(r,i);c=a(f,c);if(f.status){i=f.index;s.push(f.value)}else break}return a(t(i,s),c)})};n.result=function(r){return this.map(function(n){return r})};n.atMost=function(r){return this.times(0,r)};n.atLeast=function(r){var n=this;return o(this.times(r),this.many(),function(r,n){return r.concat(n)})};n.map=function(n){var e=this;return r(function(r,u){var i=e._(r,u);if(!i.status)return i;return a(t(i.index,n(i.value)),i)})};n.skip=function(r){return s(this,r).map(function(r){return r[0]})};n.mark=function(){return o(M,this,M,function(r,n,t){return{start:r,value:n,end:t}})};n.desc=function(r){return this.or(h(r))};var v=Parsimmon.string=function(n){var a=n.length;var u="'"+n+"'";return r(function(r,i){var s=r.slice(i,i+a);if(s===n){return t(i+a,s)}else{return e(i,u)}})};var l=Parsimmon.regex=function(n,a){var u=RegExp("^(?:"+n.source+")",(""+n).slice((""+n).lastIndexOf("/")+1));if(a==null)a=0;return r(function(r,i){var s=u.exec(r.slice(i));if(s){var o=s[0];var f=s[a];if(f!=null)return t(i+o.length,f)}return e(i,n)})};var m=Parsimmon.succeed=function(n){return r(function(r,e){return t(e,n)})};var h=Parsimmon.fail=function(n){return r(function(r,t){return e(t,n)})};var p=Parsimmon.letter=l(/[a-z]/i).desc("a letter");var d=Parsimmon.letters=l(/[a-z]*/i);var g=Parsimmon.digit=l(/[0-9]/).desc("a digit");var x=Parsimmon.digits=l(/[0-9]*/);var P=Parsimmon.whitespace=l(/\s+/).desc("whitespace");var _=Parsimmon.optWhitespace=l(/\s*/);var y=Parsimmon.any=r(function(r,n){if(n>=r.length)return e(n,"any character");return t(n+1,r.charAt(n))});var w=Parsimmon.all=r(function(r,n){return t(r.length,r.slice(n))});var O=Parsimmon.eof=r(function(r,n){if(n<r.length)return e(n,"EOF");return t(n,null)});var k=Parsimmon.test=function(n){return r(function(r,a){var u=r.charAt(a);if(a<r.length&&n(u)){return t(a+1,u)}else{return e(a,"a character matching "+n)}})};var E=Parsimmon.oneOf=function(r){return k(function(n){return r.indexOf(n)>=0})};var z=Parsimmon.noneOf=function(r){return k(function(n){return r.indexOf(n)<0})};var A=Parsimmon.takeWhile=function(n){return r(function(r,e){var a=e;while(a<r.length&&n(r.charAt(a)))a+=1;return t(a,r.slice(e,a))})};var q=Parsimmon.lazy=function(n,t){if(arguments.length<2){t=n;n=undefined}var e=r(function(r,n){e._=t()._;return e._(r,n)});if(n)e=e.desc(n);return e};var M=Parsimmon.index=r(function(r,n){return t(n,n)});n.concat=n.or;n.empty=h("empty");n.of=r.of=Parsimmon.of=m;n.ap=function(r){return o(this,r,function(r,n){return r(n)})};n.chain=function(n){var t=this;return r(function(r,e){var u=t._(r,e);if(!u.status)return u;var i=n(u.value);return a(i._(r,u.index),u)})};return r}();

@@ -1,6 +0,7 @@

var P = require('pjs').P;
// pass
var Parsimmon = {};
Parsimmon.Parser = P(function(_, _super, Parser) {
Parsimmon.Parser = (function() {
"use strict";
// The Parser object is a wrapper for a parser function.

@@ -12,3 +13,9 @@ // Externally, you use one to parse a string by calling

// parser combinator methods.
function Parser(action) {
if (!(this instanceof Parser)) return new Parser(action);
this._ = action;
};
var _ = Parser.prototype;
function makeSuccess(index, value) {

@@ -67,4 +74,2 @@ return {

_.init = function(body) { this._ = body; };
_.parse = function(stream) {

@@ -103,2 +108,11 @@ var result = this.skip(eof)._(stream, 0);

var seqMap = Parsimmon.seqMap = function() {
var args = [].slice.call(arguments);
var mapper = args.pop();
return seq.apply(null, args).map(function(results) {
return mapper.apply(null, results);
});
};
/**

@@ -133,3 +147,3 @@ * Allows to add custom primitive parsers

if (typeof next === 'function') {
throw new Error('chaining features of .then are no longer supported');
throw new Error('chaining features of .then are no longer supported, use .chain instead');
}

@@ -214,5 +228,3 @@

}
else {
return prevResult;
}
else return prevResult;
}

@@ -227,5 +239,3 @@

}
else {
break;
}
else break;
}

@@ -238,8 +248,8 @@

// -*- higher-level combinators -*- //
_.result = function(res) { return this.then(succeed(res)); };
_.result = function(res) { return this.map(function(_) { return res; }); };
_.atMost = function(n) { return this.times(0, n); };
_.atLeast = function(n) {
var self = this;
return seq(this.times(n), this.many()).map(function(results) {
return results[0].concat(results[1]);
return seqMap(this.times(n), this.many(), function(init, rest) {
return init.concat(rest);
});

@@ -262,4 +272,4 @@ };

_.mark = function() {
return seq(index, this, index).map(function(results) {
return { start: results[0], value: results[1], end: results[2] };
return seqMap(index, this, index, function(start, value, end) {
return { start: start, value: value, end: end };
});

@@ -289,4 +299,5 @@ };

var regex = Parsimmon.regex = function(re) {
var regex = Parsimmon.regex = function(re, group) {
var anchored = RegExp('^(?:'+re.source+')', (''+re).slice((''+re).lastIndexOf('/')+1));
if (group == null) group = 0;

@@ -297,8 +308,8 @@ return Parser(function(stream, i) {

if (match) {
var result = match[0];
return makeSuccess(i+result.length, result);
var fullMatch = match[0];
var groupMatch = match[group];
if (groupMatch != null) return makeSuccess(i+fullMatch.length, groupMatch);
}
else {
return makeFailure(i, re);
}
return makeFailure(i, re);
});

@@ -352,2 +363,10 @@ };

var oneOf = Parsimmon.oneOf = function(str) {
return test(function(ch) { return str.indexOf(ch) >= 0; });
};
var noneOf = Parsimmon.noneOf = function(str) {
return test(function(ch) { return str.indexOf(ch) < 0; });
};
var takeWhile = Parsimmon.takeWhile = function(predicate) {

@@ -391,5 +410,3 @@ return Parser(function(stream, i) {

_.ap = function(other) {
return seq(this, other).map(function(results) {
return results[0](results[1]);
});
return seqMap(this, other, function(f, x) { return f(x); })
};

@@ -407,3 +424,5 @@

};
});
return Parser;
})();
module.exports = Parsimmon;
{
"name": "parsimmon",
"version": "0.5.1",
"version": "0.6.0",
"description": "A monadic LL(infinity) parser combinator library",

@@ -5,0 +5,0 @@ "keywords": ["parsing", "parse", "parser combinators"],

@@ -75,4 +75,5 @@ [![Build Status](https://secure.travis-ci.org/jneen/parsimmon.png)](http://travis-ci.org/jneen/parsimmon)

`"my-string"`, and will yield the same.
- `Parsimmon.regex(/myregex/)` is a parser that expects the stream
to match the given regex.
- `Parsimmon.regex(/myregex/, group=0)` is a parser that expects the stream
to match the given regex, and yields the given match group, or the
entire match.
- `Parsimmon.succeed(result)` is a parser that doesn't consume any of

@@ -79,0 +80,0 @@ the string, and yields `result`.

@@ -1,2 +0,1 @@

return Parsimmon;
})()
// pass

@@ -1,1 +0,1 @@

var Parsimmon = (function(undefined) {
// pass

@@ -1,1 +0,1 @@

var P = require('pjs').P;
// pass
var Parsimmon = {};
Parsimmon.Parser = P(function(_, _super, Parser) {
Parsimmon.Parser = (function() {
"use strict";
// The Parser object is a wrapper for a parser function.

@@ -11,3 +12,9 @@ // Externally, you use one to parse a string by calling

// parser combinator methods.
function Parser(action) {
if (!(this instanceof Parser)) return new Parser(action);
this._ = action;
};
var _ = Parser.prototype;
function makeSuccess(index, value) {

@@ -66,4 +73,2 @@ return {

_.init = function(body) { this._ = body; };
_.parse = function(stream) {

@@ -102,2 +107,11 @@ var result = this.skip(eof)._(stream, 0);

var seqMap = Parsimmon.seqMap = function() {
var args = [].slice.call(arguments);
var mapper = args.pop();
return seq.apply(null, args).map(function(results) {
return mapper.apply(null, results);
});
};
/**

@@ -132,3 +146,3 @@ * Allows to add custom primitive parsers

if (typeof next === 'function') {
throw new Error('chaining features of .then are no longer supported');
throw new Error('chaining features of .then are no longer supported, use .chain instead');
}

@@ -213,5 +227,3 @@

}
else {
return prevResult;
}
else return prevResult;
}

@@ -226,5 +238,3 @@

}
else {
break;
}
else break;
}

@@ -237,8 +247,8 @@

// -*- higher-level combinators -*- //
_.result = function(res) { return this.then(succeed(res)); };
_.result = function(res) { return this.map(function(_) { return res; }); };
_.atMost = function(n) { return this.times(0, n); };
_.atLeast = function(n) {
var self = this;
return seq(this.times(n), this.many()).map(function(results) {
return results[0].concat(results[1]);
return seqMap(this.times(n), this.many(), function(init, rest) {
return init.concat(rest);
});

@@ -261,4 +271,4 @@ };

_.mark = function() {
return seq(index, this, index).map(function(results) {
return { start: results[0], value: results[1], end: results[2] };
return seqMap(index, this, index, function(start, value, end) {
return { start: start, value: value, end: end };
});

@@ -288,4 +298,5 @@ };

var regex = Parsimmon.regex = function(re) {
var regex = Parsimmon.regex = function(re, group) {
var anchored = RegExp('^(?:'+re.source+')', (''+re).slice((''+re).lastIndexOf('/')+1));
if (group == null) group = 0;

@@ -296,8 +307,8 @@ return Parser(function(stream, i) {

if (match) {
var result = match[0];
return makeSuccess(i+result.length, result);
var fullMatch = match[0];
var groupMatch = match[group];
if (groupMatch != null) return makeSuccess(i+fullMatch.length, groupMatch);
}
else {
return makeFailure(i, re);
}
return makeFailure(i, re);
});

@@ -351,2 +362,10 @@ };

var oneOf = Parsimmon.oneOf = function(str) {
return test(function(ch) { return str.indexOf(ch) >= 0; });
};
var noneOf = Parsimmon.noneOf = function(str) {
return test(function(ch) { return str.indexOf(ch) < 0; });
};
var takeWhile = Parsimmon.takeWhile = function(predicate) {

@@ -390,5 +409,3 @@ return Parser(function(stream, i) {

_.ap = function(other) {
return seq(this, other).map(function(results) {
return results[0](results[1]);
});
return seqMap(this, other, function(f, x) { return f(x); })
};

@@ -406,2 +423,4 @@

};
});
return Parser;
})();

@@ -50,2 +50,11 @@ suite('parser', function() {

test('Parsimmon.regex with group', function() {
var parser0 = regex(/(\w)(\d)/, 0);
var parser1 = regex(/(\w)(\d)/, 1);
var parser2 = regex(/(\w)(\d)/, 2);
assert.equal(parser0.parse('a1').value, 'a1');
assert.equal(parser1.parse('a1').value, 'a');
assert.equal(parser2.parse('a1').value, '1');
});
test('Parsimmon.seq', function() {

@@ -52,0 +61,0 @@ var parser = seq(string('('), regex(/[^\)]/).many(), string(')'));

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc