nadesiko3
Version:
Japanese Programming Language
11 lines • 338 kB
JavaScript
"use strict";(()=>{var W={and:1,or:1,eq:2,noteq:2,"===":2,"!==":2,gt:2,gteq:2,lt:2,lteq:2,"&":3,"+":4,"-":4,shift_l:4,shift_r:4,shift_r0:4,"*":5,"/":5,"\xF7":5,"\xF7\xF7":5,"%":5,"^":6,"**":6},se=["\u3044\u3066","\u3048\u3066","\u304D\u3066","\u3051\u3066","\u3057\u3066","\u3063\u3066","\u306B\u3066","\u307F\u3066","\u3081\u3066","\u306D\u3066","\u306B\u306F","\u3093\u3067"],Me=[];for(let t in W)Me.push(t);function E(t="?",e="",n=-1,r=0,i="main.nako3"){return{type:t,value:e,indent:n,line:r,column:0,file:i,josi:""}}var Ee=class{constructor(e){this.logger=e,this.stackList=[],this.tokens=[],this.usedFuncs=new Set,this.stack=[],this.index=0,this.y=[],this.modName="inline",this.namespaceStack=[],this.modList=[],this.funclist=new Map,this.funcLevel=0,this.usedAsyncFn=!1,this.localvars=new Map([["\u305D\u308C",{type:"var",value:""}]]),this.genMode="sync",this.arrayIndexFrom=0,this.flagReverseArrayIndex=!1,this.flagCheckArrayInit=!1,this.recentlyCalledFunc=[],this.isReadingCalc=!1,this.isExportDefault=!0,this.isExportStack=[],this.moduleExport=new Map,this.init()}init(){this.funclist=new Map,this.moduleExport=new Map,this.reset()}reset(){this.tokens=[],this.index=0,this.stack=[],this.y=[],this.genMode="sync"}setFuncList(e){this.funclist=e}setModuleExport(e){this.moduleExport=e}popStack(e=void 0){if(!e){let n=this.stack.pop();return n||null}for(let n=this.stack.length-1;n>=0;n--){let r=this.stack[n];if(e.length===0||e.indexOf(r.josi)>=0)return this.stack.splice(n,1),this.logger.trace("POP :"+JSON.stringify(r)),r}return null}saveStack(){this.stackList.push(this.stack),this.stack=[]}loadStack(){this.stack=this.stackList.pop()}findVar(e){if(this.localvars.get(e))return{name:e,scope:"local",info:this.localvars.get(e)};if(e.indexOf("__")>=0)return this.funclist.get(e)?{name:e,scope:"global",info:this.funclist.get(e)}:void 0;let n=`${this.modName}__${e}`;if(this.funclist.get(n))return{name:n,scope:"global",info:this.funclist.get(n)};for(let r of this.modList){let i=`${r}__${e}`,o=this.moduleExport.get(r),s=this.funclist.get(i);if(s&&(s.isExport===!0||s.isExport!==!1&&o!==!1))return{name:i,scope:"global",info:this.funclist.get(i)}}if(this.funclist.get(e))return{name:e,scope:"system",info:this.funclist.get(e)}}pushStack(e){this.logger.trace("PUSH:"+JSON.stringify(e)),this.stack.push(e)}isEOF(){return this.index>=this.tokens.length}getIndex(){return this.index}check(e){return this.tokens[this.index].type===e}check2(e){for(let n=0;n<e.length;n++){let r=n+this.index;if(this.tokens.length<=r)return!1;if(e[n]==="*")continue;let i=this.tokens[r];if(e[n]instanceof Array){if(e[n].indexOf(i.type)<0)return!1;continue}if(i.type!==e[n])return!1}return!0}checkTypes(e){let n=this.tokens[this.index].type;return e.indexOf(n)>=0}accept(e){let n=[],r=this.index,i=()=>(this.index=r,!1);for(let o=0;o<e.length;o++){if(this.isEOF())return i();let s=e[o];if(s==null)return i();if(typeof s=="string"){let u=this.get();if(u&&u.type!==s)return i();n[o]=u;continue}if(typeof s=="function"){let c=s.bind(this)(n);if(c===null)return i();n[o]=c;continue}if(s instanceof Array){if(!this.checkTypes(s))return i();n[o]=this.get();continue}throw new Error("System Error : accept broken : "+typeof s)}return this.y=n,!0}get(){return this.isEOF()?null:this.tokens[this.index++]}getCur(){if(this.isEOF())throw new Error("\u30C8\u30FC\u30AF\u30F3\u304C\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3002");let e=this.tokens[this.index++];if(!e)throw new Error("\u30C8\u30FC\u30AF\u30F3\u304C\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3002");return e}unget(){this.index>0&&this.index--}peek(e=0){return this.isEOF()?null:this.tokens[this.index+e]}peekDef(e=null){return this.isEOF()?(e||(e=E()),e):this.tokens[this.index]}peekSourceMap(){let e=this.peek();return e===null?{startOffset:void 0,endOffset:void 0,file:void 0,line:0,column:0}:{startOffset:e.startOffset,endOffset:e.endOffset,file:e.file,line:e.line,column:e.column}}nodeToStr(e,n,r){let i=n.depth-1,o=u=>n.typeName!==void 0?n.typeName:u,s=r?" debug: "+JSON.stringify(e,null,2):"";if(!e)return"(NULL)";switch(e.type){case"not":if(i>=0){let u=e.value;return`${o("")}\u300E${this.nodeToStr(u,{depth:i},r)}\u306B\u6F14\u7B97\u5B50\u300Enot\u300F\u3092\u9069\u7528\u3057\u305F\u5F0F${s}\u300F`}else return`${o("\u6F14\u7B97\u5B50")}\u300Enot\u300F`;case"op":{let u=e,c=u.operator||"",a={eq:"\uFF1D",not:"!",gt:">",lt:"<",and:"\u304B\u3064",or:"\u307E\u305F\u306F"};if(c in a&&(c=a[c]),i>=0){let f=this.nodeToStr(u.left,{depth:i},r),l=this.nodeToStr(u.right,{depth:i},r);return u.operator==="eq"?`${o("")}\u300E${f}\u3068${l}\u304C\u7B49\u3057\u3044\u304B\u3069\u3046\u304B\u306E\u6BD4\u8F03${s}\u300F`:`${o("")}\u300E${f}\u3068${l}\u306B\u6F14\u7B97\u5B50\u300E${c}\u300F\u3092\u9069\u7528\u3057\u305F\u5F0F${s}\u300F`}else return`${o("\u6F14\u7B97\u5B50")}\u300E${c}${s}\u300F`}case"number":return`${o("\u6570\u5024")}${e.value}`;case"bigint":return`${o("\u5DE8\u5927\u6574\u6570")}${e.value}`;case"string":return`${o("\u6587\u5B57\u5217")}\u300E${e.value}${s}\u300F`;case"word":return`${o("\u5358\u8A9E")}\u300E${e.value}${s}\u300F`;case"func":return`${o("\u95A2\u6570")}\u300E${e.name||e.value}${s}\u300F`;case"eol":return"\u884C\u306E\u672B\u5C3E";case"eof":return"\u30D5\u30A1\u30A4\u30EB\u306E\u672B\u5C3E";default:{let u=e.name;return u&&(u=e.value),typeof u!="string"&&(u=e.type),`${o("")}\u300E${u}${s}\u300F`}}}};var I=class extends Error{constructor(e,n,r=void 0,i=void 0){let o=`${r||""}${i===void 0?"":`(${i+1}\u884C\u76EE): `}`;n=n.replace(/『main__(.+?)』/g,"\u300E$1\u300F"),super(`[${e}]${o}${n}`),this.name="NakoError",this.type="NakoError",this.tag="["+e+"]",this.positionJa=o,this.msg=n}},ue=class extends I{constructor(e,n,r){super("\u30A4\u30F3\u30C7\u30F3\u30C8\u30A8\u30E9\u30FC",e,r,n),this.type="NakoIndentError",this.line=n,this.file=r}},z=class extends I{constructor(e,n,r,i,o){super("\u5B57\u53E5\u89E3\u6790\u30A8\u30E9\u30FC\uFF08\u5185\u90E8\u30A8\u30E9\u30FC\uFF09",e,o,i),this.type="InternalLexerError",this.preprocessedCodeStartOffset=n,this.preprocessedCodeEndOffset=r,this.line=i,this.file=o}},ne=class extends I{constructor(e,n,r,i,o){super("\u5B57\u53E5\u89E3\u6790\u30A8\u30E9\u30FC",e,o,i),this.type="NakoLexerError",this.startOffset=n,this.endOffset=r,this.line=i,this.file=o}},_=class t extends I{static fromNode(e,n,r=void 0){if(!n)return new t(e,void 0,void 0,void 0,void 0);let i=typeof n.startOffset=="number"?n.startOffset:void 0,o=r&&typeof r.endOffset=="number"?r.endOffset:typeof n.endOffset=="number"?n.endOffset:void 0;return new t(e,n.line,i,o,n.file)}constructor(e,n,r,i,o){super("\u6587\u6CD5\u30A8\u30E9\u30FC",e,o,n),this.type="NakoSyntaxError",this.file=o,this.line=n,this.startOffset=r,this.endOffset=i}},re=class t extends I{constructor(e,n){let r="unknown";typeof e=="string"?r=e:e instanceof t||e instanceof I?r=e.msg:e instanceof Error&&(e.name==="Error"?r=e.message:r=`${e.name}: ${e.message}`);let i,o,s;n===void 0?(i=void 0,o=void 0):(s=/^l(-?\d+):(.*)$/.exec(n))?(i=parseInt(s[1]),o=s[2]):(s=/^l(-?\d+)$/.exec(n))?(i=parseInt(s[1]),o="main.nako3"):(i=0,o=n),super("\u5B9F\u884C\u6642\u30A8\u30E9\u30FC",r,o,i),this.type="NakoRuntimeError",this.lineNo=n,this.line=i,this.file=o}},B=class extends I{constructor(e,n,r){super("\u53D6\u308A\u8FBC\u307F\u30A8\u30E9\u30FC",e,n,r),this.file=n,this.line=r}};var An=new Map([["\u56DE","\u56DE"],["\u56DE\u7E70\u8FD4","\u56DE"],["\u9593","\u9593"],["\u9593\u7E70\u8FD4","\u9593"],["\u7E70\u8FD4","\u7E70\u8FD4"],["\u5897\u7E70\u8FD4","\u5897\u7E70\u8FD4"],["\u6E1B\u7E70\u8FD4","\u6E1B\u7E70\u8FD4"],["\u5F8C\u5224\u5B9A","\u5F8C\u5224\u5B9A"],["\u53CD\u5FA9","\u53CD\u5FA9"],["\u629C","\u629C\u3051\u308B"],["\u7D9A","\u7D9A\u3051\u308B"],["\u623B","\u623B\u308B"],["\u5148","\u5148\u306B"],["\u6B21","\u6B21\u306B"],["\u4EE3\u5165","\u4EE3\u5165"],["\u5B9F\u884C\u901F\u5EA6\u512A\u5148","\u5B9F\u884C\u901F\u5EA6\u512A\u5148"],["\u30D1\u30D5\u30A9\u30FC\u30DE\u30F3\u30B9\u30E2\u30CB\u30BF\u9069\u7528","\u30D1\u30D5\u30A9\u30FC\u30DE\u30F3\u30B9\u30E2\u30CB\u30BF\u9069\u7528"],["\u5B9A","\u5B9A\u3081\u308B"],["\u9010\u6B21\u5B9F\u884C","\u9010\u6B21\u5B9F\u884C"],["\u6761\u4EF6\u5206\u5C90","\u6761\u4EF6\u5206\u5C90"],["\u5897","\u5897"],["\u6E1B","\u6E1B"],["\u5909\u6570","\u5909\u6570"],["\u5B9A\u6570","\u5B9A\u6570"],["\u30A8\u30E9\u30FC\u76E3\u8996","\u30A8\u30E9\u30FC\u76E3\u8996"],["\u30A8\u30E9\u30FC","\u30A8\u30E9\u30FC"],["\u305D\u308C","word"],["\u305D\u3046","word"],["\u95A2\u6570","def_func"],["\u30A4\u30F3\u30C7\u30F3\u30C8\u69CB\u6587","\u30A4\u30F3\u30C7\u30F3\u30C8\u69CB\u6587"],["\u975E\u540C\u671F\u30E2\u30FC\u30C9","\u975E\u540C\u671F\u30E2\u30FC\u30C9"],["DNCL\u30E2\u30FC\u30C9","DNCL\u30E2\u30FC\u30C9"],["\u30E2\u30FC\u30C9\u8A2D\u5B9A","\u30E2\u30FC\u30C9\u8A2D\u5B9A"],["\u53D6\u8FBC","\u53D6\u8FBC"],["\u30E2\u30B8\u30E5\u30FC\u30EB\u516C\u958B\u65E2\u5B9A\u5024","\u30E2\u30B8\u30E5\u30FC\u30EB\u516C\u958B\u65E2\u5B9A\u5024"],["\u53B3\u30C1\u30A7\u30C3\u30AF","\u53B3\u30C1\u30A7\u30C3\u30AF"]]),Xe=An;function St(t){let e=t.charCodeAt(0);return t===" "?4:t===" "||t==="|"?1:t==="\u30FB"||t==="\u3000"||t==="\u23CB"||t==="\u23CC"||e>=9472&&e<=9599||e>=9120&&e<=9135||e>=9144&&e<=9151?2:0}var Ne=["\u306B\u3064\u3044\u3066","\u304F\u3089\u3044","\u306A\u306E\u304B","\u307E\u3067\u3092","\u307E\u3067\u306E","\u306B\u3088\u308B","\u3068\u306F","\u304B\u3089","\u307E\u3067","\u3060\u3051","\u3088\u308A","\u307B\u3069","\u306A\u3069","\u3044\u3066","\u3048\u3066","\u304D\u3066","\u3051\u3066","\u3057\u3066","\u3063\u3066","\u306B\u3066","\u307F\u3066","\u3081\u3066","\u306D\u3066","\u3067\u306F","\u306B\u306F","\u306F~","\u3093\u3067","\u305A\u3064","\u306F","\u3092","\u306B","\u3078","\u3067","\u3068","\u304C","\u306E"],Nn=["\u3067\u306A\u3051\u308C\u3070","\u306A\u3051\u308C\u3070","\u306A\u3089\u3070","\u306A\u3089","\u305F\u3089","\u308C\u3070"],Fn=["\u3053\u3068","\u3067\u3042\u308B","\u3067\u3059","\u3057\u307E\u3059","\u3067\u3057\u305F"],Ye={};Nn.forEach(t=>{Ne.push(t),Ye[t]=!0});var ce={};Fn.forEach(t=>{Ne.push(t),ce[t]=!0});var Ae=[];for(let t of Ne)Ae.push("\u3082\u306E"+t),Ae.push(t);Ae.sort((t,e)=>e.length-t.length);var Cn="^[\\t ]*("+Ae.join("|")+")",de=new RegExp(Cn),jt=Ne;var Tn=/^[\u3005\u4E00-\u9FCF_a-zA-Z0-9ァ-ヶー\u2460-\u24FF\u2776-\u277F\u3251-\u32BF]+/,Ot=/^[ぁ-ん]/,Ln=/^[ぁ-ん]+$/,Dn=/^.+(以上|以下|超|未満)$/,Vn=/^(かつ|または)/,xt=t=>function(){throw new Error("\u7A81\u7136\u306E\u300E"+t+"\u300F\u304C\u3042\u308A\u307E\u3059\u3002")},$t=/^(円|ドル|元|歩|㎡|坪|度|℃|°|個|つ|本|冊|才|歳|匹|枚|皿|セット|羽|人|件|行|列|機|品|m|mm|cm|km|g|kg|t|px|dot|pt|em|b|mb|kb|gb)/,Mt=[{name:"\u3053\u3053\u307E\u3067",pattern:/^;;;/},{name:"eol",pattern:/^\n/},{name:"eol",pattern:/^;/},{name:"space",pattern:/^(\x20|\x09|・|⎿ |└||)+/},{name:"comma",pattern:/^,/},{name:"line_comment",pattern:/^#[^\n]*/},{name:"line_comment",pattern:/^\/\/[^\n]*/},{name:"range_comment",pattern:/^\/\*/,cbParser:Pn},{name:"def_test",pattern:/^●テスト:/},{name:"def_func",pattern:/^●/},{name:"\u2026",pattern:/^…/},{name:"\u2026",pattern:/^\.{2,3}/},{name:"bigint",pattern:/^0[xX][0-9a-fA-F]+(_[0-9a-fA-F]+)*n/,readJosi:!0},{name:"bigint",pattern:/^0[oO][0-7]+(_[0-7]+)*n/,readJosi:!0},{name:"bigint",pattern:/^0[bB][0-1]+(_[0-1]+)*n/,readJosi:!0},{name:"bigint",pattern:/^\d+(_\d+)*?n/,readJosi:!0},{name:"number",pattern:/^0[xX][0-9a-fA-F]+(_[0-9a-fA-F]+)*/,readJosi:!0,cb:ae},{name:"number",pattern:/^0[oO][0-7]+(_[0-7]+)*/,readJosi:!0,cb:ae},{name:"number",pattern:/^0[bB][0-1]+(_[0-1]+)*/,readJosi:!0,cb:ae},{name:"number",pattern:/^\d+(_\d+)*\.(\d+(_\d+)*)?([eE][+|-]?\d+(_\d+)*)?/,readJosi:!0,cb:ae},{name:"number",pattern:/^\.\d+(_\d+)*([eE][+|-]?\d+(_\d+)*)?/,readJosi:!0,cb:ae},{name:"number",pattern:/^\d+(_\d+)*([eE][+|-]?\d+(_\d+)*)?/,readJosi:!0,cb:ae},{name:"\u3053\u3053\u304B\u3089",pattern:/^(ここから),?/},{name:"\u3053\u3053\u307E\u3067",pattern:/^(ここまで|💧)/},{name:"\u3082\u3057",pattern:/^もしも?/},{name:"\u9055\u3048\u3070",pattern:/^違(えば)?/},{name:"shift_r0",pattern:/^>>>/},{name:"shift_r",pattern:/^>>/},{name:"shift_l",pattern:/^<</},{name:"===",pattern:/^===/},{name:"!==",pattern:/^!==/},{name:"gteq",pattern:/^(≧|>=|=>)/},{name:"lteq",pattern:/^(≦|<=|=<)/},{name:"noteq",pattern:/^(≠|<>|!=)/},{name:"\u2190",pattern:/^(←|<--)/},{name:"eq",pattern:/^(==|🟰🟰)/},{name:"eq",pattern:/^(=|🟰)/},{name:"line_comment",pattern:/^(!|💡)(インデント構文|ここまでだるい|DNCLモード|DNCL2モード|DNCL2)[^\n]*/},{name:"not",pattern:/^(!|💡)/},{name:"gt",pattern:/^>/},{name:"lt",pattern:/^</},{name:"and",pattern:/^(かつ|&&|and\s)/},{name:"or",pattern:/^(または|或いは|あるいは|or\s|\|\|)/},{name:"@",pattern:/^@/},{name:"+",pattern:/^\+/},{name:"-",pattern:/^-/},{name:"**",pattern:/^(××|\*\*)/},{name:"*",pattern:/^(×|\*)/},{name:"\xF7\xF7",pattern:/^÷÷/},{name:"\xF7",pattern:/^(÷|\/)/},{name:"%",pattern:/^%/},{name:"^",pattern:/^\^/},{name:"&",pattern:/^&/},{name:"[",pattern:/^\[/},{name:"]",pattern:/^]/,readJosi:!0},{name:"(",pattern:/^\(/},{name:")",pattern:/^\)/,readJosi:!0},{name:"|",pattern:/^\|/},{name:"string",pattern:/^🌿/,cbParser:t=>ie("\u{1F33F}","\u{1F33F}",t)},{name:"string_ex",pattern:/^🌴/,cbParser:t=>ie("\u{1F334}","\u{1F334}",t)},{name:"string_ex",pattern:/^「/,cbParser:t=>ie("\u300C","\u300D",t)},{name:"string",pattern:/^『/,cbParser:t=>ie("\u300E","\u300F",t)},{name:"string_ex",pattern:/^“/,cbParser:t=>ie("\u201C","\u201D",t)},{name:"string_ex",pattern:/^"/,cbParser:t=>ie('"','"',t)},{name:"string",pattern:/^'/,cbParser:t=>ie("'","'",t)},{name:"\u300D",pattern:/^」/,cbParser:xt("\u300D")},{name:"\u300F",pattern:/^』/,cbParser:xt("\u300F")},{name:"func",pattern:/^\{関数\},?/},{name:"{",pattern:/^\{/},{name:"}",pattern:/^\}/,readJosi:!0},{name:":",pattern:/^:/},{name:"_eol",pattern:/^_\s*\n/},{name:"dec_lineno",pattern:/^‰/},{name:"word",pattern:/^[\uD800-\uDBFF][\uDC00-\uDFFF][_a-zA-Z0-9]*/,readJosi:!0},{name:"word",pattern:/^[\u1F60-\u1F6F][_a-zA-Z0-9]*/,readJosi:!0},{name:"word",pattern:/^《.+?》/,readJosi:!0},{name:"word",pattern:/^[_a-zA-Z\u3005\u4E00-\u9FCFぁ-んァ-ヶ\u2460-\u24FF\u2776-\u277F\u3251-\u32BF]/,cbParser:Rn}];function In(t){return Ot.test(t)?Ln.test(t)?t:t.replace(/[ぁ-ん]+$/g,""):t.replace(/[ぁ-ん]+/g,"")}function Pn(t){let e="",n="",r=0;t=t.substring(2);let i=t.indexOf("*/");i<0?(e=t,t=""):(e=t.substring(0,i),t=t.substring(i+2));for(let o=0;o<e.length;o++)e.charAt(o)===`
`&&r++;return e=e.replace(/(^\s+|\s+$)/,""),{src:t,res:e,josi:n,numEOL:r}}function Rn(t,e=!0){let n="",r="";for(;t!=="";){if(n.length>0){if(Vn.exec(t))break;let c=de.exec(t);if(c){r=c[0].replace(/^\s+/,""),t=t.substring(c[0].length),t.charAt(0)===","&&(t=t.substring(1));break}}let o=Tn.exec(t);if(o){n+=o[0],t=t.substring(o[0].length);continue}if(Ot.test(t)){n+=t.charAt(0),t=t.substring(1);continue}break}/[ぁ-ん]間$/.test(n)&&(t=n.charAt(n.length-1)+t,n=n.slice(0,-1));let i=Dn.exec(n);return i&&(t=i[1]+r+t,r="",n=n.substring(0,n.length-i[1].length)),r.substring(0,2)==="\u3082\u306E"&&(r=r.substring(2)),ce[r]&&(r=""),e&&(n=In(n)),n===""&&r!==""&&(n=r,r=""),{src:t,res:n,josi:r,numEOL:0}}function ie(t,e,n){let r="",i="",o=0;n=n.substring(t.length);let s=n.indexOf(e);if(s<0)r=n,n="";else if(r=n.substring(0,s),n=n.substring(s+e.length),r.indexOf(t)>=0)throw t==="\u300E"?new Error("\u300C\u300E\u300D\u3067\u59CB\u3081\u305F\u6587\u5B57\u5217\u306E\u4E2D\u306B\u300C\u300E\u300D\u3092\u542B\u3081\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002"):new Error(`\u300E${t}\u300F\u3067\u59CB\u3081\u305F\u6587\u5B57\u5217\u306E\u4E2D\u306B\u300E${t}\u300F\u3092\u542B\u3081\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002`);let u=de.exec(n);u&&(i=u[0].replace(/^\s+/,""),n=n.substring(u[0].length),n.charAt(0)===","&&(n=n.substring(1))),ce[i]&&(i=""),i.substring(0,2)==="\u3082\u306E"&&(i=i.substring(2));for(let c=0;c<r.length;c++)r.charAt(c)===`
`&&o++;return{src:n,res:r,josi:i,numEOL:o}}function ae(t){return Number(t.replace(/_/g,""))}var q=class t{constructor(e){this.logger=e,this.funclist=new Map,this.modList=[],this.result=[],this.modName="main.nako3",this.moduleExport=new Map,this.reservedWords=Array.from(Xe.keys()),this.josiList=jt}setFuncList(e){this.funclist=e}setModuleExport(e){this.moduleExport=e}replaceTokens(e,n,r){if(this.result=e,this.modName=t.filenameToModName(r),t.preDefineFunc(e,this.logger,this.funclist,this.moduleExport),this._replaceWord(this.result),n)if(this.result.length>0){let i=this.result[this.result.length-1];this.result.push({type:"eol",line:i.line,column:0,indent:-1,file:i.file,josi:"",value:"---",startOffset:i.startOffset,endOffset:i.endOffset,rawJosi:""}),this.result.push({type:"eof",line:i.line,indent:-1,column:0,file:i.file,josi:"",value:"",startOffset:i.startOffset,endOffset:i.endOffset,rawJosi:""})}else this.result.push({type:"eol",line:0,column:0,indent:-1,file:"",josi:"",value:"---",startOffset:0,endOffset:0,rawJosi:""}),this.result.push({type:"eof",line:0,column:0,indent:-1,file:"",josi:"",value:"",startOffset:0,endOffset:0,rawJosi:""});return this.result}static preDefineFunc(e,n,r,i){let o=0,s=!1,u=()=>{let c=[],a={};if(e[o].type!=="(")return[];for(o++;e[o];){let d=e[o];if(o++,d.type===")")break;d.type==="func"?s=!0:d.type!=="|"&&d.type!=="comma"&&(s&&(d.funcPointer=!0,s=!1),c.push(d),a[d.value]||(a[d.value]=[]),a[d.value].push(d.josi))}let f=[],l=[],p=[],h={};for(let d of c)if(!h[d.value]){let g=a[d.value];p.push(g),f.push(d.value),d.funcPointer?l.push(d.value):l.push(null),h[d.value]=!0}return[p,f,l]};for(;o<e.length;){let c=e[o];if(c.type==="not"&&e.length-o>3){let v={type:"eol"};if(o>=1&&(v=e[o-1]),v.type==="eol"){let k=e[o+1];if(k.type==="word"&&k.value==="\u30E2\u30B8\u30E5\u30FC\u30EB\u516C\u958B\u65E2\u5B9A\u5024"){if(k.type="\u30E2\u30B8\u30E5\u30FC\u30EB\u516C\u958B\u65E2\u5B9A\u5024",k=e[o+2],k.type==="string"&&k.value==="\u975E\u516C\u958B"){let $=t.filenameToModName(c.file);i.set($,!1),o+=3;continue}else if(k.type==="string"&&k.value==="\u516C\u958B"){let $=t.filenameToModName(c.file);i.set($,!0),o+=3;continue}}}}if(c.type==="word"&&c.josi==="\u306B\u306F"||c.type==="word"&&c.josi==="\u306F~"){c.josi="\u306B\u306F",e.splice(o+1,0,{type:"def_func",value:"\u95A2\u6570",indent:c.indent,line:c.line,column:c.column,file:c.file,josi:"",startOffset:c.endOffset,endOffset:c.endOffset,rawJosi:"",tag:"\u7121\u540D\u95A2\u6570"}),o++;continue}if(c.type==="word"&&c.value==="\u6C38\u9060"&&c.josi==="\u306B"){let v=e[o+1];v.value==="\u7E70\u8FD4"&&(v.value="\u9593",v.josi="\u306E"),o++;continue}if(c.type==="word"&&c.josi===""&&c.value.length>=2&&c.value.match(/回$/)){c.value=c.value.substring(0,c.value.length-1),c.endOffset||(c.endOffset=1);let v={type:"\u56DE",value:"\u56DE",indent:c.indent,line:c.line,column:c.column,file:c.file,josi:"",startOffset:c.endOffset-1,endOffset:c.endOffset,rawJosi:""};e.splice(o+1,0,v),c.endOffset--,o++}if(c.type==="word"){let v=Xe.get(c.value);v&&(c.type=v),c.value==="\u305D\u3046"&&(c.value="\u305D\u308C")}if(c.type!=="def_test"&&c.type!=="def_func"){o++;continue}let a=!0,f={type:"eol"};o>=1&&(f=e[o-1]),f.type==="eol"&&(a=!1);let l=c;o++;let p=[],h=[],d=[],g="",b=null,m=null;if(e[o]&&e[o].type==="{"){o++;let v=e[o]&&e[o].type==="word"?e[o].value:"";v==="\u516C\u958B"?m=!0:v==="\u975E\u516C\u958B"?m=!1:v==="\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8"?m=!0:n.warn(`\u4E0D\u660E\u306A\u95A2\u6570\u5C5E\u6027\u300E${v}\u300F\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059\u3002`),o++,e[o]&&e[o].type==="}"&&o++}if(e[o]&&e[o].type==="("&&([p,h,d]=u()),!a&&e[o]&&e[o].type==="word"&&(b=e[o++],g=b.value),p.length===0&&e[o]&&e[o].type==="("&&([p,h,d]=u()),g!==""&&b){if(g=t.filenameToModName(c.file)+"__"+g,r.has(g)){let k=g.replace(/^main__/,"");n.warn(`\u95A2\u6570\u300E${k}\u300F\u306F\u65E2\u306B\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059\u3002`,l)}b.value=g,r.set(g,{type:"func",josi:p,fn:null,asyncFn:!1,isExport:m,varnames:h,funcPointers:d})}let y={type:"func",josi:p,varnames:h,funcPointers:d};l.meta=y}}splitStringEx(e){let n=[],r=e.split(/[{{]/);n.push(r[0]);for(let i of r.slice(1)){let o=i.replace("\uFF5D","}").indexOf("}");if(o===-1)return null;n.push(i.slice(0,o),i.slice(o+1))}return n}_replaceWord(e){let n=[],r=0,i=!1,o=[],s=()=>r<=0?"eol":e[r-1].type,u=e.length>0?t.filenameToModName(e[0].file):"main";for(;r<e.length;){let c=e[r];if((c.type==="word"||c.type==="func")&&c.value==="\u540D\u524D\u7A7A\u9593\u8A2D\u5B9A"){if(i)throw new z("\u540D\u524D\u7A7A\u9593\u8A2D\u5B9A\u306E\u95A2\u6570\u53C2\u7167\u3092\u53D6\u5F97\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002",c.startOffset===void 0?0:c.startOffset,c.endOffset===void 0?0:c.endOffset,c.line,c.file);o.push(u),u=e[r-1].value}if((c.type==="word"||c.type==="func")&&c.value==="\u540D\u524D\u7A7A\u9593\u30DD\u30C3\u30D7"){if(i)throw new z("\u540D\u524D\u7A7A\u9593\u30DD\u30C3\u30D7\u306E\u95A2\u6570\u53C2\u7167\u3092\u53D6\u5F97\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002",c.startOffset===void 0?0:c.startOffset,c.endOffset===void 0?0:c.endOffset,c.line,c.file);let a=o.pop();a&&(u=a)}if(c.type==="word"&&c.value!=="\u305D\u308C"){let a=c.value;if(a.indexOf("__")<0){let l=`${u}__${a}`,p=this.funclist.get(l);if(p&&p.type==="func"){c.type=i?"func_pointer":"func",c.meta=p,c.value=l,i&&(i=!1,e.splice(r-1,1));continue}for(let h of this.modList){let d=`${h}__${a}`,g=this.funclist.get(d),b=this.moduleExport.get(h);if(g&&g.type==="func"&&(g.isExport===!0||g.isExport!==!1&&b!==!1)){c.type=i?"func_pointer":"func",c.meta=g,c.value=d,i&&(i=!1,e.splice(r-1,1));break}}if(c.type==="func"||c.type==="func_pointer")continue}let f=this.funclist.get(a);if(f&&f.type==="func"&&(c.type=i?"func_pointer":"func",c.meta=f,i)){i=!1,e.splice(r-1,1);continue}}if(i=!1,c.type==="func"&&c.value==="{\u95A2\u6570}"){r++,i=!0;continue}if(c.type==="-"&&e[r+1]){let a=e[r+1].type;if(a==="number"||a==="bigint"){let f=s();(f==="eol"||W[f]||e[r-1].josi!=="")&&(e.splice(r,1),a==="number"?e[r].value*=-1:e[r].value="-"+e[r].value)}}if(c.josi===void 0&&(c.josi=""),c.josi==="\u306F"){c.rawJosi||(c.rawJosi=c.josi);let a=c.endOffset===void 0?void 0:c.endOffset-c.rawJosi.length;e.splice(r+1,0,{type:"eq",indent:c.indent,line:c.line,column:c.column,file:c.file,startOffset:a,endOffset:c.endOffset,josi:"",rawJosi:"",value:void 0}),r+=2,c.josi=c.rawJosi="",c.endOffset=a;continue}if(c.josi==="\u3068\u306F"){c.rawJosi||(c.rawJosi=c.josi);let a=c.endOffset===void 0?void 0:c.endOffset-c.rawJosi.length;e.splice(r+1,0,{type:c.josi,indent:c.indent,line:c.line,column:c.column,file:c.file,startOffset:a,endOffset:c.endOffset,josi:"",rawJosi:"",value:void 0}),c.josi=c.rawJosi="",c.endOffset=a,r+=2;continue}if(Ye[c.josi]){let a=c.josi==="\u3067\u306A\u3051\u308C\u3070"||c.josi==="\u306A\u3051\u308C\u3070"?"\u3067\u306A\u3051\u308C\u3070":"\u306A\u3089\u3070";c.rawJosi||(c.rawJosi=a);let f=c.endOffset===void 0?void 0:c.endOffset-c.rawJosi.length;e.splice(r+1,0,{type:"\u306A\u3089\u3070",value:a,indent:c.indent,line:c.line,column:c.column,file:c.file,startOffset:f,endOffset:c.endOffset,josi:"",rawJosi:""}),c.josi=c.rawJosi="",c.endOffset=f,r+=2;continue}if(c.type==="_eol"){e.splice(r,1);continue}if(c.type==="line_comment"||c.type==="range_comment"){n.push(c.value),e.splice(r,1);continue}c.type==="eol"&&(c.value=n.join("/"),n=[]),r++}}countIndent(e){let n=0;for(let r=0;r<e.length;r++){let i=e.charAt(r),o=St(i);if(o===0)return[n,r];n+=o}return[n,e.length]}tokenize(e,n,r){let i=e.length,o=[],s,u,c=1,a=!1,f=0,l=this.countIndent(e);for(f=l[0],e=e.substring(l[1]),c+=l[1];e!=="";){let p=!1;for(let h of Mt){let d=h.pattern.exec(e);if(!d)continue;if(p=!0,h.name==="space"){c+=d[0].length,e=e.substring(d[0].length);continue}if(h.cbParser){let y;if(a&&h.name==="word")y=h.cbParser(e,!1);else try{y=h.cbParser(e)}catch(v){throw new ne(v.message,i-e.length,i-e.length+1,n,r)}if(h.name==="string_ex"){let v=this.splitStringEx(y.res);if(v===null)throw new z("\u5C55\u958B\u3042\u308A\u6587\u5B57\u5217\u3067\u5024\u306E\u57CB\u3081\u8FBC\u307F{...}\u304C\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\u3002",i-e.length,i-y.src.length,n,r);let k=0;for(let $=0;$<v.length;$++){let V=$===v.length-1?y.josi:"";$%2===0?(o.push({type:"string",value:v[$],file:r,josi:V,indent:f,line:n,column:c,preprocessedCodeOffset:i-e.length+k,preprocessedCodeLength:v[$].length+2+V.length}),k+=v[$].length+2):(o.push({type:"&",value:"&",josi:"",indent:f,file:r,line:n,column:c,preprocessedCodeOffset:i-e.length+k,preprocessedCodeLength:0}),o.push({type:"(",value:"(",josi:"",indent:f,file:r,line:n,column:c,preprocessedCodeOffset:i-e.length+k,preprocessedCodeLength:0}),o.push({type:"code",value:v[$],josi:"",indent:f,file:r,line:n,column:c,preprocessedCodeOffset:i-e.length+k,preprocessedCodeLength:v[$].length}),o.push({type:")",value:")",josi:"",indent:f,file:r,line:n,column:c,preprocessedCodeOffset:i-e.length+k+v[$].length,preprocessedCodeLength:0}),o.push({type:"&",value:"&",josi:"",indent:f,file:r,line:n,column:c,preprocessedCodeOffset:i-e.length+k+v[$].length,preprocessedCodeLength:0}),k+=v[$].length)}n+=y.numEOL,c+=e.length-y.src.length,e=y.src,y.numEOL>0&&(c=1);break}s=c,c+=e.length-y.src.length,o.push({type:h.name,value:y.res,josi:y.josi,indent:f,line:n,column:s,file:r,preprocessedCodeOffset:i-e.length,preprocessedCodeLength:e.length-y.src.length}),e=y.src,n+=y.numEOL,y.numEOL>0&&(c=1);break}let g=i-e.length,b=d[0];if(h.cb&&(b=h.cb(b)),s=c,u=n,c+=d[0].length,e=e.substring(d[0].length),(h.name==="eol"&&b===`
`||h.name==="_eol")&&(b=n++,c=1),h.name==="number"){let y=$t.exec(e);y&&(e=e.substring(y[0].length),c+=d[0].length)}let m="";if(h.readJosi){let y=de.exec(e);y&&(c+=y[0].length,m=y[0].replace(/^\s+/,""),e=e.substring(y[0].length),e.charAt(0)===","&&(e=e.substring(1)),ce[m]&&(m=""),m.substring(0,2)==="\u3082\u306E"&&(m=m.substring(2)))}switch(h.name){case"def_test":{a=!0;break}case"eol":{a=!1;break}default:break}if(h.name==="dec_lineno"){n--;continue}if(o.push({type:h.name,value:b,indent:f,line:u,column:s,file:r,josi:m,preprocessedCodeOffset:g,preprocessedCodeLength:i-e.length-g}),h.name==="eol"&&c===1){let y=this.countIndent(e);f=y[0],c+=y[1],e=e.substring(y[1])}break}if(!p)throw new z("\u672A\u77E5\u306E\u8A9E\u53E5: "+e.substring(0,3)+"...",i-e.length,i-i+3,n,r)}return o}static tokensToTypeStr(e,n){return e.map(i=>i.type).join(n)}static filenameToModName(e){if(!e)return"main";if(e=e.replace(/[\\:]/g,"/"),e.indexOf("/")>=0){let n=e.split("/");e=n[n.length-1]}return e=e.replace(/\.nako3?$/,""),e}};var Fe=class extends Ee{parse(e,n){return this.reset(),this.tokens=e,this.modName=q.filenameToModName(n),this.modList.push(this.modName),this.startParser()}startParser(){let e=this.ySentenceList(),n=this.get();if(n&&n.type!=="eof")throw this.logger.debug(`\u69CB\u6587\u89E3\u6790\u3067\u30A8\u30E9\u30FC\u3002${this.nodeToStr(n,{depth:1},!0)}\u306E\u4F7F\u3044\u65B9\u304C\u9593\u9055\u3063\u3066\u3044\u307E\u3059\u3002`,n),_.fromNode(`\u69CB\u6587\u89E3\u6790\u3067\u30A8\u30E9\u30FC\u3002${this.nodeToStr(n,{depth:1},!1)}\u306E\u4F7F\u3044\u65B9\u304C\u9593\u9055\u3063\u3066\u3044\u307E\u3059\u3002`,n);return e}ySentenceList(){let e=[],n=-1,r=this.peekSourceMap();for(;!this.isEOF();){let i=this.ySentence();if(!i)break;e.push(i),n<0&&(n=i.line)}if(e.length===0){let i=this.peek()||this.tokens[0];throw this.logger.debug("\u69CB\u6587\u89E3\u6790\u306B\u5931\u6557:"+this.nodeToStr(this.peek(),{depth:1},!0),i),_.fromNode("\u69CB\u6587\u89E3\u6790\u306B\u5931\u6557:"+this.nodeToStr(this.peek(),{depth:1},!1),i)}return{type:"block",block:e,...r,end:this.peekSourceMap(),genMode:this.genMode}}makeStackBalanceReport(){let e=[];this.stack.forEach(o=>{let s=this.nodeToStr(o,{depth:1},!1);o.josi&&(s+=o.josi),e.push(s)});let n=e.join(","),r="",i=65;for(let o of this.recentlyCalledFunc){r+=" - ";let s=0,u=o.josi;if(u)for(let c of u){let a=String.fromCharCode(i+s);r+=a,c.length===1?r+=c[0]:r+=`(${c.join("|")})`,s++}r+=o.name+`
`}return this.recentlyCalledFunc=[],`\u672A\u89E3\u6C7A\u306E\u5358\u8A9E\u304C\u3042\u308A\u307E\u3059: [${n}]
\u6B21\u306E\u547D\u4EE4\u306E\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059:
${r}`}yEOL(){let e=this.get();if(!e)return null;if(this.stack.length>0){let n=this.makeStackBalanceReport();throw _.fromNode(n,e)}return this.recentlyCalledFunc=[],e}ySentence(){let e=this.peekSourceMap();if(this.check("eol"))return this.yEOL();if(this.check("\u3082\u3057"))return this.yIF();if(this.check("\u5F8C\u5224\u5B9A"))return this.yAtohantei();if(this.check("\u30A8\u30E9\u30FC\u76E3\u8996"))return this.yTryExcept();if(this.accept(["\u629C\u3051\u308B"]))return{type:"break",josi:"",...e,end:this.peekSourceMap()};if(this.accept(["\u7D9A\u3051\u308B"]))return{type:"continue",josi:"",...e,end:this.peekSourceMap()};if(this.accept(["DNCL\u30E2\u30FC\u30C9"]))return this.yDNCLMode(1);if(this.accept(["DNCL2\u30E2\u30FC\u30C9"]))return this.yDNCLMode(2);if(this.accept(["not","string","\u30E2\u30FC\u30C9\u8A2D\u5B9A"]))return this.ySetGenMode(this.y[1].value);if(this.accept(["not","\u30E2\u30B8\u30E5\u30FC\u30EB\u516C\u958B\u65E2\u5B9A\u5024","eq","string"]))return this.yExportDefault(this.y[3].value);if(this.accept(["not","\u53B3\u30C1\u30A7\u30C3\u30AF"]))return this.ySetMode("\u53B3\u3057\u304F\u30C1\u30A7\u30C3\u30AF");if(this.check("\u9010\u6B21\u5B9F\u884C"))return this.yTikuji();if(this.accept(["not","\u975E\u540C\u671F\u30E2\u30FC\u30C9"]))return this.yASyncMode();if(this.check2(["func","eq"])){let n=this.get()||E();throw _.fromNode(`\u95A2\u6570\u300E${n.value}\u300F\u306B\u4EE3\u5165\u3067\u304D\u307E\u305B\u3093\u3002`,n)}if(this.accept([this.ySpeedMode]))return this.y[0];if(this.accept([this.yPerformanceMonitor]))return this.y[0];if(this.accept([this.yLet]))return this.y[0];if(this.accept([this.yDefTest]))return this.y[0];if(this.accept([this.yDefFunc]))return this.y[0];if(this.accept([this.yCall])){let n=this.y[0],r=this.peek();if(r&&r.type==="\u306A\u3089\u3070"){let i=this.peekSourceMap(),o=n;return this.get(),this.yIfThen(i,o)}else if(se.indexOf(n.josi||"")>=0){if(this.stack.length>=1){let o=this.makeStackBalanceReport();throw _.fromNode(o,n)}let i=this.ySentence();if(i!==null)return{type:"block",block:[n,i],josi:i.josi,...e,end:this.peekSourceMap()}}return n}return null}yASyncMode(){return this.logger.error("\u300E\u975E\u540C\u671F\u30E2\u30FC\u30C9\u300F\u69CB\u6587\u306F\u5EC3\u6B62\u3055\u308C\u307E\u3057\u305F(https://nadesi.com/v3/doc/go.php?1028)\u3002",this.peek()),{type:"eol",...this.peekSourceMap(),end:this.peekSourceMap()}}yDNCLMode(e){let n=this.peekSourceMap();return e===1&&(this.arrayIndexFrom=1,this.flagReverseArrayIndex=!0),this.flagCheckArrayInit=!0,{type:"eol",...n,end:this.peekSourceMap()}}ySetGenMode(e){let n=this.peekSourceMap();return this.genMode=e,{type:"eol",...n,end:this.peekSourceMap()}}yExportDefault(e){let n=this.peekSourceMap();return this.isExportDefault=e==="\u516C\u958B",this.moduleExport.set(this.modName,this.isExportDefault),{type:"eol",...n,end:this.peekSourceMap()}}ySetMode(e){let n=this.peekSourceMap();return{type:"run_mode",value:e,...n,end:this.peekSourceMap()}}yBlock(){let e=this.peekSourceMap(),n=[];for(this.check("\u3053\u3053\u304B\u3089")&&this.get();!this.isEOF()&&!(this.checkTypes(["\u9055\u3048\u3070","\u3053\u3053\u307E\u3067","\u30A8\u30E9\u30FC"])||!this.accept([this.ySentence]));)n.push(this.y[0]);return{type:"block",block:n,...e,end:this.peekSourceMap()}}yDefFuncReadArgs(){if(!this.check("("))return null;let e=[];for(this.get();!this.isEOF();){if(this.check(")")){this.get();break}let n=this.get();n&&e.push(n),this.check("comma")&&this.get()}return e}yDefTest(){return this.yDef("def_test")}yDefFunc(){return this.yDef("def_func")}yDef(e){if(!this.check(e))return null;let n=this.peekSourceMap(),r=this.get();if(!r)return null;let i=this.isExportDefault;if(this.check("{")){this.get();let f=this.get();if(this.check("}"))this.get();else throw _.fromNode("\u95A2\u6570\u306E\u5C5E\u6027\u306E\u6307\u5B9A\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002\u300E{\u300F\u3068\u300E}\u300F\u3067\u56F2\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002",r);f!=null&&(f.value==="\u516C\u958B"&&(i=!0),f.value==="\u975E\u516C\u958B"&&(i=!1),f.value==="\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8"&&(i=!0))}let o=[];this.check("(")&&(o=this.yDefFuncReadArgs()||[]);let s=this.get();if(!s||s.type!=="func")throw this.logger.debug(this.nodeToStr(s,{depth:0,typeName:"\u95A2\u6570"},!0)+"\u306E\u5BA3\u8A00\u3067\u30A8\u30E9\u30FC\u3002",s),_.fromNode(this.nodeToStr(s,{depth:0,typeName:"\u95A2\u6570"},!1)+"\u306E\u5BA3\u8A00\u3067\u30A8\u30E9\u30FC\u3002",r);if(this.check("(")){if(o.length>0)throw this.logger.debug(this.nodeToStr(s,{depth:0,typeName:"\u95A2\u6570"},!0)+"\u306E\u5BA3\u8A00\u3067\u3001\u5F15\u6570\u5B9A\u7FA9\u306F\u540D\u524D\u306E\u524D\u304B\u5F8C\u306B\u4E00\u5EA6\u3060\u3051\u53EF\u80FD\u3067\u3059\u3002",s),_.fromNode(this.nodeToStr(s,{depth:0,typeName:"\u95A2\u6570"},!1)+"\u306E\u5BA3\u8A00\u3067\u3001\u5F15\u6570\u5B9A\u7FA9\u306F\u540D\u524D\u306E\u524D\u304B\u5F8C\u306B\u4E00\u5EA6\u3060\u3051\u53EF\u80FD\u3067\u3059\u3002",s);o=this.yDefFuncReadArgs()||[]}this.check("\u3068\u306F")&&this.get();let u=null,c=!1,a=!1;this.check("\u3053\u3053\u304B\u3089")&&(c=!0),this.check("eol")&&(c=!0);try{this.funcLevel++,this.usedAsyncFn=!1;let f=this.localvars;if(this.localvars=new Map([["\u305D\u308C",{type:"var",value:""}]]),c){this.saveStack();for(let l of o){let p=l.value?l.value+"":"";this.localvars.set(p,{type:"var",value:""})}if(u=this.yBlock(),this.check("\u3053\u3053\u307E\u3067"))this.get();else throw _.fromNode("\u300E\u3053\u3053\u307E\u3067\u300F\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u95A2\u6570\u5B9A\u7FA9\u306E\u672B\u5C3E\u306B\u5FC5\u8981\u3067\u3059\u3002",r);this.loadStack()}else this.saveStack(),u=this.ySentence(),this.loadStack();this.funcLevel--,a=this.usedAsyncFn,this.localvars=f}catch(f){throw this.logger.debug(this.nodeToStr(s,{depth:0,typeName:"\u95A2\u6570"},!0)+`\u306E\u5B9A\u7FA9\u3067\u4EE5\u4E0B\u306E\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3057\u305F\u3002
`+f.message,r),_.fromNode(this.nodeToStr(s,{depth:0,typeName:"\u95A2\u6570"},!1)+`\u306E\u5B9A\u7FA9\u3067\u4EE5\u4E0B\u306E\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3057\u305F\u3002
`+f.message,r)}return{type:e,name:s,args:o,block:u||[],asyncFn:a,isExport:i,josi:"",...n,end:this.peekSourceMap()}}yIFCond(){let e=this.peekSourceMap(),n=this.yGetArg();if(!n)return null;if(n.josi==="\u306A\u3089\u3070")return n;if(n.josi==="\u3067\u306A\u3051\u308C\u3070")return n={type:"not",value:n,josi:"",...e,end:this.peekSourceMap()},n;if(n.josi!==""&&this.check("func"))this.stack.push(n),n=this.yCall();else if(n.josi==="\u304C"){let i=this.index,o=this.yGetArg();if(!o)throw _.fromNode("\u3082\u3057\u6587\u306E\u6761\u4EF6\u300CA\u304CB\u306A\u3089\u3070\u300D\u3067B\u304C\u306A\u3044\u304B\u6761\u4EF6\u304C\u8907\u96D1\u904E\u304E\u307E\u3059\u3002"+this.nodeToStr(this.peek(),{depth:1},!1),e);if(this.check("\u306A\u3089\u3070")){let s=this.get()||{value:"\u306A\u3089\u3070"};o.josi=s.value}if(o&&(o.josi==="\u306A\u3089\u3070"||o.josi==="\u3067\u306A\u3051\u308C\u3070"))return{type:"op",operator:o.josi==="\u3067\u306A\u3051\u308C\u3070"?"noteq":"eq",left:n,right:o,josi:"",...e,end:this.peekSourceMap()};this.index=i}if(this.check("\u306A\u3089\u3070")||(this.stack.push(n),n=this.yCall()),!this.check("\u306A\u3089\u3070")){let i=n||{type:"?",...e};throw this.logger.debug("\u3082\u3057\u6587\u3067\u300E\u306A\u3089\u3070\u300F\u304C\u306A\u3044\u304B\u3001\u6761\u4EF6\u304C\u8907\u96D1\u904E\u304E\u307E\u3059\u3002"+this.nodeToStr(this.peek(),{depth:1},!1)+"\u306E\u76F4\u524D\u306B\u300E\u306A\u3089\u3070\u300F\u3092\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\u3002",i),_.fromNode("\u3082\u3057\u6587\u3067\u300E\u306A\u3089\u3070\u300F\u304C\u306A\u3044\u304B\u3001\u6761\u4EF6\u304C\u8907\u96D1\u904E\u304E\u307E\u3059\u3002"+this.nodeToStr(this.peek(),{depth:1},!1)+"\u306E\u76F4\u524D\u306B\u300E\u306A\u3089\u3070\u300F\u3092\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\u3002",i)}let r=this.get();return r&&r.value==="\u3067\u306A\u3051\u308C\u3070"&&(n={type:"not",value:n,josi:"",...e,end:this.peekSourceMap()}),n}yIF(){let e=this.peekSourceMap();if(!this.check("\u3082\u3057"))return null;let n=this.get();if(n==null)return null;for(;this.check("comma");)this.get();let r=null;try{r=this.yIFCond()}catch(i){throw _.fromNode(`\u300E\u3082\u3057\u300F\u6587\u306E\u6761\u4EF6\u3067\u6B21\u306E\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059\u3002
`+i.message,n)}if(r===null)throw _.fromNode("\u300E\u3082\u3057\u300F\u6587\u3067\u6761\u4EF6\u306E\u6307\u5B9A\u304C\u7A7A\u3067\u3059\u3002",n);return this.yIfThen(e,r)}yIfThen(e,n){let r=null,i=null,o=!1;for(this.check("eol")?r=this.yBlock():(r=this.ySentence(),o=!0);this.check("eol");)this.get();if(this.check("\u9055\u3048\u3070")){for(this.get();this.check("comma");)this.get();this.check("eol")?i=this.yBlock():(i=this.ySentence(),o=!0)}if(o===!1)if(this.check("\u3053\u3053\u307E\u3067"))this.get();else throw _.fromNode("\u300E\u3082\u3057\u300F\u6587\u3067\u300E\u3053\u3053\u307E\u3067\u300F\u304C\u3042\u308A\u307E\u305B\u3093\u3002",e);return{type:"if",expr:n||[],block:r||[],false_block:i||[],josi:"",...e,end:this.peekSourceMap()}}ySpeedMode(){let e=this.peekSourceMap();if(!this.check2(["string","\u5B9F\u884C\u901F\u5EA6\u512A\u5148"]))return null;let n=this.get();this.get();let r="";if(n&&n.value)r=n.value;else return null;let i={\u884C\u756A\u53F7\u7121\u3057:!1,\u6697\u9ED9\u306E\u578B\u5909\u63DB\u7121\u3057:!1,\u5F37\u5236\u30D4\u30E5\u30A2:!1,\u305D\u308C\u7121\u52B9:!1};for(let u of r.split("/")){if(u==="\u5168\u3066"){for(let c of Object.keys(i))i[c]=!0;break}Object.keys(i).includes(u)?i[u]=!0:this.logger.warn(`\u5B9F\u884C\u901F\u5EA6\u512A\u5148\u6587\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u300E${u}\u300F\u306F\u5B58\u5728\u3057\u307E\u305B\u3093\u3002`,n)}let o=!1;this.check("\u3053\u3053\u304B\u3089")?(this.get(),o=!0):this.check("eol")&&(o=!0);let s=null;return o?(s=this.yBlock(),this.check("\u3053\u3053\u307E\u3067")&&this.get()):s=this.ySentence(),{type:"speed_mode",options:i,block:s||[],josi:"",...e}}yPerformanceMonitor(){let e=this.peekSourceMap();if(!this.check2(["string","\u30D1\u30D5\u30A9\u30FC\u30DE\u30F3\u30B9\u30E2\u30CB\u30BF\u9069\u7528"]))return null;let n=this.get();if(!n)return null;this.get();let r={\u30E6\u30FC\u30B6\u95A2\u6570:!1,\u30B7\u30B9\u30C6\u30E0\u95A2\u6570\u672C\u4F53:!1,\u30B7\u30B9\u30C6\u30E0\u95A2\u6570:!1};for(let s of n.value.split("/")){if(s==="\u5168\u3066"){for(let u of Object.keys(r))r[u]=!0;break}Object.keys(r).includes(s)?r[s]=!0:this.logger.warn(`\u30D1\u30D5\u30A9\u30FC\u30DE\u30F3\u30B9\u30E2\u30CB\u30BF\u9069\u7528\u6587\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u300E${s}\u300F\u306F\u5B58\u5728\u3057\u307E\u305B\u3093\u3002`,n)}let i=!1;this.check("\u3053\u3053\u304B\u3089")?(this.get(),i=!0):this.check("eol")&&(i=!0);let o=null;return i?(o=this.yBlock(),this.check("\u3053\u3053\u307E\u3067")&&this.get()):o=this.ySentence(),{type:"performance_monitor",options:r,block:o||[],josi:"",...e}}yTikuji(){if(!this.check("\u9010\u6B21\u5B9F\u884C"))return null;let e=this.getCur();return this.logger.error("\u300E\u9010\u6B21\u5B9F\u884C\u300F\u69CB\u6587\u306F\u5EC3\u6B62\u3055\u308C\u307E\u3057\u305F(https://nadesi.com/v3/doc/go.php?944)\u3002",e),{type:"eol",...this.peekSourceMap(),end:this.peekSourceMap()}}yGetArgOperator(e){let n=[e];for(;!this.isEOF();){let r=this.peek();if(r&&W[r.type]){r=this.getCur(),n.push(r);let i=this.yValue();if(i===null)throw _.fromNode(`\u8A08\u7B97\u5F0F\u3067\u6F14\u7B97\u5B50\u300E${r.value}\u300F\u5F8C\u306B\u5024\u304C\u3042\u308A\u307E\u305B\u3093`,e);n.push(i);continue}break}return n.length===0?null:n.length===1?n[0]:this.infixToAST(n)}yRange(e){if(!this.check("\u2026"))return null;let n=this.peekSourceMap();this.get();let r=this.yValue();if(!e||!r)throw _.fromNode("\u7BC4\u56F2\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306E\u6307\u5B9A\u30A8\u30E9\u30FC\u3002\u300EA\u2026B\u300F\u306E\u66F8\u5F0F\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002",n);return{type:"func",name:"\u7BC4\u56F2",args:[e,r],josi:r.josi,...n,end:this.peekSourceMap()}}yGetArg(){let e=this.yValue();return e===null?null:this.check("\u2026")?this.yRange(e):this.yGetArgOperator(e)}infixToPolish(e){let n=o=>W[o.type]?W[o.type]:10,r=[],i=[];for(;e.length>0;){let o=e.shift();if(!o)break;for(;r.length>0;){let s=r[r.length-1];if(n(o)>n(s))break;let u=r.pop();if(!u){this.logger.error("\u8A08\u7B97\u5F0F\u306B\u9593\u9055\u3044\u304C\u3042\u308A\u307E\u3059\u3002",o);break}i.push(u)}r.push(o)}for(;r.length>0;){let o=r.pop();o&&i.push(o)}return i}infixToAST(e){if(e.length===0)return null;let n=e[e.length-1].josi,r=e[e.length-1],i=this.infixToPolish(e),o=[];for(let u of i){if(!W[u.type]){o.push(u);continue}let c=o.pop(),a=o.pop();if(a===void 0||c===void 0)throw this.logger.debug(`--- \u8A08\u7B97\u5F0F(\u9006\u30DD\u30FC\u30E9\u30F3\u30C9) ---
`+JSON.stringify(i)),_.fromNode("\u8A08\u7B97\u5F0F\u3067\u30A8\u30E9\u30FC",r);let f={type:"op",operator:u.type,left:a,right:c,josi:n,startOffset:a.startOffset,endOffset:a.endOffset,line:a.line,column:a.column,file:a.file};o.push(f)}let s=o.pop();return s||null}yGetArgParen(e){let n=!1,r=this.stack.length;for(;!this.isEOF();){if(this.check(")")){n=!0;break}let o=this.yGetArg();if(o){this.pushStack(o),this.check("comma")&&this.get();continue}break}if(!n)throw _.fromNode(`C\u98A8\u95A2\u6570\u300E${e[0].value}\u300F\u3067\u30AB\u30C3\u30B3\u304C\u9589\u3058\u3066\u3044\u307E\u305B\u3093`,e[0]);let i=[];for(;r<this.stack.length;){let o=this.popStack();o&&i.unshift(o)}return i}yRepeatTime(){let e=this.peekSourceMap();if(!this.check("\u56DE"))return null;this.get(),this.check("comma")&&this.get(),this.check("\u7E70\u8FD4")&&this.get();let n=this.popStack([]),r=!1,i=null;if(n===null&&(n={type:"word",value:"\u305D\u308C",josi:"",...e,end:this.peekSourceMap()}),this.check("comma")&&this.get(),this.check("\u3053\u3053\u304B\u3089")?(this.get(),r=!0):this.check("eol")&&(r=!0),r)if(i=this.yBlock(),this.check("\u3053\u3053\u307E\u3067"))this.get();else throw _.fromNode("\u300E\u3053\u3053\u307E\u3067\u300F\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u300E\u56DE\u300F...\u300E\u3053\u3053\u307E\u3067\u300F\u3092\u5BFE\u5FDC\u3055\u305B\u3066\u304F\u3060\u3055\u3044\u3002",e);else i=this.ySentence();return{type:"repeat_times",value:n,block:i||[],josi:"",...e,end:this.peekSourceMap()}}yWhile(){let e=this.peekSourceMap();if(!this.check("\u9593"))return null;for(this.get();this.check("comma");)this.get();this.check("\u7E70\u8FD4")&&this.get();let n=this.popStack();if(n===null)throw _.fromNode("\u300E\u9593\u300F\u3067\u6761\u4EF6\u304C\u3042\u308A\u307E\u305B\u3093\u3002",e);if(this.check("comma")&&this.get(),!this.checkTypes(["\u3053\u3053\u304B\u3089","eol"]))throw _.fromNode("\u300E\u9593\u300F\u306E\u76F4\u5F8C\u306F\u6539\u884C\u304C\u5FC5\u8981\u3067\u3059",e);let r=this.yBlock();if(this.check("\u3053\u3053\u307E\u3067"))this.get();else throw _.fromNode("\u300E\u3053\u3053\u307E\u3067\u300F\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u300E\u9593\u300F...\u300E\u3053\u3053\u307E\u3067\u300F\u3092\u5BFE\u5FDC\u3055\u305B\u3066\u304F\u3060\u3055\u3044\u3002",e);return{type:"while",cond:n,block:r,josi:"",...e,end:this.peekSourceMap()}}yAtohantei(){let e=this.peekSourceMap();this.check("\u5F8C\u5224\u5B9A")&&this.get(),this.check("\u7E70\u8FD4")&&this.get(),this.check("\u3053\u3053\u304B\u3089")&&this.get();let n=this.yBlock();this.check("\u3053\u3053\u307E\u3067")&&this.get(),this.check("comma")&&this.get();let r=this.yGetArg(),i=!1,o=this.peek();return o&&o.value==="\u306A\u308B"&&(o.josi==="\u307E\u3067"||o.josi==="\u307E\u3067\u306E")&&(this.get(),i=!0),this.check("\u9593")&&this.get(),i&&(r={type:"not",value:r,josi:"",...e,end:this.peekSourceMap()}),{type:"atohantei",cond:r||[],block:n,josi:"",...e,end:this.peekSourceMap()}}yFor(){let e="\u300E\u7E70\u308A\u8FD4\u3059\u300F\u6587\u3067A\u304B\u3089B\u307E\u3067\u306E\u6307\u5B9A\u304C\u3042\u308A\u307E\u305B\u3093\u3002",n=!0,r=null,i=this.peekSourceMap();if(!(this.check("\u7E70\u8FD4")||this.check("\u5897\u7E70\u8FD4")||this.check("\u6E1B\u7E70\u8FD4")))return null;let o=this.getCur(),s=this.stack.pop();s&&(s.type==="word"&&(s.value==="\u5897"||s.value==="\u6E1B")?(s.value==="\u5897"&&(n=!1),o.type=s.value+o.type):this.stack.push(s));let u=null;(o.type==="\u5897\u7E70\u8FD4"||o.type==="\u6E1B\u7E70\u8FD4")&&(u=this.popStack(["\u305A\u3064"]),o.type==="\u5897\u7E70\u8FD4"&&(n=!1),r=o.type==="\u5897\u7E70\u8FD4"?"up":"down");let c=this.popStack(["\u307E\u3067","\u3092"]),a=this.popStack(["\u304B\u3089"]),f=this.popStack(["\u3092","\u3067"]);if((a===null||c===null)&&!(a==null&&c&&c.type==="func"&&c.name==="\u7BC4\u56F2"))throw _.fromNode(e,o);this.check("comma")&&this.get();let l=!1;this.check("\u3053\u3053\u304B\u3089")?(l=!0,this.get()):this.check("eol")&&(l=!0,this.get());let p=null;if(l)if(p=this.yBlock(),this.check("\u3053\u3053\u307E\u3067"))this.get();else throw _.fromNode("\u300E\u3053\u3053\u307E\u3067\u300F\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u300E\u7E70\u308A\u8FD4\u3059\u300F...\u300E\u3053\u3053\u307E\u3067\u300F\u3092\u5BFE\u5FDC\u3055\u305B\u3066\u304F\u3060\u3055\u3044\u3002",i);else p=this.ySentence();return{type:"for",from:a,to:c,inc:u,flagDown:n,loopDirection:r,word:f,block:p||[],josi:"",...i,end:this.peekSourceMap()}}yReturn(){let e=this.peekSourceMap();if(!this.check("\u623B\u308B"))return null;this.get();let n=this.popStack(["\u3067","\u3092"]);if(this.stack.length>0)throw _.fromNode("\u300E\u623B\u300F\u6587\u306E\u76F4\u524D\u306B\u672A\u89E3\u6C7A\u306E\u5F15\u6570\u304C\u3042\u308A\u307E\u3059\u3002\u300E(\u5F0F)\u3092\u623B\u3059\u300F\u306E\u3088\u3046\u306B\u5F0F\u3092\u30AB\u30C3\u30B3\u3067\u62EC\u3063\u3066\u304F\u3060\u3055\u3044\u3002",e);return{type:"return",value:n,josi:"",...e,end:this.peekSourceMap()}}yForEach(){let e=this.peekSourceMap();if(!this.check("\u53CD\u5FA9"))return null;for(this.get();this.check("comma");)this.get();let n=this.popStack(["\u3092"]),r=this.popStack(["\u3067"]),i=null,o=!1;if(this.check("\u3053\u3053\u304B\u3089")?(o=!0,this.get()):this.check("eol")&&(o=!0),o)if(i=this.yBlock(),this.check("\u3053\u3053\u307E\u3067"))this.get();else throw _.fromNode("\u300E\u3053\u3053\u307E\u3067\u300F\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u300E\u53CD\u5FA9\u300F...\u300E\u3053\u3053\u307E\u3067\u300F\u3092\u5BFE\u5FDC\u3055\u305B\u3066\u304F\u3060\u3055\u3044\u3002",e);else i=this.ySentence();return{type:"foreach",name:r,target:n,block:i||[],josi:"",...e,end:this.peekSourceMap()}}ySwitch(){let e=this.peekSourceMap();if(!this.check("\u6761\u4EF6\u5206\u5C90"))return null;let n=this.get();if(!n)return null;let r=this.get();if(!r)return null;let i=this.popStack(["\u3067"]);if(!i)throw _.fromNode("\u300E(\u5024)\u3067\u6761\u4EF6\u5206\u5C90\u300F\u306E\u3088\u3046\u306B\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002",n);if(r.type!=="eol")throw _.fromNode("\u300E\u6761\u4EF6\u5206\u5C90\u300F\u306E\u76F4\u5F8C\u306F\u6539\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002",n);let o=!1,s=!1,u=[];for(;!this.isEOF();){if(this.check("\u3053\u3053\u307E\u3067")){if(s)throw _.fromNode("\u300E\u6761\u4EF6\u5206\u5C90\u300F\u306F\u300E(\u6761\u4EF6)\u306A\u3089\u3070\u301C\u3053\u3053\u307E\u3067\u300F\u3068\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002",n);this.get();break}if(this.check("eol")){this.get();continue}if(o)throw _.fromNode("\u300E\u6761\u4EF6\u5206\u5C90\u300F\u3067\u300E\u9055\u3048\u3070\u301C\u3053\u3053\u307E\u3067\u300F\u306E\u5F8C\u306B\u51E6\u7406\u3092\u7D9A\u3051\u308B\u3053\u3068\u306F\u51FA\u6765\u307E\u305B\u3093\u3002",n);let c=null,a=this.peek();if(a&&a.type==="\u9055\u3048\u3070")s=!1,o=!0,c=this.get(),this.check("comma")&&this.get();else{if(s)throw _.fromNode("\u300E\u6761\u4EF6\u5206\u5C90\u300F\u306F\u300E(\u6761\u4EF6)\u306A\u3089\u3070\u301C\u3053\u3053\u307E\u3067\u300F\u3068\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002",n);if(c=this.yValue(),!c)throw _.fromNode("\u300E\u6761\u4EF6\u5206\u5C90\u300F\u306F\u300E(\u6761\u4EF6)\u306A\u3089\u3070\u301C\u3053\u3053\u307E\u3067\u300F\u3068\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002",n);let p=this.get();if(!p||p.type!=="\u306A\u3089\u3070")throw _.fromNode("\u300E\u6761\u4EF6\u5206\u5C90\u300F\u3067\u6761\u4EF6\u306F\uFF0A\uFF0A\u306A\u3089\u3070\u3068\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002",n);this.check("comma")&&this.get()}let f=this.yBlock(),l=this.peek();if(l&&l.type==="\u3053\u3053\u307E\u3067")this.get();else{if(o)throw _.fromNode("\u300E\u6761\u4EF6\u5206\u5C90\u300F\u306F\u300E\u9055\u3048\u3070\u301C\u3053\u3053\u307E\u3067\u300F\u3068\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002",n);s=!0}u.push([c,f])}return{type:"switch",value:i,cases:u||[],josi:"",...e,end:this.peekSourceMap()}}yMumeiFunc(){let e=this.peekSourceMap();if(!this.check("def_func"))return null;let n=this.get();if(!n)return null;let r=[];this.check("comma")&&this.get(),this.check("(")&&(r=this.yDefFuncReadArgs()||[]),this.check("comma")&&this.get(),this.funcLevel++,this.saveStack();let i=this.yBlock();if(!this.check("\u3053\u3053\u307E\u3067"))throw _.fromNode("\u300E\u3053\u3053\u307E\u3067\u300F\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u300E\u306B\u306F\u300F\u69CB\u6587\u304B\u7121\u540D\u95A2\u6570\u306E\u672B\u5C3E\u306B\u300E\u3053\u3053\u307E\u3067\u300F\u304C\u5FC5\u8981\u3067\u3059\u3002",e);return this.get(),this.loadStack(),this.funcLevel--,{type:"func_obj",args:r,block:i,meta:n.meta,josi:"",...e,end:this.peekSourceMap()}}yDainyu(){let e=this.peekSourceMap(),n=this.get();if(n===null)return null;let r=this.popStack(["\u3092"]),i=this.popStack(["\u3078","\u306B"]);if(!i||i.type!=="word"&&i.type!=="func"&&i.type!=="\u914D\u5217\u53C2\u7167")throw _.fromNode("\u4EE3\u5165\u6587\u3067\u4EE3\u5165\u5148\u306E\u5909\u6570\u304C\u898B\u5F53\u305F\u308A\u307E\u305B\u3093\u3002\u300E(\u5909\u6570\u540D)\u306B(\u5024)\u3092\u4EE3\u5165\u300F\u306E\u3088\u3046\u306B\u4F7F\u30