数通智联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7 lines
15 KiB

2 years ago
/*!
* message-compiler v9.2.2
* (c) 2022 kazuya kawaguchi
* Released under the MIT License.
*/
const e=Object.assign,t=e=>"string"==typeof e,n={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,__EXTEND_POINT__:15},r={[n.EXPECTED_TOKEN]:"Expected token: '{0}'",[n.INVALID_TOKEN_IN_PLACEHOLDER]:"Invalid token in placeholder: '{0}'",[n.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]:"Unterminated single quote in placeholder",[n.UNKNOWN_ESCAPE_SEQUENCE]:"Unknown escape sequence: \\{0}",[n.INVALID_UNICODE_ESCAPE_SEQUENCE]:"Invalid unicode escape sequence: {0}",[n.UNBALANCED_CLOSING_BRACE]:"Unbalanced closing brace",[n.UNTERMINATED_CLOSING_BRACE]:"Unterminated closing brace",[n.EMPTY_PLACEHOLDER]:"Empty placeholder",[n.NOT_ALLOW_NEST_PLACEHOLDER]:"Not allowed nest placeholder",[n.INVALID_LINKED_FORMAT]:"Invalid linked format",[n.MUST_HAVE_MESSAGES_IN_PLURAL]:"Plural must have messages",[n.UNEXPECTED_EMPTY_LINKED_MODIFIER]:"Unexpected empty linked modifier",[n.UNEXPECTED_EMPTY_LINKED_KEY]:"Unexpected empty linked key",[n.UNEXPECTED_LEXICAL_ANALYSIS]:"Unexpected lexical analysis in token: '{0}'"};function c(e,t,n={}){const{domain:r,messages:c,args:o}=n,s=new SyntaxError(String(e));return s.code=e,t&&(s.location=t),s.domain=r,s}function o(e){throw e}const s={start:{line:1,column:1,offset:0},end:{line:1,column:1,offset:0}};function u(e,t,n){return{line:e,column:t,offset:n}}function a(e,t,n){const r={start:e,end:t};return null!=n&&(r.source=n),r}const i=String.fromCharCode(8232),l=String.fromCharCode(8233);function f(e){const t=e;let n=0,r=1,c=1,o=0;const s=e=>"\r"===t[e]&&"\n"===t[e+1],u=e=>t[e]===l,a=e=>t[e]===i,f=e=>s(e)||(e=>"\n"===t[e])(e)||u(e)||a(e),d=e=>s(e)||u(e)||a(e)?"\n":t[e];function p(){return o=0,f(n)&&(r++,c=0),s(n)&&n++,n++,c++,t[n]}return{index:()=>n,line:()=>r,column:()=>c,peekOffset:()=>o,charAt:d,currentChar:()=>d(n),currentPeek:()=>d(n+o),next:p,peek:function(){return s(n+o)&&o++,o++,t[n+o]},reset:function(){n=0,r=1,c=1,o=0},resetPeek:function(e=0){o=e},skipToPeek:function(){const e=n+o;for(;e!==n;)p();o=0}}}const d=void 0;function p(e,t={}){const n=!1!==t.location,r=f(e),c=()=>r.index(),o=()=>u(r.line(),r.column(),r.index()),s=o(),i=c(),l={currentType:14,offset:i,startLoc:s,endLoc:s,lastType:14,lastOffset:i,lastStartLoc:s,lastEndLoc:s,braceNest:0,inLinked:!1,text:""},p=()=>l,{onError:E}=t;function k(e,t,r){e.endLoc=o(),e.currentType=t;const c={type:t};return n&&(c.loc=a(e.startLoc,e.endLoc)),null!=r&&(c.value=r),c}const L=e=>k(e,14);function h(e,t){return e.currentChar()===t?(e.next(),t):(o(),"")}function N(e){let t="";for(;" "===e.currentPeek()||"\n"===e.currentPeek();)t+=e.currentPeek(),e.peek();return t}function _(e){const t=N(e);return e.skipToPeek(),t}function T(e){if(e===d)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function C(e,t){const{currentType:n}=t;if(2!==n)return!1;N(e);const r=function(e){if(e===d)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function P(e){N(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function x(e,t=!0){const n=(t=!1,r="",c=!1)=>{const o=e.currentPeek();return"{"===o?"%"!==r&&t:"@"!==o&&o?"%"===o?(e.peek(),n(t,"%",!0)):"|"===o?!("%"!==r&&!c)||!(" "===r||"\n"===r):" "===o?(e.peek(),n(!0," ",c)):"\n"!==o||(e.peek(),n(!0,"\n",c)):"%"===r||t},r=n();return t&&e.resetPeek(),r}function y(e,t){const n=e.currentChar();return n===d?d:t(n)?(e.next(),n):null}function m(e){return y(e,(e=>{const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t}))}function I(e){return y(e,(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57}))}function S(e){return y(e,(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}))}function O(e){let t="",n="";for(;t=I(e);)n+=t;return n}fu