func-params
Advanced tools
Comparing version 0.9.16 to 0.9.17
/* | ||
** func-params -- Run-Time Function Parameter Name Determination | ||
** Copyright (c) 2018-2019 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** Copyright (c) 2018-2021 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** | ||
@@ -5,0 +5,0 @@ ** Permission is hereby granted, free of charge, to any person obtaining |
/* | ||
** func-params -- Run-Time Function Parameter Name Determination | ||
** Copyright (c) 2018-2019 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** Copyright (c) 2018-2021 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** | ||
@@ -31,3 +31,3 @@ ** Permission is hereby granted, free of charge, to any person obtaining | ||
(function (global){ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Tokenizr=t()}}(function(){return function(){return function t(n,e,i){function r(s,a){if(!e[s]){if(!n[s]){var u="function"==typeof _dereq_&&_dereq_;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=e[s]={exports:{}};n[s][0].call(h.exports,function(t){return r(n[s][1][t]||t)},h,h.exports,t,n,e,i)}return e[s].exports}for(var o="function"==typeof _dereq_&&_dereq_,s=0;s<i.length;s++)r(i[s]);return r}}()({1:[function(t,n,e){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,n){return!n||"object"!==i(n)&&"function"!=typeof n?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):n}function o(t){var n="function"==typeof Map?new Map:void 0;return(o=function(t){if(null===t||!function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return function(t,n,e){return(function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct:function(t,n,e){var i=[null];i.push.apply(i,n);var r=new(Function.bind.apply(t,i));return e&&s(r,e.prototype),r}).apply(null,arguments)}(t,arguments,a(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),s(e,t)})(t)}function s(t,n){return(s=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function c(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function h(t,n,e){return n&&c(t.prototype,n),e&&c(t,e),t}var l=function(t,n){var e=t.length,i=n-20;i<0&&(i=0);var r=n+20;r>e&&(r=e);var o=function(t){return t.charCodeAt(0).toString(16).toUpperCase()},s=function(t,n,e){return t.substr(n,e).replace(/\\/g,"\\\\").replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(t){return"\\x0"+o(t)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(t){return"\\x"+o(t)}).replace(/[\u0100-\u0FFF]/g,function(t){return"\\u0"+o(t)}).replace(/[\u1000-\uFFFF]/g,function(t){return"\\u"+o(t)})};return{prologTrunc:i>0,prologText:s(t,i,n-i),tokenText:s(t,n,1),epilogText:s(t,n+1,r-(n+1)),epilogTrunc:r<e}},f=function(){function t(n,e,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;u(this,t),this.type=n,this.value=e,this.text=i,this.pos=r,this.line=o,this.column=s}return h(t,[{key:"toString",value:function(){return"<type: ".concat(this.type,", ")+"value: ".concat(JSON.stringify(this.value),", ")+"text: ".concat(JSON.stringify(this.text),", ")+"pos: ".concat(this.pos,", ")+"line: ".concat(this.line,", ")+"column: ".concat(this.column,">")}},{key:"isA",value:function(t,n){return t===this.type&&(2!==arguments.length||n===this.value)}}]),t}(),p=function(t){function n(t,e,i,o,s){var c;return u(this,n),(c=r(this,a(n).call(this,t))).name="ParsingError",c.message=t,c.pos=e,c.line=i,c.column=o,c.input=s,c}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),n&&s(t,n)}(n,o(Error)),h(n,[{key:"toString",value:function(){for(var t=l(this.input,this.pos),n="line ".concat(this.line," (column ").concat(this.column,"): "),e="",i=0;i<n.length+t.prologText.length;i++)e+=" ";return"Parsing Error: "+this.message+"\n"+n+t.prologText+t.tokenText+t.epilogText+"\n"+e+"^"}}]),n}(),_=function(){function t(n){u(this,t),this._tokenizr=n,this._data={},this._repeat=!1,this._reject=!1,this._ignore=!1,this._match=null}return h(t,[{key:"data",value:function(t,n){var e=this._data[t];return 2===arguments.length&&(this._data[t]=n),e}},{key:"info",value:function(){return{line:this._tokenizr._line,column:this._tokenizr._column,pos:this._tokenizr._pos,len:this._match[0].length}}},{key:"push",value:function(){var t;return(t=this._tokenizr).push.apply(t,arguments),this}},{key:"pop",value:function(){var t;return(t=this._tokenizr).pop.apply(t,arguments)}},{key:"state",value:function(){var t,n;return arguments.length>0?((n=this._tokenizr).state.apply(n,arguments),this):(t=this._tokenizr).state.apply(t,arguments)}},{key:"tag",value:function(){var t;return(t=this._tokenizr).tag.apply(t,arguments),this}},{key:"tagged",value:function(){var t;return(t=this._tokenizr).tagged.apply(t,arguments)}},{key:"untag",value:function(){var t;return(t=this._tokenizr).untag.apply(t,arguments),this}},{key:"repeat",value:function(){return this._tokenizr._log(" REPEAT"),this._repeat=!0,this}},{key:"reject",value:function(){return this._tokenizr._log(" REJECT"),this._reject=!0,this}},{key:"ignore",value:function(){return this._tokenizr._log(" IGNORE"),this._ignore=!0,this}},{key:"accept",value:function(t,n){return arguments.length<2&&(n=this._match[0]),this._tokenizr._log(" ACCEPT: type: ".concat(t,", value: ")+"".concat(JSON.stringify(n)," (").concat(i(n),'), text: "').concat(this._match[0],'"')),this._tokenizr._pending.push(new f(t,n,this._match[0],this._tokenizr._pos,this._tokenizr._line,this._tokenizr._column)),this}},{key:"stop",value:function(){return this._tokenizr._stopped=!0,this}}]),t}(),g=function(){function t(){u(this,t),this._before=null,this._after=null,this._finish=null,this._rules=[],this._debug=!1,this.reset()}return h(t,[{key:"reset",value:function(){return this._input="",this._len=0,this._eof=!1,this._pos=0,this._line=1,this._column=1,this._state=["default"],this._tag={},this._transaction=[],this._pending=[],this._stopped=!1,this._ctx=new _(this),this}},{key:"error",value:function(t){return new p(t,this._pos,this._line,this._column,this._input)}},{key:"debug",value:function(t){return this._debug=t,this}},{key:"_log",value:function(t){this._debug&&console.log("tokenizr: ".concat(t))}},{key:"input",value:function(t){if("string"!=typeof t)throw new Error('parameter "input" not a String');return this.reset(),this._input=t,this._len=t.length,this}},{key:"push",value:function(t){if(1!==arguments.length)throw new Error("invalid number of arguments");if("string"!=typeof t)throw new Error('parameter "state" not a String');return this._log(" STATE (PUSH): "+"old: <".concat(this._state[this._state.length-1],">, ")+"new: <".concat(t,">")),this._state.push(t),this}},{key:"pop",value:function(){if(0!==arguments.length)throw new Error("invalid number of arguments");if(this._state.length<2)throw new Error("no more custom states to pop");return this._log(" STATE (POP): "+"old: <".concat(this._state[this._state.length-1],">, ")+"new: <".concat(this._state[this._state.length-2],">")),this._state.pop()}},{key:"state",value:function(t){if(1===arguments.length){if("string"!=typeof t)throw new Error('parameter "state" not a String');return this._log(" STATE (SET): "+"old: <".concat(this._state[this._state.length-1],">, ")+"new: <".concat(t,">")),this._state[this._state.length-1]=t,this}if(0===arguments.length)return this._state[this._state.length-1];throw new Error("invalid number of arguments")}},{key:"tag",value:function(t){if(1!==arguments.length)throw new Error("invalid number of arguments");if("string"!=typeof t)throw new Error('parameter "tag" not a String');return this._log(" TAG (ADD): ".concat(t)),this._tag[t]=!0,this}},{key:"tagged",value:function(t){if(1!==arguments.length)throw new Error("invalid number of arguments");if("string"!=typeof t)throw new Error('parameter "tag" not a String');return!0===this._tag[t]}},{key:"untag",value:function(t){if(1!==arguments.length)throw new Error("invalid number of arguments");if("string"!=typeof t)throw new Error('parameter "tag" not a String');return this._log(" TAG (DEL): ".concat(t)),delete this._tag[t],this}},{key:"before",value:function(t){return this._before=t,this}},{key:"after",value:function(t){return this._after=t,this}},{key:"finish",value:function(t){return this._finish=t,this}},{key:"rule",value:function(t,n,e){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unknown";if(2===arguments.length&&"function"==typeof n){var o=[t,n];n=o[0],e=o[1],t="*"}else if(3===arguments.length&&"function"==typeof n){var s=[t,n,e];n=s[0],e=s[1],r=s[2],t="*"}if("string"!=typeof t)throw new Error('parameter "state" not a String');if(!("object"===i(n)&&n instanceof RegExp))throw new Error('parameter "pattern" not a RegExp');if("function"!=typeof e)throw new Error('parameter "action" not a Function');if("string"!=typeof r)throw new Error('parameter "name" not a String');t=t.split(/\s*,\s*/g).map(function(t){var n=t.split(/\s+/g),e=n.filter(function(t){return null===t.match(/^#/)}),i=n.filter(function(t){return null!==t.match(/^#/)}).map(function(t){return t.replace(/^#/,"")});if(1!==e.length)throw new Error("exactly one state required");return{state:e[0],tags:i}});var a="g";try{"boolean"==typeof new RegExp("","y").sticky&&(a="y")}catch(t){}return"boolean"==typeof n.multiline&&n.multiline&&(a+="m"),"boolean"==typeof n.dotAll&&n.dotAll&&(a+="s"),"boolean"==typeof n.ignoreCase&&n.ignoreCase&&(a+="i"),"boolean"==typeof n.unicode&&n.unicode&&(a+="u"),n=new RegExp(n.source,a),this._log("rule: configure rule (state: ".concat(t,", pattern: ").concat(n.source,")")),this._rules.push({state:t,pattern:n,action:e,name:r}),this}},{key:"_progress",value:function(t,n){for(var e=this._line,i=this._column,r=this._input,o=t;o<n;o++){var s=r.charAt(o);"\r"===s?this._column=1:"\n"===s?(this._line++,this._column=1):"\t"===s?this._column+=8-this._column%8:this._column++}this._log(" PROGRESS: characters: ".concat(n-t,", ")+"from: <line ".concat(e,", column ").concat(i,">, ")+"to: <line ".concat(this._line,", column ").concat(this._column,">"))}},{key:"_tokenize",value:function(){var t=this,n=function(){t._eof||(null!==t._finish&&t._finish.call(t._ctx,t._ctx),t._eof=!0,t._pending.push(new f("EOF","","",t._pos,t._line,t._column)))};if(!(this._stopped||this._pos>=this._len)){for(var e=!0;e;){if(e=!1,this._debug){var i=l(this._input,this._pos),r=Object.keys(this._tag).map(function(t){return"#".concat(t)}).join(" ");this._log("INPUT: state: <".concat(this._state[this._state.length-1],">, tags: <").concat(r,">, text: ")+(i.prologTrunc?"...":'"')+"".concat(i.prologText,"<").concat(i.tokenText,">").concat(i.epilogText)+(i.epilogTrunc?"...":'"')+", at: <line ".concat(this._line,", column ").concat(this._column,">"))}for(var o=0;o<this._rules.length;o++){if(this._debug){var s=this._rules[o].state.map(function(t){var n=t.state;return t.tags.length>0&&(n+=" "+t.tags.map(function(t){return"#".concat(t)}).join(" ")),n}).join(", ");this._log(" RULE: state(s): <".concat(s,">, ")+"pattern: ".concat(this._rules[o].pattern.source))}var a=!1,u=this._rules[o].state.map(function(t){return t.state}),c=u.indexOf("*");if(c<0&&(c=u.indexOf(this._state[this._state.length-1])),c>=0){a=!0;var h=this._rules[o].state[c].tags;(h=h.filter(function(n){return!t._tag[n]})).length>0&&(a=!1)}if(a){this._rules[o].pattern.lastIndex=this._pos;var p=this._rules[o].pattern.exec(this._input);if(this._rules[o].pattern.lastIndex=this._pos,null!==(p=this._rules[o].pattern.exec(this._input))&&p.index===this._pos){if(this._debug&&this._log(" MATCHED: "+JSON.stringify(p)),this._ctx._match=p,this._ctx._repeat=!1,this._ctx._reject=!1,this._ctx._ignore=!1,null!==this._before&&this._before.call(this._ctx,this._ctx,p,this._rules[o]),this._rules[o].action.call(this._ctx,this._ctx,p),null!==this._after&&this._after.call(this._ctx,this._ctx,p,this._rules[o]),this._ctx._reject)continue;if(this._ctx._repeat){e=!0;break}if(this._ctx._ignore){if(this._progress(this._pos,this._rules[o].pattern.lastIndex),this._pos=this._rules[o].pattern.lastIndex,this._pos>=this._len)return void n();e=!0;break}if(this._pending.length>0)return this._progress(this._pos,this._rules[o].pattern.lastIndex),this._pos=this._rules[o].pattern.lastIndex,void(this._pos>=this._len&&n());throw new Error('action of pattern "'+this._rules[o].pattern.source+'" neither rejected nor accepted any token(s)')}}}}throw this.error("token not recognized")}n()}},{key:"token",value:function(){if(0===this._pending.length&&this._tokenize(),this._pending.length>0){var t=this._pending.shift();return this._transaction.length>0&&this._transaction[0].push(t),this._log("TOKEN: ".concat(t.toString())),t}return null}},{key:"tokens",value:function(){for(var t,n=[];null!==(t=this.token());)n.push(t);return n}},{key:"peek",value:function(t){void 0===t&&(t=0);for(var n=0;n<this._pending.length+t;n++)this._tokenize();if(t>=this._pending.length)throw new Error("not enough tokens available for peek operation");return this._log("PEEK: ".concat(this._pending[t].toString())),this._pending[t]}},{key:"skip",value:function(t){void 0===t&&(t=1);for(var n=0;n<this._pending.length+t;n++)this._tokenize();if(t>this._pending.length)throw new Error("not enough tokens available for skip operation");for(;t-- >0;)this.token();return this}},{key:"consume",value:function(t,n){for(var e=this,r=0;r<this._pending.length+1;r++)this._tokenize();if(0===this._pending.length)throw new Error("not enough tokens available for consume operation");var o=this.token();this._log("CONSUME: ".concat(o.toString()));var s=function(){throw new p("expected: <type: ".concat(t,", value: ").concat(JSON.stringify(n)," (").concat(i(n),")>, ")+"found: <type: ".concat(o.type,", value: ").concat(JSON.stringify(o.value)," (").concat(i(o.value),")>"),o.pos,o.line,o.column,e._input)};return 2!==arguments.length||o.isA(t,n)?o.isA(t)||s():s(JSON.stringify(n),i(n)),o}},{key:"begin",value:function(){return this._log("BEGIN: level ".concat(this._transaction.length)),this._transaction.unshift([]),this}},{key:"depth",value:function(){if(0===this._transaction.length)throw new Error("cannot determine depth -- no active transaction");return this._transaction[0].length}},{key:"commit",value:function(){if(0===this._transaction.length)throw new Error("cannot commit transaction -- no active transaction");return this._transaction.shift(),this._log("COMMIT: level ".concat(this._transaction.length)),this}},{key:"rollback",value:function(){if(0===this._transaction.length)throw new Error("cannot rollback transaction -- no active transaction");return this._pending=this._transaction[0].concat(this._pending),this._transaction.shift(),this._log("ROLLBACK: level ".concat(this._transaction.length)),this}},{key:"alternatives",value:function(){for(var t=null,n=[],e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];for(var o=0;o<i.length;o++)try{this.begin(),t=i[o].call(this),this.commit();break}catch(t){this._log("EXCEPTION: ".concat(t.toString())),n.push({ex:t,depth:this.depth()}),this.rollback();continue}if(null===t&&n.length>0)throw(n=n.sort(function(t,n){return t.depth-n.depth}))[0].ex;return t}}]),t}();g.Token=f,g.ParsingError=p,g.ActionContext=_,n.exports=g},{}]},{},[1])(1)}); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Tokenizr=t()}}(function(){return function(){return function t(n,e,i){function r(s,a){if(!e[s]){if(!n[s]){var u="function"==typeof _dereq_&&_dereq_;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=e[s]={exports:{}};n[s][0].call(h.exports,function(t){return r(n[s][1][t]||t)},h,h.exports,t,n,e,i)}return e[s].exports}for(var o="function"==typeof _dereq_&&_dereq_,s=0;s<i.length;s++)r(i[s]);return r}}()({1:[function(t,n,e){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t){var n=s();return function(){var e,r=u(t);if(n){var o=u(this).constructor;e=Reflect.construct(r,arguments,o)}else e=r.apply(this,arguments);return function(t,n){return!n||"object"!==i(n)&&"function"!=typeof n?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):n}(this,e)}}function o(t){var n="function"==typeof Map?new Map:void 0;return(o=function(t){if(null===t||!function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return function(t,n,e){return(s()?Reflect.construct:function(t,n,e){var i=[null];i.push.apply(i,n);var r=new(Function.bind.apply(t,i));return e&&a(r,e.prototype),r}).apply(null,arguments)}(t,arguments,u(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),a(e,t)})(t)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}function a(t,n){return(a=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function h(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function l(t,n,e){return n&&h(t.prototype,n),e&&h(t,e),t}var f=function(t,n){var e=t.length,i=n-20;i<0&&(i=0);var r=n+20;r>e&&(r=e);var o=function(t){return t.charCodeAt(0).toString(16).toUpperCase()},s=function(t,n,e){return t.substr(n,e).replace(/\\/g,"\\\\").replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(t){return"\\x0"+o(t)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(t){return"\\x"+o(t)}).replace(/[\u0100-\u0FFF]/g,function(t){return"\\u0"+o(t)}).replace(/[\u1000-\uFFFF]/g,function(t){return"\\u"+o(t)})};return{prologTrunc:i>0,prologText:s(t,i,n-i),tokenText:s(t,n,1),epilogText:s(t,n+1,r-(n+1)),epilogTrunc:r<e}},p=function(){function t(n,e,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;c(this,t),this.type=n,this.value=e,this.text=i,this.pos=r,this.line=o,this.column=s}return l(t,[{key:"toString",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(t,n){return n};return"".concat(t("type",this.type)," ")+"(value: ".concat(t("value",JSON.stringify(this.value)),", ")+"text: ".concat(t("text",JSON.stringify(this.text)),", ")+"pos: ".concat(t("pos",this.pos),", ")+"line: ".concat(t("line",this.line),", ")+"column: ".concat(t("column",this.column),")")}},{key:"isA",value:function(t,n){return t===this.type&&(2!==arguments.length||n===this.value)}}]),t}(),_=function(t){!function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),n&&a(t,n)}(e,o(Error));var n=r(e);function e(t,i,r,o,s){var a;return c(this,e),(a=n.call(this,t)).name="ParsingError",a.message=t,a.pos=i,a.line=r,a.column=o,a.input=s,a}return l(e,[{key:"toString",value:function(){for(var t=f(this.input,this.pos),n="line ".concat(this.line," (column ").concat(this.column,"): "),e="",i=0;i<n.length+t.prologText.length;i++)e+=" ";return"Parsing Error: "+this.message+"\n"+n+t.prologText+t.tokenText+t.epilogText+"\n"+e+"^"}}]),e}(),g=function(){function t(n){c(this,t),this._tokenizr=n,this._data={},this._repeat=!1,this._reject=!1,this._ignore=!1,this._match=null}return l(t,[{key:"data",value:function(t,n){var e=this._data[t];return 2===arguments.length&&(this._data[t]=n),e}},{key:"info",value:function(){return{line:this._tokenizr._line,column:this._tokenizr._column,pos:this._tokenizr._pos,len:this._match[0].length}}},{key:"push",value:function(){var t;return(t=this._tokenizr).push.apply(t,arguments),this}},{key:"pop",value:function(){var t;return(t=this._tokenizr).pop.apply(t,arguments)}},{key:"state",value:function(){var t,n;return arguments.length>0?((n=this._tokenizr).state.apply(n,arguments),this):(t=this._tokenizr).state.apply(t,arguments)}},{key:"tag",value:function(){var t;return(t=this._tokenizr).tag.apply(t,arguments),this}},{key:"tagged",value:function(){var t;return(t=this._tokenizr).tagged.apply(t,arguments)}},{key:"untag",value:function(){var t;return(t=this._tokenizr).untag.apply(t,arguments),this}},{key:"repeat",value:function(){return this._tokenizr._log(" REPEAT"),this._repeat=!0,this}},{key:"reject",value:function(){return this._tokenizr._log(" REJECT"),this._reject=!0,this}},{key:"ignore",value:function(){return this._tokenizr._log(" IGNORE"),this._ignore=!0,this}},{key:"accept",value:function(t,n){return arguments.length<2&&(n=this._match[0]),this._tokenizr._log(" ACCEPT: type: ".concat(t,", value: ")+"".concat(JSON.stringify(n)," (").concat(i(n),'), text: "').concat(this._match[0],'"')),this._tokenizr._pending.push(new p(t,n,this._match[0],this._tokenizr._pos,this._tokenizr._line,this._tokenizr._column)),this}},{key:"stop",value:function(){return this._tokenizr._stopped=!0,this}}]),t}(),v=function(){function t(){c(this,t),this._before=null,this._after=null,this._finish=null,this._rules=[],this._debug=!1,this.reset()}return l(t,[{key:"reset",value:function(){return this._input="",this._len=0,this._eof=!1,this._pos=0,this._line=1,this._column=1,this._state=["default"],this._tag={},this._transaction=[],this._pending=[],this._stopped=!1,this._ctx=new g(this),this}},{key:"error",value:function(t){return new _(t,this._pos,this._line,this._column,this._input)}},{key:"debug",value:function(t){return this._debug=t,this}},{key:"_log",value:function(t){this._debug&&console.log("tokenizr: ".concat(t))}},{key:"input",value:function(t){if("string"!=typeof t)throw new Error('parameter "input" not a String');return this.reset(),this._input=t,this._len=t.length,this}},{key:"push",value:function(t){if(1!==arguments.length)throw new Error("invalid number of arguments");if("string"!=typeof t)throw new Error('parameter "state" not a String');return this._log(" STATE (PUSH): "+"old: <".concat(this._state[this._state.length-1],">, ")+"new: <".concat(t,">")),this._state.push(t),this}},{key:"pop",value:function(){if(0!==arguments.length)throw new Error("invalid number of arguments");if(this._state.length<2)throw new Error("no more custom states to pop");return this._log(" STATE (POP): "+"old: <".concat(this._state[this._state.length-1],">, ")+"new: <".concat(this._state[this._state.length-2],">")),this._state.pop()}},{key:"state",value:function(t){if(1===arguments.length){if("string"!=typeof t)throw new Error('parameter "state" not a String');return this._log(" STATE (SET): "+"old: <".concat(this._state[this._state.length-1],">, ")+"new: <".concat(t,">")),this._state[this._state.length-1]=t,this}if(0===arguments.length)return this._state[this._state.length-1];throw new Error("invalid number of arguments")}},{key:"tag",value:function(t){if(1!==arguments.length)throw new Error("invalid number of arguments");if("string"!=typeof t)throw new Error('parameter "tag" not a String');return this._log(" TAG (ADD): ".concat(t)),this._tag[t]=!0,this}},{key:"tagged",value:function(t){if(1!==arguments.length)throw new Error("invalid number of arguments");if("string"!=typeof t)throw new Error('parameter "tag" not a String');return!0===this._tag[t]}},{key:"untag",value:function(t){if(1!==arguments.length)throw new Error("invalid number of arguments");if("string"!=typeof t)throw new Error('parameter "tag" not a String');return this._log(" TAG (DEL): ".concat(t)),delete this._tag[t],this}},{key:"before",value:function(t){return this._before=t,this}},{key:"after",value:function(t){return this._after=t,this}},{key:"finish",value:function(t){return this._finish=t,this}},{key:"rule",value:function(t,n,e){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unknown";if(2===arguments.length&&"function"==typeof n){var o=[t,n];n=o[0],e=o[1],t="*"}else if(3===arguments.length&&"function"==typeof n){var s=[t,n,e];n=s[0],e=s[1],r=s[2],t="*"}if("string"!=typeof t)throw new Error('parameter "state" not a String');if(!("object"===i(n)&&n instanceof RegExp))throw new Error('parameter "pattern" not a RegExp');if("function"!=typeof e)throw new Error('parameter "action" not a Function');if("string"!=typeof r)throw new Error('parameter "name" not a String');t=t.split(/\s*,\s*/g).map(function(t){var n=t.split(/\s+/g),e=n.filter(function(t){return null===t.match(/^#/)}),i=n.filter(function(t){return null!==t.match(/^#/)}).map(function(t){return t.replace(/^#/,"")});if(1!==e.length)throw new Error("exactly one state required");return{state:e[0],tags:i}});var a="g";try{"boolean"==typeof new RegExp("","y").sticky&&(a="y")}catch(t){}return"boolean"==typeof n.multiline&&n.multiline&&(a+="m"),"boolean"==typeof n.dotAll&&n.dotAll&&(a+="s"),"boolean"==typeof n.ignoreCase&&n.ignoreCase&&(a+="i"),"boolean"==typeof n.unicode&&n.unicode&&(a+="u"),n=new RegExp(n.source,a),this._log("rule: configure rule (state: ".concat(t,", pattern: ").concat(n.source,")")),this._rules.push({state:t,pattern:n,action:e,name:r}),this}},{key:"_progress",value:function(t,n){for(var e=this._line,i=this._column,r=this._input,o=t;o<n;o++){var s=r.charAt(o);"\r"===s?this._column=1:"\n"===s?(this._line++,this._column=1):"\t"===s?this._column+=8-this._column%8:this._column++}this._log(" PROGRESS: characters: ".concat(n-t,", ")+"from: <line ".concat(e,", column ").concat(i,">, ")+"to: <line ".concat(this._line,", column ").concat(this._column,">"))}},{key:"_tokenize",value:function(){var t=this,n=function(){t._eof||(null!==t._finish&&t._finish.call(t._ctx,t._ctx),t._eof=!0,t._pending.push(new p("EOF","","",t._pos,t._line,t._column)))};if(!(this._stopped||this._pos>=this._len)){for(var e=!0;e;){if(e=!1,this._debug){var i=f(this._input,this._pos),r=Object.keys(this._tag).map(function(t){return"#".concat(t)}).join(" ");this._log("INPUT: state: <".concat(this._state[this._state.length-1],">, tags: <").concat(r,">, text: ")+(i.prologTrunc?"...":'"')+"".concat(i.prologText,"<").concat(i.tokenText,">").concat(i.epilogText)+(i.epilogTrunc?"...":'"')+", at: <line ".concat(this._line,", column ").concat(this._column,">"))}for(var o=0;o<this._rules.length;o++){if(this._debug){var s=this._rules[o].state.map(function(t){var n=t.state;return t.tags.length>0&&(n+=" "+t.tags.map(function(t){return"#".concat(t)}).join(" ")),n}).join(", ");this._log(" RULE: state(s): <".concat(s,">, ")+"pattern: ".concat(this._rules[o].pattern.source))}var a=!1,u=this._rules[o].state.map(function(t){return t.state}),c=u.indexOf("*");if(c<0&&(c=u.indexOf(this._state[this._state.length-1])),c>=0){a=!0;var h=this._rules[o].state[c].tags;(h=h.filter(function(n){return!t._tag[n]})).length>0&&(a=!1)}if(a){this._rules[o].pattern.lastIndex=this._pos;var l=this._rules[o].pattern.exec(this._input);if(this._rules[o].pattern.lastIndex=this._pos,null!==(l=this._rules[o].pattern.exec(this._input))&&l.index===this._pos){if(this._debug&&this._log(" MATCHED: "+JSON.stringify(l)),this._ctx._match=l,this._ctx._repeat=!1,this._ctx._reject=!1,this._ctx._ignore=!1,null!==this._before&&this._before.call(this._ctx,this._ctx,l,this._rules[o]),this._rules[o].action.call(this._ctx,this._ctx,l),null!==this._after&&this._after.call(this._ctx,this._ctx,l,this._rules[o]),this._ctx._reject)continue;if(this._ctx._repeat){e=!0;break}if(this._ctx._ignore){if(this._progress(this._pos,this._rules[o].pattern.lastIndex),this._pos=this._rules[o].pattern.lastIndex,this._pos>=this._len)return void n();e=!0;break}if(this._pending.length>0)return this._progress(this._pos,this._rules[o].pattern.lastIndex),this._pos=this._rules[o].pattern.lastIndex,void(this._pos>=this._len&&n());throw new Error('action of pattern "'+this._rules[o].pattern.source+'" neither rejected nor accepted any token(s)')}}}}throw this.error("token not recognized")}n()}},{key:"token",value:function(){if(0===this._pending.length&&this._tokenize(),this._pending.length>0){var t=this._pending.shift();return this._transaction.length>0&&this._transaction[0].push(t),this._log("TOKEN: ".concat(t.toString())),t}return null}},{key:"tokens",value:function(){for(var t,n=[];null!==(t=this.token());)n.push(t);return n}},{key:"peek",value:function(t){void 0===t&&(t=0);for(var n=0;n<this._pending.length+t;n++)this._tokenize();if(t>=this._pending.length)throw new Error("not enough tokens available for peek operation");return this._log("PEEK: ".concat(this._pending[t].toString())),this._pending[t]}},{key:"skip",value:function(t){void 0===t&&(t=1);for(var n=0;n<this._pending.length+t;n++)this._tokenize();if(t>this._pending.length)throw new Error("not enough tokens available for skip operation");for(;t-- >0;)this.token();return this}},{key:"consume",value:function(t,n){for(var e=this,r=0;r<this._pending.length+1;r++)this._tokenize();if(0===this._pending.length)throw new Error("not enough tokens available for consume operation");var o=this.token();this._log("CONSUME: ".concat(o.toString()));var s=function(){throw new _("expected: <type: ".concat(t,", value: ").concat(JSON.stringify(n)," (").concat(i(n),")>, ")+"found: <type: ".concat(o.type,", value: ").concat(JSON.stringify(o.value)," (").concat(i(o.value),")>"),o.pos,o.line,o.column,e._input)};return 2!==arguments.length||o.isA(t,n)?o.isA(t)||s():s(JSON.stringify(n),i(n)),o}},{key:"begin",value:function(){return this._log("BEGIN: level ".concat(this._transaction.length)),this._transaction.unshift([]),this}},{key:"depth",value:function(){if(0===this._transaction.length)throw new Error("cannot determine depth -- no active transaction");return this._transaction[0].length}},{key:"commit",value:function(){if(0===this._transaction.length)throw new Error("cannot commit transaction -- no active transaction");var t=this._transaction.shift();return this._transaction.length>0&&(this._transaction[0]=this._transaction[0].concat(t)),this._log("COMMIT: level ".concat(this._transaction.length)),this}},{key:"rollback",value:function(){if(0===this._transaction.length)throw new Error("cannot rollback transaction -- no active transaction");var t=this._transaction.shift();return this._pending=t.concat(this._pending),this._log("ROLLBACK: level ".concat(this._transaction.length)),this}},{key:"alternatives",value:function(){for(var t=null,n=[],e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];for(var o=0;o<i.length;o++)try{this.begin(),t=i[o].call(this),this.commit();break}catch(t){this._log("EXCEPTION: ".concat(t.toString())),n.push({ex:t,depth:this.depth()}),this.rollback();continue}if(null===t&&n.length>0)throw(n=n.sort(function(t,n){return t.depth-n.depth}))[0].ex;return t}}]),t}();v.Token=p,v.ParsingError=_,v.ActionContext=g,n.exports=v},{}]},{},[1])(1)}); | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
@@ -34,0 +34,0 @@ },{}],3:[function(_dereq_,module,exports){ |
/* | ||
** func-params -- Run-Time Function Parameter Name Determination | ||
** Copyright (c) 2018-2019 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** Copyright (c) 2018-2021 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** | ||
@@ -30,3 +30,3 @@ ** Permission is hereby granted, free of charge, to any person obtaining | ||
** func-params -- Run-Time Function Parameter Name Determination | ||
** Copyright (c) 2018-2019 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** Copyright (c) 2018-2021 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** | ||
@@ -33,0 +33,0 @@ ** Permission is hereby granted, free of charge, to any person obtaining |
@@ -5,3 +5,3 @@ { | ||
"description": "Run-Time Function Parameter Name Determination", | ||
"version": "0.9.16", | ||
"version": "0.9.17", | ||
"license": "MIT", | ||
@@ -24,3 +24,3 @@ "author": { | ||
"devDependencies": { | ||
"grunt": "1.0.4", | ||
"grunt": "1.3.0", | ||
"grunt-cli": "1.3.2", | ||
@@ -30,5 +30,5 @@ "grunt-contrib-clean": "2.0.0", | ||
"grunt-mocha-test": "0.13.3", | ||
"grunt-eslint": "22.0.0", | ||
"babel-eslint": "10.0.3", | ||
"mocha": "6.2.2", | ||
"grunt-eslint": "23.0.0", | ||
"babel-eslint": "10.1.0", | ||
"mocha": "8.2.1", | ||
"chai": "4.2.0", | ||
@@ -38,17 +38,16 @@ "envify": "4.1.0", | ||
"babelify": "10.0.0", | ||
"eslint": "6.8.0", | ||
"eslint-config-standard": "14.1.0", | ||
"eslint-plugin-standard": "4.0.1", | ||
"eslint": "7.17.0", | ||
"eslint-config-standard": "16.0.2", | ||
"eslint-plugin-promise": "4.2.1", | ||
"eslint-plugin-import": "2.19.1", | ||
"eslint-plugin-node": "10.0.0", | ||
"@babel/core": "7.7.7", | ||
"@babel/preset-env": "7.7.7", | ||
"@babel/plugin-transform-runtime": "7.7.6", | ||
"browserify-header": "1.0.1", | ||
"browserify-derequire": "1.0.1" | ||
"eslint-plugin-import": "2.22.1", | ||
"eslint-plugin-node": "11.1.0", | ||
"@babel/core": "7.12.10", | ||
"@babel/preset-env": "7.12.11", | ||
"@babel/plugin-transform-runtime": "7.12.10", | ||
"browserify-header": "1.1.0", | ||
"browserify-derequire": "1.1.1" | ||
}, | ||
"dependencies" : { | ||
"tokenizr": "1.5.5", | ||
"cache-lru": "1.1.10" | ||
"tokenizr": "1.6.3", | ||
"cache-lru": "1.1.11" | ||
}, | ||
@@ -55,0 +54,0 @@ "engines": { |
@@ -56,3 +56,3 @@ | ||
Copyright (c) 2018-2019 Dr. Ralf S. Engelschall (http://engelschall.com/) | ||
Copyright (c) 2018-2021 Dr. Ralf S. Engelschall (http://engelschall.com/) | ||
@@ -59,0 +59,0 @@ Permission is hereby granted, free of charge, to any person obtaining |
/* | ||
** func-params -- Run-Time Function Parameter Name Determination | ||
** Copyright (c) 2018-2019 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** Copyright (c) 2018-2021 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** | ||
@@ -5,0 +5,0 @@ ** Permission is hereby granted, free of charge, to any person obtaining |
/* | ||
** func-params -- Run-Time Function Parameter Name Determination | ||
** Copyright (c) 2018-2019 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** Copyright (c) 2018-2021 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** | ||
@@ -5,0 +5,0 @@ ** Permission is hereby granted, free of charge, to any person obtaining |
/* | ||
** func-params -- Run-Time Function Parameter Name Determination | ||
** Copyright (c) 2018-2019 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** Copyright (c) 2018-2021 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** | ||
@@ -5,0 +5,0 @@ ** Permission is hereby granted, free of charge, to any person obtaining |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
55725
22
655
+ Addedcache-lru@1.1.11(transitive)
+ Addedtokenizr@1.6.3(transitive)
- Removedcache-lru@1.1.10(transitive)
- Removedtokenizr@1.5.5(transitive)
Updatedcache-lru@1.1.11
Updatedtokenizr@1.6.3