nadesiko3
Version:
Japanese Programming Language
12 lines • 363 kB
JavaScript
"use strict";(()=>{var z={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},ae=["\u3044\u3066","\u3048\u3066","\u304D\u3066","\u3051\u3066","\u3057\u3066","\u3063\u3066","\u306B\u3066","\u307F\u3066","\u3081\u3066","\u306D\u3066","\u306B\u306F","\u3093\u3067"],Ee=[];for(let t in z)Ee.push(t);function M(t="?",e="",n=-1,r=0,s="main.nako3"){return{type:t,value:e,indent:n,line:r,column:0,file:s,josi:""}}var Ne=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.isModifiedNodes=!1,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 s=`${r}__${e}`,o=this.moduleExport.get(r),u=this.funclist.get(s);if(u&&(u.isExport===!0||u.isExport!==!1&&o!==!1))return{name:s,scope:"global",info:this.funclist.get(s)}}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 s=this.tokens[r];if(e[n]instanceof Array){if(e[n].indexOf(s.type)<0)return!1;continue}if(s.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,s=()=>(this.index=r,!1);for(let o=0;o<e.length;o++){if(this.isEOF())return s();let u=e[o];if(u==null)return s();if(typeof u=="string"){let i=this.get();if(i&&i.type!==u)return s();n[o]=i;continue}if(typeof u=="function"){let c=u.bind(this)(n);if(c===null)return s();n[o]=c;continue}if(u instanceof Array){if(!this.checkTypes(u))return s();n[o]=this.get();continue}throw new Error("System Error : accept broken : "+typeof u)}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=M()),e):this.tokens[this.index]}peekSourceMap(e=void 0){let n=e===void 0?this.peek():e;return n===null?{startOffset:void 0,endOffset:void 0,file:void 0,line:0,column:0}:{startOffset:n.startOffset,endOffset:n.endOffset,file:n.file,line:n.line,column:n.column}}nodeToStr(e,n,r){let s=n.depth-1,o=i=>n.typeName!==void 0?n.typeName:i,u=r?" debug: "+JSON.stringify(e,null,2):"";if(!e)return"(NULL)";switch(e.type){case"not":if(s>=0){let i=e.blocks[0];return`${o("")}\u300E${this.nodeToStr(i,{depth:s},r)}\u306B\u6F14\u7B97\u5B50\u300Enot\u300F\u3092\u9069\u7528\u3057\u305F\u5F0F${u}\u300F`}else return`${o("\u6F14\u7B97\u5B50")}\u300Enot\u300F`;case"op":{let i=e,c=i.operator||"",a={eq:"\uFF1D",not:"!",gt:">",lt:"<",and:"\u304B\u3064",or:"\u307E\u305F\u306F"};if(c in a&&(c=a[c]),s>=0){let f=this.nodeToStr(i.blocks[0],{depth:s},r),l=this.nodeToStr(i.blocks[1],{depth:s},r);return i.operator==="eq"?`${o("")}\u300E${f}\u3068${l}\u304C\u7B49\u3057\u3044\u304B\u3069\u3046\u304B\u306E\u6BD4\u8F03${u}\u300F`:`${o("")}\u300E${f}\u3068${l}\u306B\u6F14\u7B97\u5B50\u300E${c}\u300F\u3092\u9069\u7528\u3057\u305F\u5F0F${u}\u300F`}else return`${o("\u6F14\u7B97\u5B50")}\u300E${c}${u}\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}${u}\u300F`;case"word":return`${o("\u5358\u8A9E")}\u300E${e.value}${u}\u300F`;case"func":return`${o("\u95A2\u6570")}\u300E${e.name||e.value}${u}\u300F`;case"eol":return"\u884C\u306E\u672B\u5C3E";case"eof":return"\u30D5\u30A1\u30A4\u30EB\u306E\u672B\u5C3E";default:{let i=e.name;return i&&(i=e.value),typeof i!="string"&&(i=e.type),`${o("")}\u300E${i}${u}\u300F`}}}};var P=class extends Error{constructor(e,n,r=void 0,s=void 0){let o=`${r||""}${s===void 0?"":`(${s+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}},fe=class extends P{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}},K=class extends P{constructor(e,n,r,s,o){super("\u5B57\u53E5\u89E3\u6790\u30A8\u30E9\u30FC\uFF08\u5185\u90E8\u30A8\u30E9\u30FC\uFF09",e,o,s),this.type="InternalLexerError",this.preprocessedCodeStartOffset=n,this.preprocessedCodeEndOffset=r,this.line=s,this.file=o}},se=class extends P{constructor(e,n,r,s,o){super("\u5B57\u53E5\u89E3\u6790\u30A8\u30E9\u30FC",e,o,s),this.type="NakoLexerError",this.startOffset=n,this.endOffset=r,this.line=s,this.file=o}},y=class t extends P{static fromNode(e,n,r=void 0){if(!n)return new t(e,void 0,void 0,void 0,void 0);let s=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,s,o,n.file)}constructor(e,n,r,s,o){super("\u6587\u6CD5\u30A8\u30E9\u30FC",e,o,n),this.type="NakoSyntaxError",this.file=o,this.line=n,this.startOffset=r,this.endOffset=s}},oe=class t extends P{constructor(e,n){let r="unknown";typeof e=="string"?r=e:e instanceof t||e instanceof P?r=e.msg:e instanceof Error&&(e.name==="Error"?r=e.message:r=`${e.name}: ${e.message}`);let s,o,u;n===void 0?(s=void 0,o=void 0):(u=/^l(-?\d+):(.*)$/.exec(n))?(s=parseInt(u[1]),o=u[2]):(u=/^l(-?\d+)$/.exec(n))?(s=parseInt(u[1]),o="main.nako3"):(s=0,o=n),super("\u5B9F\u884C\u6642\u30A8\u30E9\u30FC",r,o,s),this.type="NakoRuntimeError",this.lineNo=n,this.line=s,this.file=o}},q=class extends P{constructor(e,n,r){super("\u53D6\u308A\u8FBC\u307F\u30A8\u30E9\u30FC",e,n,r),this.file=n,this.line=r}};var Nn=new Map([["\u3082\u3057","\u3082\u3057"],["\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"],["DNCL2\u30E2\u30FC\u30C9","DNCL2\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"]]),Ye=Nn;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 Te=["\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"],Fn=["\u3067\u306A\u3051\u308C\u3070","\u306A\u3051\u308C\u3070","\u306A\u3089\u3070","\u306A\u3089","\u305F\u3089","\u308C\u3070"],Tn=["\u3053\u3068","\u3067\u3042\u308B","\u3067\u3059","\u3057\u307E\u3059","\u3067\u3057\u305F"],Ze={};Fn.forEach(t=>{Te.push(t),Ze[t]=!0});var le={};Tn.forEach(t=>{Te.push(t),le[t]=!0});var Fe=[];for(let t of Te)Fe.push("\u3082\u306E"+t),Fe.push(t);Fe.sort((t,e)=>e.length-t.length);var Cn="^[\\t ]*("+Fe.join("|")+")",pe=new RegExp(Cn),jt=Te;var Ln=/^[\u3005\u4E00-\u9FCF_a-zA-Z0-9ァ-ヶー\u2460-\u24FF\u2776-\u277F\u3251-\u32BF]+/,Ot=/^[ぁ-ん]/,Vn=/^[ぁ-ん]+$/,Dn=/^.+(以上|以下|超|未満)$/,In=/^(かつ|または)/,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|b|mb|kb|gb)/,At=/^(px|em|ex|rem|vw|vh|vmin|vmax)/,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:Rn},{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:he},{name:"number",pattern:/^0[oO][0-7]+(_[0-7]+)*/,readJosi:!0,cb:he},{name:"number",pattern:/^0[bB][0-1]+(_[0-1]+)*/,readJosi:!0,cb:he},{name:"number",pattern:/^\d+(_\d+)*\.(\d+(_\d+)*)?([eE][+|-]?\d+(_\d+)*)?/,readJosi:!0,cb:he},{name:"number",pattern:/^\.\d+(_\d+)*([eE][+|-]?\d+(_\d+)*)?/,readJosi:!0,cb:he},{name:"number",pattern:/^\d+(_\d+)*([eE][+|-]?\d+(_\d+)*)?/,readJosi:!0,cb:he},{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:"??",pattern:/^\?\?/},{name:"word",pattern:/^\$\{.+?\}/,cbParser:t=>Bn(t)},{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:Jn}];function Pn(t){return Ot.test(t)?Vn.test(t)?t:t.replace(/[ぁ-ん]+$/g,""):t.replace(/[ぁ-ん]+/g,"")}function Rn(t){let e="",n="",r=0;t=t.substring(2);let s=t.indexOf("*/");s<0?(e=t,t=""):(e=t.substring(0,s),t=t.substring(s+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 Jn(t,e=!0){let n="",r="";for(;t!=="";){if(n.length>0){if(In.exec(t))break;let c=pe.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=Ln.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 s=Dn.exec(n);return s&&(t=s[1]+r+t,r="",n=n.substring(0,n.length-s[1].length)),r.substring(0,2)==="\u3082\u306E"&&(r=r.substring(2)),le[r]&&(r=""),e&&(n=Pn(n)),n===""&&r!==""&&(n=r,r=""),{src:t,res:n,josi:r,numEOL:0}}function ie(t,e,n){let r="",s="",o=0;n=n.substring(t.length);let u=n.indexOf(e);if(u<0)r=n,n="";else if(r=n.substring(0,u),n=n.substring(u+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 i=pe.exec(n);i&&(s=i[0].replace(/^\s+/,""),n=n.substring(i[0].length),n.charAt(0)===","&&(n=n.substring(1))),le[s]&&(s=""),s.substring(0,2)==="\u3082\u306E"&&(s=s.substring(2));for(let c=0;c<r.length;c++)r.charAt(c)===`
`&&o++;return{src:n,res:r,josi:s,numEOL:o}}function Bn(t){let e="",n="",r=0;t=t.substring(2);let s=t.indexOf("}");if(s<0)throw new Error("\u5909\u6570\u540D\u306E\u7D42\u308F\u308A\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002");e=t.substring(0,s),t=t.substring(s+1);let o=pe.exec(t);o&&(n=o[0].replace(/^\s+/,""),t=t.substring(o[0].length),t.charAt(0)===","&&(t=t.substring(1)));for(let u=0;u<e.length;u++)e.charAt(u)===`
`&&r++;if(r>0)throw new Error("\u5909\u6570\u540D\u306B\u6539\u884C\u3092\u542B\u3081\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002");return{src:t,res:e,josi:n,numEOL:r}}function he(t){return Number(t.replace(/_/g,""))}var G=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(Ye.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 s=this.result[this.result.length-1];this.result.push({type:"eol",line:s.line,column:0,indent:-1,file:s.file,josi:"",value:"---",startOffset:s.startOffset,endOffset:s.endOffset,rawJosi:""}),this.result.push({type:"eof",line:s.line,indent:-1,column:0,file:s.file,josi:"",value:"",startOffset:s.startOffset,endOffset:s.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,s){let o=0,u=!1,i=()=>{let c=[],a={};if(e[o].type!=="(")return[];for(o++;e[o];){let _=e[o];if(o++,_.type===")")break;_.type==="func"?u=!0:_.type!=="|"&&_.type!=="comma"&&(u&&(_.funcPointer=!0,u=!1),c.push(_),a[_.value]||(a[_.value]=[]),a[_.value].push(_.josi))}let f=[],l=[],p=[],h={};for(let _ of c)if(!h[_.value]){let g=a[_.value];p.push(g),f.push(_.value),_.funcPointer?l.push(_.value):l.push(null),h[_.value]=!0}return[p,f,l]};for(;o<e.length;){let c=e[o];if(c.type==="not"&&e.length-o>3){let m={type:"eol"};if(o>=1&&(m=e[o-1]),m.type==="eol"){let w=e[o+1];if(w.type==="word"&&w.value==="\u30E2\u30B8\u30E5\u30FC\u30EB\u516C\u958B\u65E2\u5B9A\u5024"){if(w.type="\u30E2\u30B8\u30E5\u30FC\u30EB\u516C\u958B\u65E2\u5B9A\u5024",w=e[o+2],w.type==="string"&&w.value==="\u975E\u516C\u958B"){let A=t.filenameToModName(c.file);s.set(A,!1),o+=3;continue}else if(w.type==="string"&&w.value==="\u516C\u958B"){let A=t.filenameToModName(c.file);s.set(A,!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 m=e[o+1];m.value==="\u7E70\u8FD4"&&(m.value="\u9593",m.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 m={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,m),c.endOffset--,o++}if(c.type==="word"){let m=Ye.get(c.value);m&&(c.type=m),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=[],_=[],g="",b=null,k=null;if(e[o]&&e[o].type==="{"){o++;let m=e[o]&&e[o].type==="word"?e[o].value:"";m==="\u516C\u958B"?k=!0:m==="\u975E\u516C\u958B"?k=!1:m==="\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8"?k=!0:n.warn(`\u4E0D\u660E\u306A\u95A2\u6570\u5C5E\u6027\u300E${m}\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,_]=i()),!a&&e[o]&&e[o].type==="word"&&(b=e[o++],g=b.value),p.length===0&&e[o]&&e[o].type==="("&&([p,h,_]=i()),g!==""&&b){if(g=t.filenameToModName(c.file)+"__"+g,r.has(g)){let w=g.replace(/^main__/,"");n.warn(`\u95A2\u6570\u300E${w}\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:k,varnames:h,funcPointers:_})}let d={type:"func",josi:p,varnames:h,funcPointers:_};l.meta=d}}splitStringEx(e){let n=[],r=e.split(/[{{]/);n.push(r[0]);for(let s of r.slice(1)){let o=s.replace("\uFF5D","}").indexOf("}");if(o===-1)return null;n.push(s.slice(0,o),s.slice(o+1))}return n}_replaceWord(e){let n=[],r=0,s=!1,o=[],u=()=>r<=0?"eol":e[r-1].type,i=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(s)throw new K("\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(i),i=e[r-1].value}if((c.type==="word"||c.type==="func")&&c.value==="\u540D\u524D\u7A7A\u9593\u30DD\u30C3\u30D7"){if(s)throw new K("\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&&(i=a)}if(c.type==="word"&&c.value!=="\u305D\u308C"){let a=c.value;if(a.indexOf("__")<0){let l=`${i}__${a}`,p=this.funclist.get(l);if(p&&p.type==="func"){let h=c;h.type=s?"func_pointer":"func",h.meta=p,h.value=l,s&&(s=!1,e.splice(r-1,1));continue}for(let h of this.modList){let _=`${h}__${a}`,g=this.funclist.get(_),b=this.moduleExport.get(h);if(g&&g.type==="func"&&(g.isExport===!0||g.isExport!==!1&&b!==!1)){let k=c;k.type=s?"func_pointer":"func",k.meta=g,k.value=_,s&&(s=!1,e.splice(r-1,1));break}}}let f=this.funclist.get(a);if(f&&f.type==="func"){let l=c;if(l.type=s?"func_pointer":"func",l.meta=f,s){s=!1,e.splice(r-1,1);continue}}}if(s=!1,c.type==="func"&&c.value==="{\u95A2\u6570}"){r++,s=!0;continue}if(c.type==="-"&&e[r+1]){let a=e[r+1].type;if(a==="number"||a==="bigint"){let f=u();(f==="eol"||z[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:"\u3068\u306F",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(Ze[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 s=e.charAt(r),o=St(s);if(o===0)return[n,r];n+=o}return[n,e.length]}tokenize(e,n,r){let s=e.length,o=[],u,i,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 _=h.pattern.exec(e);if(!_)continue;let g=h.name;if(p=!0,h.name==="space"){c+=_[0].length,e=e.substring(_[0].length);continue}if(h.cbParser){let m;if(a&&h.name==="word")m=h.cbParser(e,!1);else try{m=h.cbParser(e)}catch(w){throw new se(w.message,s-e.length,s-e.length+1,n,r)}if(h.name==="string_ex"){let w=this.splitStringEx(m.res);if(w===null)throw new K("\u5C55\u958B\u3042\u308A\u6587\u5B57\u5217\u3067\u5024\u306E\u57CB\u3081\u8FBC\u307F{...}\u304C\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\u3002",s-e.length,s-m.src.length,n,r);let A=0;for(let N=0;N<w.length;N++){let D=N===w.length-1?m.josi:"";N%2===0?(o.push({type:"string",value:w[N],file:r,josi:D,indent:f,line:n,column:c,preprocessedCodeOffset:s-e.length+A,preprocessedCodeLength:w[N].length+2+D.length}),A+=w[N].length+2):(o.push({type:"&",value:"&",josi:"",indent:f,file:r,line:n,column:c,preprocessedCodeOffset:s-e.length+A,preprocessedCodeLength:0}),o.push({type:"(",value:"(",josi:"",indent:f,file:r,line:n,column:c,preprocessedCodeOffset:s-e.length+A,preprocessedCodeLength:0}),o.push({type:"code",value:w[N],josi:"",indent:f,file:r,line:n,column:c,preprocessedCodeOffset:s-e.length+A,preprocessedCodeLength:w[N].length}),o.push({type:")",value:")",josi:"",indent:f,file:r,line:n,column:c,preprocessedCodeOffset:s-e.length+A+w[N].length,preprocessedCodeLength:0}),o.push({type:"&",value:"&",josi:"",indent:f,file:r,line:n,column:c,preprocessedCodeOffset:s-e.length+A+w[N].length,preprocessedCodeLength:0}),A+=w[N].length)}n+=m.numEOL,c+=e.length-m.src.length,e=m.src,m.numEOL>0&&(c=1);break}u=c,c+=e.length-m.src.length,o.push({type:h.name,value:m.res,josi:m.josi,indent:f,line:n,column:u,file:r,preprocessedCodeOffset:s-e.length,preprocessedCodeLength:e.length-m.src.length}),e=m.src,n+=m.numEOL,m.numEOL>0&&(c=1);break}let b=s-e.length,k=_[0];if(h.cb&&(k=h.cb(k)),u=c,i=n,c+=_[0].length,e=e.substring(_[0].length),(h.name==="eol"&&k===`
`||h.name==="_eol")&&(k=n++,c=1),h.name==="number"){let m=$t.exec(e);m&&(e=e.substring(m[0].length),c+=_[0].length);let w=At.exec(e);w&&(g="string",e=e.substring(w[0].length),c+=_[0].length,k+=w[0])}let d="";if(h.readJosi){let m=pe.exec(e);m&&(c+=m[0].length,d=m[0].replace(/^\s+/,""),e=e.substring(m[0].length),e.charAt(0)===","&&(e=e.substring(1)),le[d]&&(d=""),d.substring(0,2)==="\u3082\u306E"&&(d=d.substring(2)))}switch(g){case"def_test":{a=!0;break}case"eol":{a=!1;break}default:break}if(g==="dec_lineno"){n--;continue}if(o.push({type:g,value:k,indent:f,line:i,column:u,file:r,josi:d,preprocessedCodeOffset:b,preprocessedCodeLength:s-e.length-b}),g==="eol"&&c===1){let m=this.countIndent(e);f=m[0],c+=m[1],e=e.substring(m[1])}break}if(!p)throw new K("\u672A\u77E5\u306E\u8A9E\u53E5: "+e.substring(0,3)+"...",s-e.length,s-s+3,n,r)}return o}static tokensToTypeStr(e,n){return e.map(s=>s.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 Ce=class extends Ne{parse(e,n){this.reset(),this.tokens=e,this.modName=G.filenameToModName(n),this.modList.push(this.modName);let r=this.startParser();for(this.isModifiedNodes=!1,this._checkAsyncFn(r);this.isModifiedNodes;)this.isModifiedNodes=!1,this._checkAsyncFn(r);return r}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),y.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}yNop(){return{type:"nop",josi:"",...this.peekSourceMap(),end:this.peekSourceMap()}}ySentenceList(){let e=[],n=-1,r=this.peekSourceMap();for(;!this.isEOF();){let s=this.ySentence();if(!s)break;e.push(s),n<0&&(n=s.line)}if(e.length===0){let s=this.peek()||this.tokens[0];throw this.logger.debug("\u69CB\u6587\u89E3\u6790\u306B\u5931\u6557:"+this.nodeToStr(this.peek(),{depth:1},!0),s),y.fromNode("\u69CB\u6587\u89E3\u6790\u306B\u5931\u6557:"+this.nodeToStr(this.peek(),{depth:1},!1),s)}return{type:"block",blocks:e,josi:"",...r,end:this.peekSourceMap()}}makeStackBalanceReport(){let e=[];this.stack.forEach(o=>{let u=this.nodeToStr(o,{depth:1},!1);o.josi&&(u+=o.josi),e.push(u)});let n=e.join(","),r="",s=65;for(let o of this.recentlyCalledFunc){r+=" - ";let u=0,i=o.josi;if(i)for(let c of i){let a=String.fromCharCode(s+u);r+=a,c.length===1?r+=c[0]:r+=`(${c.join("|")})`,u++}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 y.fromNode(n,e)}return this.recentlyCalledFunc=[],{type:"eol",comment:e.value,line:e.line,column:e.column,file:e.file}}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.check("??"))return this.yDebugPrint();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()||M();throw y.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 s=this.peekSourceMap(),o=n;return this.get(),this.yIfThen(o,s)}else if(ae.indexOf(n.josi||"")>=0){if(this.stack.length>=1){let o=this.makeStackBalanceReport();throw y.fromNode(o,n)}let s=this.ySentence();if(s!==null)return{type:"block",blocks:[n,s],josi:s.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",blocks:n,josi:"",...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.yDefFuncCommon("def_test")}yDefFunc(){return this.yDefFuncCommon("def_func")}yDefFuncCommon(e){if(!this.check(e))return null;let n=this.peekSourceMap(),r=this.get();if(!r)return null;let s=r,o=this.isExportDefault;if(this.check("{")){this.get();let p=this.get();if(this.check("}"))this.get();else throw y.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",s);p!=null&&(p.value==="\u516C\u958B"&&(o=!0),p.value==="\u975E\u516C\u958B"&&(o=!1),p.value==="\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8"&&(o=!0))}let u=[];this.check("(")&&(u=this.yDefFuncReadArgs()||[]);let i=this.get();if(!i||i.type!=="func")throw this.logger.debug(this.nodeToStr(i,{depth:0,typeName:"\u95A2\u6570"},!0)+"\u306E\u5BA3\u8A00\u3067\u30A8\u30E9\u30FC\u3002",i),y.fromNode(this.nodeToStr(i,{depth:0,typeName:"\u95A2\u6570"},!1)+"\u306E\u5BA3\u8A00\u3067\u30A8\u30E9\u30FC\u3002",s);if(this.check("(")){if(u.length>0)throw this.logger.debug(this.nodeToStr(i,{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",i),y.fromNode(this.nodeToStr(i,{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",i);u=this.yDefFuncReadArgs()||[]}this.check("\u3068\u306F")&&this.get();let c=this.yNop(),a=!1,f=!1;this.check("\u3053\u3053\u304B\u3089")&&(a=!0),this.check("eol")&&(a=!0);try{this.funcLevel++,this.usedAsyncFn=!1;let p=this.localvars;if(this.localvars=new Map([["\u305D\u308C",{type:"var",value:""}]]),a){this.saveStack();for(let h of u){if(!h||!h.value)continue;let _=h.value;this.localvars.set(_,{type:"var",value:""})}if(c=this.yBlock(),this.check("\u3053\u3053\u307E\u3067"))this.get();else throw y.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",s);this.loadStack()}else this.saveStack(),c=this.ySentence()||this.yNop(),this.loadStack();this.funcLevel--,f=this.usedAsyncFn,this.localvars=p}catch(p){throw this.logger.debug(this.nodeToStr(i,{depth:0,typeName:"\u95A2\u6570"},!0)+`\u306E\u5B9A\u7FA9\u3067\u4EE5\u4E0B\u306E\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3057\u305F\u3002
`+p.message,s),y.fromNode(this.nodeToStr(i,{depth:0,typeName:"\u95A2\u6570"},!1)+`\u306E\u5B9A\u7FA9\u3067\u4EE5\u4E0B\u306E\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3057\u305F\u3002
`+p.message,s)}let l=this.funclist.get(i.value);return l&&!l.asyncFn&&f&&(l.asyncFn=f),{type:e,name:i.value,args:u,blocks:[c],asyncFn:f,isExport:o,josi:"",meta:s.meta,...n,end:this.peekSourceMap()}}yIFCond(){let e=this.peekSourceMap(),n=this.yGetArg();if(!n)throw y.fromNode("\u300C\u3082\u3057\u300D\u6587\u306E\u6761\u4EF6\u5F0F\u306B\u9593\u9055\u3044\u304C\u3042\u308A\u307E\u3059\u3002"+this.nodeToStr(this.peek(),{depth:1},!1),e);if(n.josi==="\u306A\u3089\u3070")return n;if(n.josi==="\u3067\u306A\u3051\u308C\u3070")return n={type:"not",operator:"not",blocks:[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 s=this.index,o=this.yGetArg();if(!o)throw y.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 u=this.get()||{value:"\u306A\u3089\u3070"};o.josi=u.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",blocks:[n,o],josi:"",...e,end:this.peekSourceMap()};this.index=s}if(this.check("\u306A\u3089\u3070")||(this.stack.push(n),n=this.yCall()),!this.check("\u306A\u3089\u3070")){let s=n||this.yNop();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",s),y.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",s)}let r=this.get();if(r&&r.value==="\u3067\u306A\u3051\u308C\u3070"&&(n={type:"not",operator:"not",blocks:[n],josi:"",...e,end:this.peekSourceMap()}),!n)throw y.fromNode("\u300C\u3082\u3057\u300D\u6587\u306E\u6761\u4EF6\u5F0F\u306B\u9593\u9055\u3044\u304C\u3042\u308A\u307E\u3059\u3002"+this.nodeToStr(this.peek(),{depth:1},!1),e);return 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(s){throw y.fromNode(`\u300E\u3082\u3057\u300F\u6587\u306E\u6761\u4EF6\u3067\u6B21\u306E\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059\u3002
`+s.message,n)}return this.yIfThen(r,e)}yIfThen(e,n){let r=this.yNop(),s=this.yNop(),o=!1;if(this.check("eol"))r=this.yBlock();else{let u=this.ySentence();u&&(r=u),o=!0}for(;this.check("eol");)this.get();if(this.check("\u9055\u3048\u3070")){for(this.get();this.check("comma");)this.get();if(this.check("eol"))s=this.yBlock();else{let u=this.ySentence();u&&(s=u),o=!0}}if(o===!1)if(this.check("\u3053\u3053\u307E\u3067"))this.get();else throw y.fromNode("\u300E\u3082\u3057\u300F\u6587\u3067\u300E\u3053\u3053\u307E\u3067\u300F\u304C\u3042\u308A\u307E\u305B\u3093\u3002",n);return{type:"if",blocks:[e,r,s],josi:"",...n,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 s={\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 i of r.split("/")){if(i==="\u5168\u3066"){for(let c of Object.keys(s))s[c]=!0;break}Object.keys(s).includes(i)?s[i]=!0:this.logger.warn(`\u5B9F\u884C\u901F\u5EA6\u512A\u5148\u6587\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u300E${i}\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 u=this.yNop();return o?(u=this.yBlock(),this.check("\u3053\u3053\u307E\u3067")&&this.get()):u=this.ySentence()||u,{type:"speed_mode",options:s,blocks:[u],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 u of n.value.split("/")){if(u==="\u5168\u3066"){for(let i of Object.keys(r))r[i]=!0;break}Object.keys(r).includes(u)?r[u]=!0:this.logger.warn(`\u30D1\u30D5\u30A9\u30FC\u30DE\u30F3\u30B9\u30E2\u30CB\u30BF\u9069\u7528\u6587\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u300E${u}\u300F\u306F\u5B58\u5728\u3057\u307E\u305B\u3093\u3002`,n)}let s=!1;this.check("\u3053\u3053\u304B\u3089")?(this.get(),s=!0):this.check("eol")&&(s=!0);let o=this.yNop();return s?(o=this.yBlock(),this.check("\u3053\u3053\u307E\u3067")&&this.get()):o=this.ySentence()||o,{type:"performance_monitor",options:r,blocks:[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&&z[r.type]){r=this.getCur(),n.push(r);let s=this.yValue();if(s===null)throw y.fromNode(`\u8A08\u7B97\u5F0F\u3067\u6F14\u7B97\u5B50\u300E${r.value}\u300F\u5F8C\u306B\u5024\u304C\u3042\u308A\u307E\u305B\u3093`,e);n.push(s);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 y.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);let s=this.funclist.get("\u7BC4\u56F2");if(!s)throw new Error("\u95A2\u6570\u300E\u7BC4\u56F2\u300F\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002plugin_system\u3092\u30B7\u30B9\u30C6\u30E0\u306B\u8FFD\u52A0\u3057\u3066\u304F\u3060\u3055\u3044\u3002");return{type:"func",name:"\u7BC4\u56F2",blocks:[e,r],josi:r.josi,meta:s,asyncFn:!1,...n,end:this.peekSourceMap()}}yDebugPrint(){let e=this.peekSourceMap(),n=this.get();if(!n||n.value!=="??")throw y.fromNode("\u300E??\u300F\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002",e);let r=this.yGetArg();if(!r)throw y.fromNode("\u300E??(\u8A08\u7B97\u5F0F)\u300F\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002",e);let s=this.funclist.get("\u30CF\u30C6\u30CA\u95A2\u6570\u5B9F\u884C");if(!s)throw new Error("\u95A2\u6570\u300E\u30CF\u30C6\u30CA\u95A2\u6570\u5B9F\u884C\u300F\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002plugin_system\u3092\u30B7\u30B9\u30C6\u30E0\u306B\u8FFD\u52A0\u3057\u3066\u304F\u3060\u3055\u3044\u3002");return{type:"func",name:"\u30CF\u30C6\u30CA\u95A2\u6570\u5B9F\u884C",blocks:[r],josi:"",meta:s,asyncFn:!1,...e,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=>z[o.type]?z[o.type]:10,r=[],s=[];for(;e.length>0;){let o=e.shift();if(!o)break;for(;r.length>0;){let u=r[r.length-1];if(n(o)>n(u))break;let i=r.pop();if(!i){this.logger.error("\u8A08\u7B97\u5F0F\u306B\u9593\u9055\u3044\u304C\u3042\u308A\u307E\u3059\u3002",o);break}s.push(i)}r.push(o)}for(;r.length>0;){let o=r.pop();o&&s.push(o)}return s}infixToAST(e){if(e.length===0)return null;let n=e[e.length-1].josi,r=e[e.length-1],s=this.infixToPolish(e),o=[];for(let i of s){if(!z[i.type]){o.push(i);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(s)),y.fromNode("\u8A08\u7B97\u5F0F\u3067\u30A8\u30E9\u30FC",r);let f={type:"op",operator:i.type,blocks:[a,c],josi:n,startOffset:a.startOffset,endOffset:a.endOffset,line:a.line,column:a.column,file:a.file};o.push(f)}let u=o.pop();return u||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 y.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 s=[];for(;r<this.stack.length;){let o=this.popStack();o&&s.unshift(o)}return s}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([])||{type:"word",value:"\u305D\u308C",josi:"",...e,end:this.peekSourceMap()},r=!1,s=this.yNop();if(this.check("comma")&&this.get(),this.check("\u3053\u3053\u304B\u3089")?(this.get(),r=!0):this.check("eol")&&(r=!0),r)if(s=this.yBlock(),this.check("\u3053\u3053\u307E\u3067"))this.get();else throw y.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{let o=this.ySentence();o&&(s=o)}return{type:"repeat_times",blocks:[n,s],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 y.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 y.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 y.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",blocks:[n,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(),s=!1,o=this.peek();return o&&o.value==="\u306A\u308B"&&(o.josi==="\u307E\u3067"||o.josi==="\u307E\u3067\u306E")&&(this.get(),s=!0),this.check("\u9593")&&this.get(),s&&(r={type:"not",operator:"not",blocks:[r],josi:"",...e,end:this.peekSourceMap()}),r||(r={type:"number",value:1,josi:"",...e,end:this.peekSourceMap()}),{type:"atohantei",blocks:[r,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=!0,s=null,o=this.peekSourceMap();if(!(this.check("\u7E70\u8FD4")||this.check("\u5897\u7E70\u8FD4")||this.check("\u6E1B\u7E70\u8FD4")))return null;let u=this.getCur(),i=this.stack.pop();if(i)if(i.type==="word"&&(i.value==="\u5897"||i.value==="\u6E1B")){i.value==="\u5897"?n=!1:r=!1;let g=i.value+u.type;if(g=="\u5897\u7E70\u8FD4")u.type="\u5897\u7E70\u8FD4";else if(g=="\u6E1B\u7E70\u8FD4")u.type="\u6E1B\u7E70\u8FD4";else throw Error("[System Error] \u5897\u7E70\u308A\u8FD4\u3057 | \u6E1B\u7E70\u308A\u8FD4\u3057\u306E\u30A8\u30E9\u30FC\u3002")}else this.stack.push(i);let c=this.yNop();(u.type==="\u5897\u7E70\u8FD4"||u.type==="\u6E1B\u7E70\u8FD4")&&(c=this.popStack(["\u305A\u3064"])||this.yNop(),u.type==="\u5897\u7E70\u8FD4"?n=!1:r=!1,s=u.type==="\u5897\u7E70\u8FD4"?"up":"down");let a=this.popStack(["\u307E\u3067","\u3092"]),f=this.popStack(["\u304B\u3089"])||this.yNop(),l=this.popStack(["\u3092","\u3067"]),p="";if(l!==null){if(l.type!=="word")throw y.fromNode("\u300E(\u5909\u6570\u540D)\u3092A\u304B\u3089B\u307E\u3067\u7E70\u308A\u8FD4\u3059\u300F\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002",l);p=l.value}if((f===null||a===null)&&!(f==null&&a&&a.type==="func"&&a.name==="\u7BC4\u56F2"))throw y.fromNode(e,u);this.check("comma")&&this.get();let h=!1;this.check("\u3053\u3053\u304B\u3089")?(h=!0,this.get()):this.check("eol")&&(h=!0,this.get());let _=this.yNop();if(h)if(_=this.yBlock(),this.check("\u3053\u3053\u307E\u3067"))this.get();else throw y.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",o);else{let g=this.ySentence();g&&(_=g)}return _||(_=this.yNop()),{type:"for",blocks:[f,a,c,_],flagDown:n,flagUp:r,loopDirection:s,word:p,josi:"",...o,end:this.peekSourceMap()}}yReturn(){let e=this.peekSourceMap();if(!this.check("\u623B\u308B"))return null;this.get();let n=this.popStack(["\u3067","\u3092"])||this.yNop();if(this.stack.length>0)throw y.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",blocks:[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"])||this.yNop(),r=this.popStack(["\u3067"]),s="";if(r!==null){if(r.type!=="word")throw y.fromNode("\u300E(\u5909\u6570\u540D)\u3067(\u914D\u5217)\u3092\u53CD\u5FA9\u300F\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002",e);s=r.value}let o=this.yNop(),u=!1;if(this.check("\u3053\u3053\u304B\u3089")?(u=!0,this.get()):this.check("eol")&&(u=!0),u)if(o=this.yBlock(),this.check("\u3053\u3053\u307E\u3067"))this.get();else throw y.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