8 lines
117 KiB
JavaScript
8 lines
117 KiB
JavaScript
|
|
// peggy 4.0.2
|
||
|
|
//
|
||
|
|
// https://peggyjs.org/
|
||
|
|
//
|
||
|
|
// Copyright (c) 2024- the Peggy authors
|
||
|
|
// Licensed under the MIT License.
|
||
|
|
|
||
|
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).peggy=t()}(this,(function(){"use strict";var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var GrammarLocation$4=function(){function GrammarLocation(e,t){this.source=e,this.start=t}return GrammarLocation.prototype.toString=function(){return String(this.source)},GrammarLocation.prototype.offset=function(e){return{line:e.line+this.start.line-1,column:1===e.line?e.column+this.start.column-1:e.column,offset:e.offset+this.start.offset}},GrammarLocation.offsetStart=function(e){return e.source&&"function"==typeof e.source.offset?e.source.offset(e.start):e.start},GrammarLocation.offsetEnd=function(e){return e.source&&"function"==typeof e.source.offset?e.source.offset(e.end):e.end},GrammarLocation}(),grammarLocation=GrammarLocation$4,__extends=commonjsGlobal&&commonjsGlobal.__extends||(extendStatics=function(e,t){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},extendStatics(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),extendStatics,GrammarLocation$3=grammarLocation,setProtoOf=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},GrammarError$3=function(e){function t(r,n,o){var u=e.call(this,r)||this;return setProtoOf(u,t.prototype),u.name="GrammarError",u.location=n,void 0===o&&(o=[]),u.diagnostics=o,u.stage=null,u.problems=[["error",r,n,o]],u}return __extends(t,e),t.prototype.toString=function(){var t=e.prototype.toString.call(this);this.location&&(t+="\n at ",void 0!==this.location.source&&null!==this.location.source&&(t+="".concat(this.location.source,":")),t+="".concat(this.location.start.line,":").concat(this.location.start.column));for(var r=0,n=this.diagnostics;r<n.length;r++){var o=n[r];t+="\n from ",void 0!==o.location.source&&null!==o.location.source&&(t+="".concat(o.location.source,":")),t+="".concat(o.location.start.line,":").concat(o.location.start.column,": ").concat(o.message)}return t},t.prototype.format=function(e){var t=e.map((function(e){var t=e.source,r=e.text;return{source:t,text:null!=r?String(r).split(/\r\n|\n|\r/g):[]}}));function r(e,r,n){void 0===n&&(n="");var o="",u=t.find((function(t){return t.source===e.source})),a=e.start,i=GrammarLocation$3.offsetStart(e);if(u){var s=e.end,c=u.text[a.line-1],l=(a.line===s.line?s.column:c.length+1)-a.column||1;n&&(o+="\nnote: ".concat(n)),o+="\n --\x3e ".concat(e.source,":").concat(i.line,":").concat(i.column,"\n").concat("".padEnd(r)," |\n").concat(i.line.toString().padStart(r)," | ").concat(c,"\n").concat("".padEnd(r)," | ").concat("".padEnd(a.column-1)).concat("".padEnd(l,"^"))}else o+="\n at ".concat(e.source,":").concat(i.line,":").concat(i.column),n&&(o+=": ".concat(n));return o}function n(e,t,n,o){void 0===o&&(o=[]);var u=-1/0;u=n?o.reduce((function(e,t){var r=t.location;return Math.max(e,GrammarLocation$3.offsetStart(r).line)}),n.start.line):Math.max.apply(null,o.map((function(e){return e.location.start.line}))),u=u.toString().length;var a="".concat(e,": ").concat(t);n&&(a+=r(n,u));for(var i=0,s=o;i<s.length;i++){var c=s[i];a+=r(c.location,u,c.message)}return a}return this.problems.filter((function(e){return"info"!==e[0]})).map((function(e){return n.apply(void 0,e)})).join("\n\n")},t}(Error),grammarError=GrammarError$3,__spreadArray$4=commonjsGlobal&&commonjsGlobal.__spreadAr
|