Socket
Socket
Sign inDemoInstall

parsimmon

Package Overview
Dependencies
0
Maintainers
3
Versions
49
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.1 to 0.7.2

build/.gitkeep

28

build/parsimmon.browser.js

@@ -1,7 +0,22 @@

// pass
var Parsimmon = {};
// This unsightly UMD-module header is here to make this code work without
// modification with CommonJS, AMD, and browser globals.
Parsimmon.Parser = (function() {
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window).
root.Parsimmon = factory();
}
}(this, function() {
"use strict";
var Parsimmon = {};
// The Parser object is a wrapper for a parser function.

@@ -18,2 +33,4 @@ // Externally, you use one to parse a string by calling

Parsimmon.Parser = Parser;
var _ = Parser.prototype;

@@ -506,4 +523,3 @@

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

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

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 i(r,n){if(!n)return r;if(r.furthest>n.furthest)return r;var t=r.furthest===n.furthest?r.expected.concat(n.expected):n.expected;return{status:r.status,index:r.index,value:r.value,furthest:n.furthest,expected:t}}function u(n){if(!(n instanceof r))throw new Error("not a parser: "+n)}function a(r){if(typeof r!=="number")throw new Error("not a number: "+r)}function o(r){if(!(r instanceof RegExp))throw new Error("not a regex: "+r)}function s(r){if(typeof r!=="function")throw new Error("not a function: "+r)}function f(r){if(typeof r!=="string")throw new Error("not a string: "+r)}function c(r){if(r.length===1)return r[0];return"one of "+r.join(", ")}function v(r,n){var t=n.index;var e=t.offset;if(e===r.length)return", got the end of the stream";var i=e>0?"'...":"'";var u=r.length-e>12?"...'":"'";return" at line "+t.line+" column "+t.column+", got "+i+r.slice(e,e+12)+u}var l=Parsimmon.formatError=function(r,n){return"expected "+c(n.expected)+v(r,n)};n.parse=function(r){if(typeof r!=="string"){throw new Error(".parse must be called with a string as its argument")}var n=this.skip(M)._(r,0);return n.status?{status:true,value:n.value}:{status:false,index:L(r,n.furthest),expected:n.expected}};var m=Parsimmon.seq=function(){var n=[].slice.call(arguments);var e=n.length;for(var a=0;a<e;a+=1){u(n[a])}return r(function(r,u){var a;var o=new Array(e);for(var s=0;s<e;s+=1){a=i(n[s]._(r,u),a);if(!a.status)return a;o[s]=a.value;u=a.index}return i(t(u,o),a)})};var h=Parsimmon.seqMap=function(){var r=[].slice.call(arguments);var n=r.pop();return m.apply(null,r).map(function(r){return n.apply(null,r)})};var p=Parsimmon.custom=function(n){return r(n(t,e))};var d=Parsimmon.alt=function(){var n=[].slice.call(arguments);var t=n.length;if(t===0)return _("zero alternates");for(var e=0;e<t;e+=1){u(n[e])}return r(function(r,t){var e;for(var u=0;u<n.length;u+=1){e=i(n[u]._(r,t),e);if(e.status)return e}return e})};var g=Parsimmon.sepBy=function(r,n){return x(r,n).or(Parsimmon.of([]))};var x=Parsimmon.sepBy1=function(r,n){u(r);u(n);var t=n.then(r).many();return r.chain(function(r){return t.map(function(n){return[r].concat(n)})})};n.or=function(r){return d(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 m(this,r).map(function(r){return r[1]})};n.many=function(){var n=this;return r(function(r,e){var u=[];var a;var o;for(;;){a=i(n._(r,e),a);if(a.status){e=a.index;u.push(a.value)}else{return i(t(e,u),a)}}})};n.times=function(n,e){if(arguments.length<2)e=n;var u=this;a(n);a(e);return r(function(r,a){var o=[];var s=a;var f;var c;for(var v=0;v<n;v+=1){f=u._(r,a);c=i(f,c);if(f.status){a=f.index;o.push(f.value)}else return c}for(;v<e;v+=1){f=u._(r,a);c=i(f,c);if(f.status){a=f.index;o.push(f.value)}else break}return i(t(a,o),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 h(this.times(r),this.many(),function(r,n){return r.concat(n)})};n.map=function(n){s(n);var e=this;return r(function(r,u){var a=e._(r,u);if(!a.status)return a;return i(t(a.index,n(a.value)),a)})};n.skip=function(r){return m(this,r).map(function(r){return r[0]})};n.mark=function(){return h(C,this,C,function(r,n,t){return{start:r,value:n,end:t}})};n.desc=function(n){var t=this;return r(function(r,e){var i=t._(r,e);if(!i.status)i.expected=[n];return i})};var P=Parsimmon.string=function(n){var i=n.length;var u="'"+n+"'";f(n);return r(function(r,a){var o=r.slice(a,a+i);if(o===n){return t(a+i,o)}else{return e(a,u)}})};var w=Parsimmon.regex=function(n,i){o(n);if(i)a(i);var u=RegExp("^(?:"+n.source+")",(""+n).slice((""+n).lastIndexOf("/")+1));var s=""+n;if(i==null)i=0;return r(function(r,n){var a=u.exec(r.slice(n));if(a){var o=a[0];var f=a[i];if(f!=null)return t(n+o.length,f)}return e(n,s)})};var y=Parsimmon.succeed=function(n){return r(function(r,e){return t(e,n)})};var _=Parsimmon.fail=function(n){return r(function(r,t){return e(t,n)})};var E=Parsimmon.letter=w(/[a-z]/i).desc("a letter");var O=Parsimmon.letters=w(/[a-z]*/i);var k=Parsimmon.digit=w(/[0-9]/).desc("a digit");var b=Parsimmon.digits=w(/[0-9]*/);var z=Parsimmon.whitespace=w(/\s+/).desc("whitespace");var A=Parsimmon.optWhitespace=w(/\s*/);var q=Parsimmon.any=r(function(r,n){if(n>=r.length)return e(n,"any character");return t(n+1,r.charAt(n))});var B=Parsimmon.all=r(function(r,n){return t(r.length,r.slice(n))});var M=Parsimmon.eof=r(function(r,n){if(n<r.length)return e(n,"EOF");return t(n,null)});var R=Parsimmon.test=function(n){s(n);return r(function(r,i){var u=r.charAt(i);if(i<r.length&&n(u)){return t(i+1,u)}else{return e(i,"a character matching "+n)}})};var W=Parsimmon.oneOf=function(r){return R(function(n){return r.indexOf(n)>=0})};var j=Parsimmon.noneOf=function(r){return R(function(n){return r.indexOf(n)<0})};var F=Parsimmon.takeWhile=function(n){s(n);return r(function(r,e){var i=e;while(i<r.length&&n(r.charAt(i)))i+=1;return t(i,r.slice(e,i))})};var I=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 L=function(r,n){var t=r.slice(0,n).split("\n");var e=t.length;var i=t[t.length-1].length+1;return{offset:n,line:e,column:i}};var C=Parsimmon.index=r(function(r,n){return t(n,L(r,n))});n.concat=n.or;n.empty=_("empty");n.of=r.of=Parsimmon.of=y;n.ap=function(r){return h(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 a=n(u.value);return i(a._(r,u.index),u)})};return r}();
(function(t,n){if(typeof define==="function"&&define.amd){define([],n)}else if(typeof module==="object"&&module.exports){module.exports=n()}else{t.Parsimmon=n()}})(this,function(){"use strict";var t={};function n(t){if(!(this instanceof n))return new n(t);this._=t}t.Parser=n;var r=n.prototype;function e(t,n){return{status:true,index:t,value:n,furthest:-1,expected:[]}}function u(t,n){return{status:false,index:-1,value:null,furthest:t,expected:[n]}}function i(t,n){if(!n)return t;if(t.furthest>n.furthest)return t;var r=t.furthest===n.furthest?t.expected.concat(n.expected):n.expected;return{status:t.status,index:t.index,value:t.value,furthest:n.furthest,expected:r}}function a(t){if(!(t instanceof n))throw new Error("not a parser: "+t)}function f(t){if(typeof t!=="number")throw new Error("not a number: "+t)}function o(t){if(!(t instanceof RegExp))throw new Error("not a regex: "+t)}function c(t){if(typeof t!=="function")throw new Error("not a function: "+t)}function s(t){if(typeof t!=="string")throw new Error("not a string: "+t)}function l(t){if(t.length===1)return t[0];return"one of "+t.join(", ")}function v(t,n){var r=n.index;var e=r.offset;if(e===t.length)return", got the end of the stream";var u=e>0?"'...":"'";var i=t.length-e>12?"...'":"'";return" at line "+r.line+" column "+r.column+", got "+u+t.slice(e,e+12)+i}var h=t.formatError=function(t,n){return"expected "+l(n.expected)+v(t,n)};r.parse=function(t){if(typeof t!=="string"){throw new Error(".parse must be called with a string as its argument")}var n=this.skip(P)._(t,0);return n.status?{status:true,value:n.value}:{status:false,index:C(t,n.furthest),expected:n.expected}};var p=t.seq=function(){var t=[].slice.call(arguments);var r=t.length;for(var u=0;u<r;u+=1){a(t[u])}return n(function(n,u){var a;var f=new Array(r);for(var o=0;o<r;o+=1){a=i(t[o]._(n,u),a);if(!a.status)return a;f[o]=a.value;u=a.index}return i(e(u,f),a)})};var d=t.seqMap=function(){var t=[].slice.call(arguments);var n=t.pop();return p.apply(null,t).map(function(t){return n.apply(null,t)})};var g=t.custom=function(t){return n(t(e,u))};var x=t.alt=function(){var t=[].slice.call(arguments);var r=t.length;if(r===0)return O("zero alternates");for(var e=0;e<r;e+=1){a(t[e])}return n(function(n,r){var e;for(var u=0;u<t.length;u+=1){e=i(t[u]._(n,r),e);if(e.status)return e}return e})};var m=t.sepBy=function(n,r){return y(n,r).or(t.of([]))};var y=t.sepBy1=function(t,n){a(t);a(n);var r=n.then(t).many();return t.chain(function(t){return r.map(function(n){return[t].concat(n)})})};r.or=function(t){return x(this,t)};r.then=function(t){if(typeof t==="function"){throw new Error("chaining features of .then are no longer supported, use .chain instead")}a(t);return p(this,t).map(function(t){return t[1]})};r.many=function(){var t=this;return n(function(n,r){var u=[];var a;var f;for(;;){a=i(t._(n,r),a);if(a.status){r=a.index;u.push(a.value)}else{return i(e(r,u),a)}}})};r.times=function(t,r){if(arguments.length<2)r=t;var u=this;f(t);f(r);return n(function(n,a){var f=[];var o=a;var c;var s;for(var l=0;l<t;l+=1){c=u._(n,a);s=i(c,s);if(c.status){a=c.index;f.push(c.value)}else return s}for(;l<r;l+=1){c=u._(n,a);s=i(c,s);if(c.status){a=c.index;f.push(c.value)}else break}return i(e(a,f),s)})};r.result=function(t){return this.map(function(n){return t})};r.atMost=function(t){return this.times(0,t)};r.atLeast=function(t){var n=this;return d(this.times(t),this.many(),function(t,n){return t.concat(n)})};r.map=function(t){c(t);var r=this;return n(function(n,u){var a=r._(n,u);if(!a.status)return a;return i(e(a.index,t(a.value)),a)})};r.skip=function(t){return p(this,t).map(function(t){return t[0]})};r.mark=function(){return d(D,this,D,function(t,n,r){return{start:t,value:n,end:r}})};r.desc=function(t){var r=this;return n(function(n,e){var u=r._(n,e);if(!u.status)u.expected=[t];return u})};var w=t.string=function(t){var r=t.length;var i="'"+t+"'";s(t);return n(function(n,a){var f=n.slice(a,a+r);if(f===t){return e(a+r,f)}else{return u(a,i)}})};var _=t.regex=function(t,r){o(t);if(r)f(r);var i=RegExp("^(?:"+t.source+")",(""+t).slice((""+t).lastIndexOf("/")+1));var a=""+t;if(r==null)r=0;return n(function(t,n){var f=i.exec(t.slice(n));if(f){var o=f[0];var c=f[r];if(c!=null)return e(n+o.length,c)}return u(n,a)})};var E=t.succeed=function(t){return n(function(n,r){return e(r,t)})};var O=t.fail=function(t){return n(function(n,r){return u(r,t)})};var b=t.letter=_(/[a-z]/i).desc("a letter");var k=t.letters=_(/[a-z]*/i);var z=t.digit=_(/[0-9]/).desc("a digit");var A=t.digits=_(/[0-9]*/);var j=t.whitespace=_(/\s+/).desc("whitespace");var q=t.optWhitespace=_(/\s*/);var B=t.any=n(function(t,n){if(n>=t.length)return u(n,"any character");return e(n+1,t.charAt(n))});var M=t.all=n(function(t,n){return e(t.length,t.slice(n))});var P=t.eof=n(function(t,n){if(n<t.length)return u(n,"EOF");return e(n,null)});var R=t.test=function(t){c(t);return n(function(n,r){var i=n.charAt(r);if(r<n.length&&t(i)){return e(r+1,i)}else{return u(r,"a character matching "+t)}})};var W=t.oneOf=function(t){return R(function(n){return t.indexOf(n)>=0})};var F=t.noneOf=function(t){return R(function(n){return t.indexOf(n)<0})};var I=t.takeWhile=function(t){c(t);return n(function(n,r){var u=r;while(u<n.length&&t(n.charAt(u)))u+=1;return e(u,n.slice(r,u))})};var L=t.lazy=function(t,r){if(arguments.length<2){r=t;t=undefined}var e=n(function(t,n){e._=r()._;return e._(t,n)});if(t)e=e.desc(t);return e};var C=function(t,n){var r=t.slice(0,n).split("\n");var e=r.length;var u=r[r.length-1].length+1;return{offset:n,line:e,column:u}};var D=t.index=n(function(t,n){return e(n,C(t,n))});r.concat=r.or;r.empty=O("empty");r.of=n.of=t.of=E;r.ap=function(t){return d(this,t,function(t,n){return t(n)})};r.chain=function(t){var r=this;return n(function(n,e){var u=r._(n,e);if(!u.status)return u;var a=t(u.value);return i(a._(n,u.index),u)})};return t});

@@ -0,10 +1,26 @@

## version 0.7.2 (2016-06-??)
* No API changes
* Switches to npm-based task running
* Switches to UMD-based code
## version 0.7.1 (2016-06-04)
* Documentation updates
* Adds line/column information to `P.index` and `.mark()`
* Adds additional type assertions
## version 0.7.0 (???)
This release may have been unpublished or something, I'm not exactly sure.
## version 0.6.0 (2015-02-24)
* add a second optional argument to `regex()` indicating group selection
* eliminates pjs dependency
* add seqMap, oneOf, and noneOf
* add a second optional argument to `regex()` indicating group selection
* eliminates pjs dependency
* add seqMap, oneOf, and noneOf
## version 0.5.1 (2014-06-25)
* Added .custom, .test, and .takeWhile for folks who don't like to use regexes.
* Added .custom, .test, and .takeWhile for folks who don't like to use regexes.

@@ -11,0 +27,0 @@ ## version 0.5.0 (2014-06-15)

{
"name": "parsimmon",
"version": "0.7.1",
"version": "0.7.2",
"description": "A monadic LL(infinity) parser combinator library",
"keywords": ["parsing", "parse", "parser combinators"],
"keywords": [
"parsing",
"parse",
"parser combinators"
],
"author": "Jeanine Adkisson <jneen at jneen dot net>",

@@ -11,13 +15,12 @@ "contributors": [

"repository": "git://github.com/jneen/parsimmon",
"files": [
"index.js", "src", "test", "Makefile", "package.json",
"build/parsimmon.commonjs.js",
"build/parsimmon.browser.js",
"build/parsimmon.browser.min.js"
"src",
"build"
],
"main": "index.js",
"main": "src/parsimmon.js",
"devDependencies": {
"chai": "1.5.x",
"mocha": "1.8.x",
"chai": "1.5.x",
"ncp": "^2.0.0",
"rimraf": "^2.5.2",
"uglify-js": "2.x"

@@ -28,4 +31,8 @@ },

"scripts": {
"test": "make test"
"clean": "rimraf build/*.js",
"build:browser": "ncp src/parsimmon.js build/parsimmon.browser.js",
"build:browser.min": "uglifyjs --mangle < src/parsimmon.js > build/parsimmon.browser.min.js",
"prepublish": "npm run test && npm run clean && npm run build:browser && npm run build:browser.min",
"test": "mocha -u tdd test/intro.js test/*.test.js"
}
}

@@ -1,6 +0,22 @@

var Parsimmon = {};
// This unsightly UMD-module header is here to make this code work without
// modification with CommonJS, AMD, and browser globals.
Parsimmon.Parser = (function() {
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window).
root.Parsimmon = factory();
}
}(this, function() {
"use strict";
var Parsimmon = {};
// The Parser object is a wrapper for a parser function.

@@ -17,2 +33,4 @@ // Externally, you use one to parse a string by calling

Parsimmon.Parser = Parser;
var _ = Parser.prototype;

@@ -505,3 +523,3 @@

return Parser;
})();
return Parsimmon;
}));
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc