├── README.md
├── index.html
├── lua-ast-printer.js
├── lua-string-decode.bundle.js
├── lua-string-decode.js
├── package-lock.json
├── package.json
└── webpack.config.js
/README.md:
--------------------------------------------------------------------------------
1 | # LuaStringEncryptor
2 | Encrypt Your GameGuardian Scripts
3 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
41 |
--------------------------------------------------------------------------------
/lua-ast-printer.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const comments_1 = require('../node_modules/lua-fmt/dist/src/comments');
3 | const printer_1 = require('../node_modules/lua-fmt/dist/src/printer');
4 | const docPrinter_1 = require('../node_modules/lua-fmt/dist/src/docPrinter');
5 | const options_1 = require('../node_modules/lua-fmt/dist/src/options');
6 |
7 | exports.luaParseDefaultOptions = {
8 | locations: true,
9 | ranges: true
10 | };
11 |
12 | function formatAst(ast, userOptions) {
13 | const options = Object.assign({}, options_1.defaultOptions, userOptions);
14 | comments_1.injectShebang(ast, options);
15 | comments_1.attachComments(ast, options);
16 | const doc = printer_1.buildDocFromAst(ast, options);
17 | return docPrinter_1.printDocToString(doc, options);
18 | }
19 |
20 | exports.formatAst = formatAst;
21 |
--------------------------------------------------------------------------------
/lua-string-decode.bundle.js:
--------------------------------------------------------------------------------
1 | var LuaStringDecode=function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=13)}([function(e,t,n){"use strict";function r(e,t,n,r={}){let a=0;return n.forEach(n=>{(r.searchBackwards?e.substring(t-n.length,t):e.substring(t,t+n.length))!==n||(a=n.length)}),t+(r.searchBackwards?-a:a)}function a(e,t,n,a={}){let i=null;for(;i!==t;)i=t,t=r(e,t,n,a);return t}function i(e,t,n={}){return r(e,t,["\n","\r\n"],n)}function o(e,t,n={}){return a(e,t,[" ","\t"],n)}function c(e,t,n={}){return a(e,o(e,t),[";"],n)}function s(e,t,n={}){const r=o(e,t,n);return r!==i(e,r,n)}function u(e,t){if("-"===e.charAt(t)&&"-"===e.charAt(t+1))for(t+=2;t>=0&&t{r>0&&n.push(e),n.push(t)}),r(n)},t.line={type:"line",hard:!1,soft:!1},t.hardline={type:"line",hard:!0,soft:!1},t.softline={type:"line",hard:!1,soft:!0},t.indent=function(e){return{type:"indent",content:e}},t.lineSuffix=function(e){return{type:"lineSuffix",content:e}},t.group=function(e,t=!1){return{type:"group",content:e,willBreak:t}},t.breakParent={type:"breakParent"},t.isEmpty=function(e){return"string"==typeof e&&0===e.length}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(2),a=n(0);var i;function o(e,t){const n=function(e){const t=Object.keys(e),n=[];function r(t){if(t&&"string"==typeof t.type&&"Comment"!==t.type){let r;for(r=n.length-1;r>=0&&!(a.locStart(n[r])<=a.locStart(t)&&a.locEnd(n[r])<=a.locEnd(e));--r);n.splice(r+1,0,t)}}for(const n of t){const t=e[n];Array.isArray(t)?t.forEach(r):t&&r(t)}return n}(e);let r=null,i=null,c=0,s=n.length;for(;c0)&&(t.parameters.length>0&&t.parameters[t.parameters.length-1]===e?(u(t,n),!0):!(!e||"Identifier"!==e.type)&&(u(t,n),!0))}function d(e,t,n,r){return!(!t||"IfStatement"!==t.type)&&(!n||"ElseifClause"!==n.type&&"ElseClause"!==n.type?!(!e||"ElseClause"!==e.type)&&(u(e,r),!0):(u(e,r),!0))}function g(e,t,n){if(n.raw.startsWith("--[["))return!1;if(!t)return!1;switch(t.type){case"WhileStatement":if(e===t.condition)return l(t,n),!0;break;case"DoStatement":case"RepeatStatement":if(null==e)return l(t,n),!0;break;case"FunctionDeclaration":if(t.parameters.length&&e===t.parameters[t.parameters.length-1]||e===t.identifier)return l(t,n),!0;break;case"ForNumericStatement":if(e===t.end||e===t.step)return l(t,n),!0;break;case"ForGenericStatement":if(e===t.iterators[t.iterators.length-1])return l(t,n),!0;break;case"IfClause":case"ElseifClause":if(e===t.condition&&n.loc.start.column>e.loc.start.column)return l(t,n),!0;break;case"ElseClause":if(null==e)return l(t,n),!0}return!1}function m(e,t,n){if(!e||!t)return!1;if("IfStatement"!==t.type)return!1;switch(e.type){case"IfClause":case"ElseifClause":case"ElseClause":if(0===e.body.length)return l(e,n),!0}return!1}!function(e){e[e.Leading=0]="Leading",e[e.Trailing=1]="Trailing",e[e.Dangling=2]="Dangling",e[e.DanglingStatement=3]="DanglingStatement"}(i||(i={})),t.attachComments=function(e,t){for(const n of e.comments){o(e,n);const r=n.precedingNode,i=n.enclosingNode,c=n.followingNode;a.hasNewLine(t.sourceText,a.locStart(n),{searchBackwards:!0})?p(i,n)||h(r,i,n)||d(r,i,c,n)||(c?s(c,n):r?f(r,n):u(i||e,n)):g(r,i,n)||m(r,i,n)||(r?f(r,n):c?s(c,n):u(i||e,n))}},t.injectShebang=function(e,t){if(!t.sourceText.startsWith("#!"))return;const n=t.sourceText.indexOf("\n"),r=t.sourceText.slice(0,n),a=t.sourceText.slice(2,n);e.comments.push({type:"Comment",loc:{start:{line:1,column:0},end:{line:1,column:n}},range:[0,n],raw:r,value:a})},t.printDanglingComments=function(e,t=!1){const n=e.getValue();if(!n||!n.attachedComments)return"";const a=[];return e.forEach(e=>{const t=e.getValue();t.commentType===i.Dangling&&a.push(t.raw)},"attachedComments"),0===a.length?"":t?r.join(r.hardline,a):r.indent(r.concat([r.hardline,r.join(r.hardline,a)]))},t.printDanglingStatementComments=function(e){const t=e.getValue();if(!t||!t.attachedComments)return"";const n=[];return e.forEach(e=>{const t=e.getValue();t.commentType===i.DanglingStatement&&(n.push(" "),n.push(t.raw))},"attachedComments"),0===n.length?"":r.concat(n)},t.printComments=function(e,t,n){const o=e.getValue(),c=n(e),s=o.attachedComments;if(!s||0===s.length)return c;const u=[],l=[c];return e.forEach(n=>{switch(n.getValue().commentType){case i.Leading:u.push(function(e,t){const n=e.getValue();if(n.raw.startsWith("--[["))return r.concat([n.raw,a.hasNewLine(t.sourceText,a.locEnd(n))?r.hardline:" "]);const i=[];return i.push(n.raw),i.push(r.hardline),a.isNextLineEmpty(t.sourceText,a.locEnd(n))&&i.push(r.hardline),r.concat(i)}(e,t));break;case i.Trailing:l.push(function(e,t){const n=e.getValue();if(a.hasNewLine(t.sourceText,a.locStart(n),{searchBackwards:!0})){const e=a.isPreviousLineEmpty(t.sourceText,a.locStart(n));return r.concat([r.hardline,e?r.hardline:"",n.raw])}if(n.raw.startsWith("--[["))return r.concat([" ",n.raw]);const i=[];return a.isNextLineEmpty(t.sourceText,a.locStart(n),{searchBackwards:!0})&&i.push(r.hardline),i.push(" "),i.push(n.raw),i.push(r.breakParent),r.lineSuffix(r.concat(i))}(e,t))}},"attachedComments"),r.concat(u.concat(l))}},function(e,t,n){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.Flat=0]="Flat",e[e.Break=1]="Break"}(r||(r={})),t.printDocToString=function(e,t){const n={options:t,indentation:0,currentLineLength:0,mode:r.Break,lineSuffixes:[],renderedText:""};return function e(t,n){if("string"==typeof t)n.renderedText+=t,n.currentLineLength+=t.length;else switch(t.type){case"concat":for(const r of t.parts)e(r,n);break;case"line":if(n.mode===r.Flat&&!t.hard){t.soft||(n.renderedText+=" ",n.currentLineLength+=1);break}if(n.lineSuffixes.length>0){const t=[...n.lineSuffixes];n.lineSuffixes.length=0;for(const r of t)e(r.content,n)}n.renderedText.length>0&&(n.renderedText=n.renderedText.replace(/[^\S\n]*$/,""));const a=n.options.useTabs?"\t".repeat(n.indentation):" ".repeat(n.indentation*n.options.indentCount);n.renderedText+="\n"+a,n.currentLineLength=a.length;break;case"indent":n.indentation++,e(t.content,n),n.indentation--;break;case"lineSuffix":n.lineSuffixes.push(t);break;case"group":const i=function e(t,n){function a(e){return n.currentLineLength+e.length<=n.options.lineWidth&&(n.currentLineLength+=e.length,!0)}if("string"==typeof t)return a(t);switch(t.type){case"concat":return t.parts.every(t=>e(t,n));case"indent":return n.indentation++,e(t.content,n)?(n.indentation--,!0):(n.indentation--,!1);case"group":return t.willBreak&&(n.mode=r.Break),e(t.content,n);case"line":return n.mode!==r.Flat||t.hard?(n.currentLineLength=n.indentation,!0):!!t.soft||a(" ");case"lineSuffix":return!0}return!1}(t,Object.assign({},n,{mode:r.Flat})),o=n.mode;!t.willBreak&&i?n.mode=r.Flat:n.mode=r.Break,e(t.content,n),n.mode=o}}(e,n),n.renderedText}},function(e,t,n){"use strict";function r(e,t,n){let r=!1;const a=e=>{if(t(e))r=!0;else if(!r&&"string"!=typeof e){switch(e.type){case"concat":e.parts.forEach(a);break;case"indent":case"group":case"lineSuffix":a(e.content)}n&&n(e)}};a(e)}function a(e){e.length>0&&(e[e.length-1].willBreak=!0)}Object.defineProperty(t,"__esModule",{value:!0}),t.willBreak=function(e){return function(e,t){let n=!1;return r(e,e=>!!t(e)&&(n=!0,!0)),n}(e,e=>{if("string"==typeof e)return!1;switch(e.type){case"line":if(e.hard)return!0;break;case"group":if(e.willBreak)return!0}return!1})},t.propagateBreaks=function(e){const t=[];r(e,e=>{if("string"==typeof e)return!1;switch(e.type){case"breakParent":a(t);break;case"group":t.push(e)}return!1},e=>{if("string"==typeof e)return!1;if("group"===e.type){const e=t.pop();e&&e.willBreak&&a(t)}return!1})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(0);t.FastPath=class{constructor(e){this.stack=[e]}getValue(){return this.stack[this.stack.length-1]}getNodeAtDepth(e){for(let t=this.stack.length-1;t>=0;t-=2){const n=this.stack[t];if(r.isNode(n)&&--e<0)return n}return null}getParent(e=0){return this.getNodeAtDepth(e+1)}call(e,t){const n=this.getValue(),r=this.stack.length;this.stack.push(t,n[t]);const a=e(this);return this.stack.length=r,a}forEach(e,t=null){let n=this.getValue();const r=this.stack.length;t&&(n=n[t],this.stack.push(n));for(let t=0;t{this.stack.push(n,t),r.push(e(this,n)),this.stack.length-=2}),this.stack.length=a,r}needsParens(){const e=this.getParent(),t=this.getValue();let n=!1;switch(t.type){case"FunctionDeclaration":case"Chunk":case"Identifier":case"BooleanLiteral":case"NilLiteral":case"NumericLiteral":case"StringLiteral":case"VarargLiteral":case"TableConstructorExpression":case"BinaryExpression":case"LogicalExpression":case"UnaryExpression":case"MemberExpression":case"IndexExpression":case"CallExpression":case"TableCallExpression":case"StringCallExpression":n=t.inParens||!1}return e&&"UnaryExpression"===t.type&&"UnaryExpression"===e.type&&(n=!0),n}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(6),a=n(2),i=n(5),o=n(3),c=n(0),s=n(1);function u(e,t,n){const r=[];return e.forEach(i=>{const o=[n(i)];c.isNextLineEmpty(t.sourceText,c.locEnd(i.getValue()))&&!function(e){const t=e.getParent(),n=e.getValue(),r=t.body;return r&&r[r.length-1]===n}(e)&&o.push(a.hardline),r.push(a.concat(o))}),a.join(a.hardline,r)}function l(e,t,n,r){const i=e.call(e=>u(e,t,n),r);return a.indent(a.concat([a.hardline,i]))}function f(e){return e.getValue().attachedComments?a.concat([o.printDanglingStatementComments(e),o.printDanglingComments(e)]):""}function p(e,t){const n=e.getValue();if("StringLiteral"!==n.type)throw new Error("printStringLiteral: Expected StringLiteral, got "+n.type);if(n.raw.startsWith("[[")||n.raw.startsWith("[="))return n.raw;const r=n.raw.slice(1,-1);let a=t.quotemark;const i=s.getStringQuotemark(a);return r.includes(i)&&(a="single"===a?"double":"single"),function(e,t){const n=s.getStringQuotemark(t),r=s.getAlternativeStringQuotemark("single"===t?"single":"double"),a=e.replace(/\\([\s\S])|(['"])/g,(e,t,a)=>t===r?t:a===n?"\\"+a:e);return n+a+n}(r,a)}function h(e,t,n){const r=function(e,t,n){const r=e.getValue();if(!r)return"";const s=[],h=r;switch(h.type){case"Chunk":return s.push(e.call(e=>u(e,t,n),"body")),s.push(o.printDanglingComments(e,!0)),(h.body.length||h.attachedComments)&&s.push(a.hardline),a.concat(s);case"LabelStatement":return a.concat(["::",e.call(n,"label"),"::"]);case"GotoStatement":return a.concat(["goto ",e.call(n,"label")]);case"BreakStatement":return"break";case"ReturnStatement":return s.push("return"),h.arguments.length>0&&(s.push(" "),s.push(a.join(", ",e.map(n,"arguments")))),a.concat(s);case"WhileStatement":return s.push("while "),s.push(e.call(n,"condition")),s.push(" do"),s.push(f(e)),h.body.length&&s.push(l(e,t,n,"body")),s.push(a.concat([a.hardline,"end"])),a.concat(s);case"DoStatement":return s.push("do"),s.push(f(e)),h.body.length&&s.push(l(e,t,n,"body")),s.push(a.concat([a.hardline,"end"])),a.concat(s);case"RepeatStatement":return s.push("repeat"),s.push(f(e)),h.body.length&&s.push(l(e,t,n,"body")),s.push(a.concat([a.hardline,"until "])),s.push(e.call(n,"condition")),a.concat(s);case"LocalStatement":case"AssignmentStatement":{const r=[];"LocalStatement"===h.type&&r.push("local ");const i=t.linebreakMultipleAssignments;r.push(a.indent(a.join(a.concat([",",i?a.hardline:a.line]),e.map(n,"variables"))));let o="";const c=[];h.init.length&&(o=" =",h.init.length>1?c.push(a.indent(a.join(a.concat([",",a.line]),e.map(n,"init")))):c.push(a.join(a.concat([",",a.line]),e.map(n,"init"))));const s=h.init.some(e=>null!=e&&"TableConstructorExpression"!==e.type&&"FunctionDeclaration"!==e.type);return a.group(a.concat([a.group(a.concat(r)),a.group(a.concat([o,s?a.indent(a.line):" ",a.concat(c)]))]))}case"CallStatement":return e.call(n,"expression");case"FunctionDeclaration":return h.isLocal&&s.push("local "),s.push("function"),h.identifier&&s.push(" ",e.call(n,"identifier")),s.push(a.concat(["(",a.group(a.indent(a.concat([a.softline,a.join(a.concat([",",a.line]),e.map(n,"parameters"))]))),")"])),s.push(f(e)),h.body.length&&s.push(l(e,t,n,"body")),s.push(a.hardline,"end"),a.concat(s);case"ForNumericStatement":return s.push("for "),s.push(e.call(n,"variable")),s.push(" = "),s.push(e.call(n,"start")),s.push(", "),s.push(e.call(n,"end")),h.step&&(s.push(", "),s.push(e.call(n,"step"))),s.push(" do"),s.push(f(e)),h.body.length&&s.push(l(e,t,n,"body")),s.push(a.concat([a.hardline,"end"])),a.concat(s);case"ForGenericStatement":return s.push("for "),s.push(a.join(", ",e.map(n,"variables"))),s.push(" in "),s.push(a.join(", ",e.map(n,"iterators"))),s.push(" do"),s.push(f(e)),h.body.length&&s.push(l(e,t,n,"body")),s.push(a.concat([a.hardline,"end"])),a.concat(s);case"IfStatement":const r=[];return e.forEach(e=>{r.push(n(e))},"clauses"),s.push(a.join(a.hardline,r)),s.push(a.concat([a.hardline,"end"])),a.concat(s);case"IfClause":return s.push(a.concat(["if ",a.group(a.concat([a.indent(a.concat([a.softline,e.call(n,"condition")])),a.softline]))," then"])),s.push(f(e)),h.body.length&&s.push(l(e,t,n,"body")),a.concat(s);case"ElseifClause":return s.push(a.concat(["elseif ",a.group(a.concat([a.indent(a.concat([a.softline,e.call(n,"condition")])),a.softline]))," then"])),s.push(f(e)),h.body.length&&s.push(l(e,t,n,"body")),a.concat(s);case"ElseClause":return s.push("else"),s.push(f(e)),h.body.length&&s.push(l(e,t,n,"body")),a.concat(s);case"BooleanLiteral":return h.raw;case"NilLiteral":return"nil";case"NumericLiteral":return h.raw;case"StringLiteral":return p(e,t);case"VarargLiteral":return"...";case"Identifier":return h.name;case"BinaryExpression":case"LogicalExpression":const d=e.getParent().type!==h.type&&h.left.type!==h.type&&h.right.type!==h.type,g=a.concat([h.operator,a.line,e.call(n,"right")]);return a.group(a.concat([e.call(n,"left"),a.indent(a.concat([" ",d?a.group(g):g]))]));case"UnaryExpression":return s.push(h.operator),"not"===h.operator&&s.push(" "),s.push(e.call(n,"argument")),a.concat(s);case"MemberExpression":return a.concat([e.call(n,"base"),h.indexer,e.call(n,"identifier")]);case"IndexExpression":return a.concat([e.call(n,"base"),"[",a.group(a.concat([a.indent(a.concat([a.softline,e.call(n,"index")])),a.softline])),"]"]);case"CallExpression":const m=e.map(n,"arguments");return a.concat([e.call(n,"base"),a.group(a.concat(["(",a.indent(a.concat([a.softline,a.join(a.concat([",",a.line]),m)])),a.softline,")"]),m.some(i.willBreak))]);case"TableCallExpression":return s.push(e.call(n,"base")),s.push(" "),s.push(e.call(n,"arguments")),a.concat(s);case"StringCallExpression":return s.push(e.call(n,"base")),s.push(" "),s.push(e.call(n,"argument")),a.concat(s);case"TableConstructorExpression":if(0===h.fields.length)return"{}";const y=[];let b=[];e.forEach(e=>{y.push(a.concat(b)),y.push(a.group(n(e))),b=[",",a.line]},"fields");const v=c.hasNewLineInRange(t.sourceText,h.range[0],h.range[1]);return a.group(a.concat(["{",a.indent(a.concat([a.softline,a.concat(y)])),a.softline,"}"]),v);case"TableKeyString":return a.concat([e.call(n,"key")," = ",e.call(n,"value")]);case"TableKey":return a.concat(["[",e.call(n,"key"),"]"," = ",e.call(n,"value")]);case"TableValue":return e.call(n,"value")}throw new Error("Unhandled AST node: "+h.type)}(e,t,n),s=[],h=e.needsParens();return h&&s.push("("),s.push(r),h&&s.push(")"),a.concat(s)}t.buildDocFromAst=function(e,t){const n=e=>o.printComments(e,t,e=>h(e,t,n)),a=n(new r.FastPath(e));return i.propagateBreaks(a),a}},function(e,t,n){"use strict";const r=n(3),a=n(7),i=n(4),o=n(1);t.luaParseDefaultOptions={locations:!0,ranges:!0},t.formatAst=function(e,t){const n=Object.assign({},o.defaultOptions,t);r.injectShebang(e,n),r.attachComments(e,n);const c=a.buildDocFromAst(e,n);return i.printDocToString(c,n)}},function(e,t,n){!function(e){var t,n,r,a=String.fromCharCode;function i(e){for(var t,n,r=[],a=0,i=e.length;a=55296&&t<=56319&&a=55296&&e<=57343)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value")}function c(e,t){return a(e>>t&63|128)}function s(e){if(0==(4294967168&e))return a(e);var t="";return 0==(4294965248&e)?t=a(e>>6&31|192):0==(4294901760&e)?(o(e),t=a(e>>12&15|224),t+=c(e,6)):0==(4292870144&e)&&(t=a(e>>18&7|240),t+=c(e,12),t+=c(e,6)),t+=a(63&e|128)}function u(){if(r>=n)throw Error("Invalid byte index");var e=255&t[r];if(r++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function l(){var e,a;if(r>n)throw Error("Invalid byte index");if(r==n)return!1;if(e=255&t[r],r++,0==(128&e))return e;if(192==(224&e)){if((a=(31&e)<<6|u())>=128)return a;throw Error("Invalid continuation byte")}if(224==(240&e)){if((a=(15&e)<<12|u()<<6|u())>=2048)return o(a),a;throw Error("Invalid continuation byte")}if(240==(248&e)&&(a=(7&e)<<18|u()<<12|u()<<6|u())>=65536&&a<=1114111)return a;throw Error("Invalid UTF-8 detected")}e.version="3.0.0",e.encode=function(e){for(var t=i(e),n=t.length,r=-1,a="";++r65535&&(i+=a((t-=65536)>>>10&1023|55296),t=56320|1023&t),i+=a(t);return i}(c)}}(t)},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){(function(e,n){var r,a,i;!function(o,c,s){"use strict";var u={function:!0,object:!0},l=u[typeof t]&&t&&!t.nodeType&&t,f=u[typeof e]&&e&&!e.nodeType&&e,p=l&&f&&"object"==typeof n&&n,h=f&&f.exports===l&&l;!p||p.global!==p&&p.window!==p&&p.self,a=[t],void 0===(i="function"==typeof(r=s)?r.apply(t,a):r)||(e.exports=i),l&&h&&s(f.exports)}(0,0,function(e){"use strict";var t,n,r;e.version="0.2.1";var a=e.defaultOptions={wait:!1,comments:!0,scope:!1,locations:!1,ranges:!1,onCreateNode:null,onCreateScope:null,onDestroyScope:null,onLocalDeclaration:null,luaVersion:"5.1",extendedIdentifiers:!1},i=1,o=2,c=4,s=8,u=16,l=32,f=64,p=128,h=256;e.tokenTypes={EOF:i,StringLiteral:o,Keyword:c,Identifier:s,NumericLiteral:u,Punctuator:l,BooleanLiteral:f,NilLiteral:p,VarargLiteral:h};var d=e.errors={unexpected:"unexpected %1 '%2' near '%3'",expected:"'%1' expected near '%2'",expectedToken:"%1 expected near '%2'",unfinishedString:"unfinished string near '%1'",malformedNumber:"malformed number near '%1'",invalidVar:"invalid left-hand side of assignment near '%1'",decimalEscapeTooLarge:"decimal escape too large near '%1'",invalidEscape:"invalid escape sequence near '%1'",hexadecimalDigitExpected:"hexadecimal digit expected near '%1'",braceExpected:"missing '%1' near '%2'",tooLargeCodepoint:"UTF-8 value too large near '%1'",unfinishedLongString:"unfinished long string (starting at line %1) near '%2'",unfinishedLongComment:"unfinished long comment (starting at line %1) near '%2'"},g=e.ast={labelStatement:function(e){return{type:"LabelStatement",label:e}},breakStatement:function(){return{type:"BreakStatement"}},gotoStatement:function(e){return{type:"GotoStatement",label:e}},returnStatement:function(e){return{type:"ReturnStatement",arguments:e}},ifStatement:function(e){return{type:"IfStatement",clauses:e}},ifClause:function(e,t){return{type:"IfClause",condition:e,body:t}},elseifClause:function(e,t){return{type:"ElseifClause",condition:e,body:t}},elseClause:function(e){return{type:"ElseClause",body:e}},whileStatement:function(e,t){return{type:"WhileStatement",condition:e,body:t}},doStatement:function(e){return{type:"DoStatement",body:e}},repeatStatement:function(e,t){return{type:"RepeatStatement",condition:e,body:t}},localStatement:function(e,t){return{type:"LocalStatement",variables:e,init:t}},assignmentStatement:function(e,t){return{type:"AssignmentStatement",variables:e,init:t}},callStatement:function(e){return{type:"CallStatement",expression:e}},functionStatement:function(e,t,n,r){return{type:"FunctionDeclaration",identifier:e,isLocal:n,parameters:t,body:r}},forNumericStatement:function(e,t,n,r,a){return{type:"ForNumericStatement",variable:e,start:t,end:n,step:r,body:a}},forGenericStatement:function(e,t,n){return{type:"ForGenericStatement",variables:e,iterators:t,body:n}},chunk:function(e){return{type:"Chunk",body:e}},identifier:function(e){return{type:"Identifier",name:e}},literal:function(e,t,n){return{type:e=e===o?"StringLiteral":e===u?"NumericLiteral":e===f?"BooleanLiteral":e===p?"NilLiteral":"VarargLiteral",value:t,raw:n}},tableKey:function(e,t){return{type:"TableKey",key:e,value:t}},tableKeyString:function(e,t){return{type:"TableKeyString",key:e,value:t}},tableValue:function(e){return{type:"TableValue",value:e}},tableConstructorExpression:function(e){return{type:"TableConstructorExpression",fields:e}},binaryExpression:function(e,t,n){return{type:"and"===e||"or"===e?"LogicalExpression":"BinaryExpression",operator:e,left:t,right:n}},unaryExpression:function(e,t){return{type:"UnaryExpression",operator:e,argument:t}},memberExpression:function(e,t,n){return{type:"MemberExpression",indexer:t,identifier:n,base:e}},indexExpression:function(e,t){return{type:"IndexExpression",base:e,index:t}},callExpression:function(e,t){return{type:"CallExpression",base:e,arguments:t}},tableCallExpression:function(e,t){return{type:"TableCallExpression",base:e,arguments:t}},stringCallExpression:function(e,t){return{type:"StringCallExpression",base:e,argument:t}},comment:function(e,t){return{type:"Comment",value:e,raw:t}}};function m(e){if(ie){var t=oe.pop();t.complete(),t.bless(e)}return n.onCreateNode&&n.onCreateNode(e),e}var y,b,v,x,S,C,E,k,w,L,A,T=Array.prototype.slice,V=(Object.prototype.toString,function(e,t){for(var n=0,r=e.length;n=r)return{type:i,value:"",line:E,lineStart:k,range:[y,y]};var e=t.charCodeAt(y),a=t.charCodeAt(y+1);if(C=y,function(e){return e>=65&&e<=90||e>=97&&e<=122||95===e||!!(n.extendedIdentifiers&&e>=128)}(e))return function(){var e,r;for(;J(t.charCodeAt(++y)););!function(e){switch(e.length){case 2:return"do"===e||"if"===e||"in"===e||"or"===e;case 3:return"and"===e||"end"===e||"for"===e||"not"===e;case 4:return"else"===e||"then"===e||("5.2"===n.luaVersion||"5.3"===n.luaVersion)&&"goto"===e;case 5:return"break"===e||"local"===e||"until"===e||"while"===e;case 6:return"elseif"===e||"repeat"===e||"return"===e;case 8:return"function"===e}return!1}(e=M(t.slice(C,y)))?"true"===e||"false"===e?(r=f,e="true"===e):"nil"===e?(r=p,e=null):r=s:r=c;return{type:r,value:e,line:E,lineStart:k,range:[C,y]}}();switch(e){case 39:case 34:return function(){var e,n=t.charCodeAt(y++),a=E,i=k,c=y,s="";for(;y=r||X(e))&&(s+=t.slice(c,y-1),D({},d.unfinishedString,s+String.fromCharCode(e)));return s+=M(t.slice(c,y-1)),{type:o,value:s,line:a,lineStart:i,lastLine:E,lastLineStart:k,range:[C,y]}}();case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return W();case 46:return $(a)?W():46===a?46===t.charCodeAt(y+2)?{type:h,value:"...",line:E,lineStart:k,range:[C,y+=3]}:_(".."):_(".");case 61:return _(61===a?"==":"=");case 62:return"5.3"===n.luaVersion&&62===a?_(">>"):_(61===a?">=":">");case 60:return"5.3"===n.luaVersion&&60===a?_("<<"):_(61===a?"<=":"<");case 126:if(61===a)return _("~=");if("5.1"===n.luaVersion||"5.2"===n.luaVersion)break;return _("~");case 58:return"5.2"!==n.luaVersion&&"5.3"!==n.luaVersion||58!==a?_(":"):_("::");case 91:return 91===a||61===a?function(){var e=E,t=k,n=R(!1);!1===n&&D(b,d.expected,"[",b.value);return{type:o,value:M(n),line:e,lineStart:t,lastLine:E,lastLineStart:k,range:[C,y]}}():_("[");case 47:return"5.3"===n.luaVersion&&47===a?_("//"):_("/");case 38:case 124:if("5.1"===n.luaVersion||"5.2"===n.luaVersion)break;case 42:case 94:case 37:case 44:case 123:case 125:case 93:case 40:case 41:case 59:case 35:case 45:case 43:return _(t.charAt(y))}return B(t.charAt(y))}function P(){var e=t.charCodeAt(y),n=t.charCodeAt(y+1);return!!X(e)&&(10===e&&13===n&&++y,13===e&&10===n&&++y,++E,k=++y,!0)}function j(){for(;y>6,128|63&e):e<65536?String.fromCharCode(224|e>>12,128|e>>6&63,128|63&e):e<1114112?String.fromCharCode(240|e>>18,128|e>>12&63,128|e>>6&63,128|63&e):null}function M(e){return e.replace(/[\ud800-\udbff][\udc00-\udfff]|[^\x00-\x7f]/g,function(e){return 1===e.length?F(e.charCodeAt(0)):F(65536+((1023&e.charCodeAt(0))<<10|1023&e.charCodeAt(1)))})}function _(e){return y+=e.length,{type:l,value:e,line:E,lineStart:k,range:[C,y]}}function W(){var e=t.charAt(y),n=t.charAt(y+1),r="0"===e&&"xX".indexOf(n||null)>=0?function(){var e,n,r,a,i=0,o=1,c=1;a=y+=2,H(t.charCodeAt(y))||D({},d.malformedNumber,t.slice(C,y));for(;H(t.charCodeAt(y));)++y;if(e=parseInt(t.slice(a,y),16),"."===t.charAt(y)){for(n=++y;H(t.charCodeAt(y));)++y;i=t.slice(n,y),i=n===y?0:parseInt(i,16)/Math.pow(16,y-n)}if("pP".indexOf(t.charAt(y)||null)>=0){for(++y,"+-".indexOf(t.charAt(y)||null)>=0&&(c="+"===t.charAt(y++)?1:-1),r=y,$(t.charCodeAt(y))||D({},d.malformedNumber,t.slice(C,y));$(t.charCodeAt(y));)++y;o=t.slice(r,y),o=Math.pow(2,o*c)}return(e+i)*o}():function(){for(;$(t.charCodeAt(y));)++y;if("."===t.charAt(y))for(++y;$(t.charCodeAt(y));)++y;if("eE".indexOf(t.charAt(y)||null)>=0)for(++y,"+-".indexOf(t.charAt(y)||null)>=0&&++y,$(t.charCodeAt(y))||D({},d.malformedNumber,t.slice(C,y));$(t.charCodeAt(y));)++y;return parseFloat(t.slice(C,y))}();return{type:u,value:r,line:E,lineStart:k,range:[C,y]}}function K(){var e=y;switch(t.charAt(y)){case"a":return++y,"";case"n":return++y,"\n";case"r":return++y,"\r";case"t":return++y,"\t";case"v":return++y,"\v";case"b":return++y,"\b";case"f":return++y,"\f";case"\r":case"\n":return P(),"\n";case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(;$(t.charCodeAt(y))&&y-e<3;)++y;var r=parseInt(t.slice(e,y),10);return r>255&&D({},d.decimalEscapeTooLarge,"\\"+r),String.fromCharCode(r);case"z":if("5.2"===n.luaVersion||"5.3"===n.luaVersion)return++y,j(),"";case"x":if("5.2"===n.luaVersion||"5.3"===n.luaVersion){if(H(t.charCodeAt(y+1))&&H(t.charCodeAt(y+2)))return y+=3,String.fromCharCode(parseInt(t.slice(e+1,y),16));D({},d.hexadecimalDigitExpected,"\\"+t.slice(e,y+2))}case"u":if("5.3"===n.luaVersion)return function(){var e=y++;for("{"!==t.charAt(y++)&&D({},d.braceExpected,"{","\\"+t.slice(e,y)),H(t.charCodeAt(y))||D({},d.hexadecimalDigitExpected,"\\"+t.slice(e,y));48===t.charCodeAt(y);)++y;for(var n=y;H(t.charCodeAt(y));)++y-n>6&&D({},d.tooLargeCodepoint,"\\"+t.slice(e,y));var r=t.charAt(y++);"}"!==r&&('"'===r||"'"===r?D({},d.braceExpected,"}","\\"+t.slice(e,y--)):D({},d.hexadecimalDigitExpected,"\\"+t.slice(e,y)));var a=parseInt(t.slice(n,y-1),16);return null===(a=F(a))&&D({},d.tooLargeCodepoint,"\\"+t.slice(e,y)),a}();default:"5.2"!==n.luaVersion&&"5.3"!==n.luaVersion||D({},d.invalidEscape,"\\"+t.slice(e,y+1));case"\\":case'"':case"'":return t.charAt(y++)}}function U(){C=y,y+=2;var e=t.charAt(y),a="",i=!1,o=y,c=k,s=E;if("["===e&&(!1===(a=R(!0))?a=e:i=!0),!i){for(;y")}function G(){v=b,b=x,x=I()}function Q(e){return e===b.value&&(G(),!0)}function q(e){e===b.value?G():D(b,d.expected,e,b.value)}function z(e){return 9===e||32===e||11===e||12===e}function X(e){return 10===e||13===e}function $(e){return e>=48&&e<=57}function H(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function J(e){return e>=65&&e<=90||e>=97&&e<=122||95===e||e>=48&&e<=57||!!(n.extendedIdentifiers&&e>=128)}function Y(e){if(i===e.type)return!0;if(c!==e.type)return!1;switch(e.value){case"else":case"elseif":case"end":case"until":return!0;default:return!1}}function Z(){var e=Array.apply(null,w[L++]);w.push(e),n.onCreateScope&&n.onCreateScope()}function ee(){w.pop();L--,n.onDestroyScope&&n.onDestroyScope()}function te(e){n.onLocalDeclaration&&n.onLocalDeclaration(e),-1===V(w[L],e)&&w[L].push(e)}function ne(e){te(e.name),re(e,!0)}function re(e,t){t||-1!==function(e,t,n){for(var r=0,a=e.length;r",b)}();case"if":return G(),function(){var e,t,r,a=[];ie&&(r=oe[oe.length-1],oe.push(r));e=be(),q("then"),n.scope&&Z();t=fe(),n.scope&&ee();a.push(m(g.ifClause(e,t))),ie&&(r=ce());for(;Q("elseif");)le(r),e=be(),q("then"),n.scope&&Z(),t=fe(),n.scope&&ee(),a.push(m(g.elseifClause(e,t))),ie&&(r=ce());Q("else")&&(ie&&(r=new se(v),oe.push(r)),n.scope&&Z(),t=fe(),n.scope&&ee(),a.push(m(g.elseClause(t))));return q("end"),m(g.ifStatement(a))}();case"return":return G(),function(){var e=[];if("end"!==b.value){var t=ye();for(null!=t&&e.push(t);Q(",");)t=be(),e.push(t);Q(";")}return m(g.returnStatement(e))}();case"function":return G(),ge(function(){var e,t,r;ie&&(r=ce());e=de(),n.scope&&(re(e,ae(e.name)),Z());for(;Q(".");)le(r),t=de(),e=m(g.memberExpression(e,".",t));Q(":")&&(le(r),t=de(),e=m(g.memberExpression(e,":",t)),n.scope&&te("self"));return e}());case"while":return G(),function(){var e=be();q("do"),n.scope&&Z();var t=fe();n.scope&&ee();return q("end"),m(g.whileStatement(e,t))}();case"for":return G(),function(){var e,t=de();n.scope&&(Z(),ne(t));if(Q("=")){var r=be();q(",");var a=be(),i=Q(",")?be():null;return q("do"),e=fe(),q("end"),n.scope&&ee(),m(g.forNumericStatement(t,r,a,i,e))}for(var o=[t];Q(",");)t=de(),n.scope&&ne(t),o.push(t);q("in");var c=[];do{var s=be();c.push(s)}while(Q(","));return q("do"),e=fe(),q("end"),n.scope&&ee(),m(g.forGenericStatement(o,c,e))}();case"repeat":return G(),function(){n.scope&&Z();var e=fe();q("until");var t=be();n.scope&&ee();return m(g.repeatStatement(t,e))}();case"break":return G(),m(g.breakStatement());case"do":return G(),function(){n.scope&&Z();var e=fe();n.scope&&ee();return q("end"),m(g.doStatement(e))}();case"goto":return G(),function(){b.value;var e=de();return m(g.gotoStatement(e))}()}return l===b.type&&Q("::")?function(){var e=b.value,t=de();n.scope&&(te("::"+e+"::"),re(t,!0));return q("::"),m(g.labelStatement(t))}():(ie&&oe.pop(),"5.2"!==n.luaVersion&&"5.3"!==n.luaVersion||!Q(";")?function(){var e,t,n=b;ie&&(t=ce());if(null==(e=xe()))return B(b);if(",=".indexOf(b.value)>=0){var r,a=[e],i=[];for(he(e);Q(",");)null==(r=xe())&&O("",b),he(r),a.push(r);q("=");do{r=be(),i.push(r)}while(Q(","));return le(t),m(g.assignmentStatement(a,i))}if(function(e){switch(e.type){case"CallExpression":case"TableCallExpression":case"StringCallExpression":return!0}return!1}(e))return le(t),m(g.callStatement(e));return B(n)}():void 0)}function he(e){(e.inParens||-1===["Identifier","MemberExpression","IndexExpression"].indexOf(e.type))&&D(b,d.invalidVar,b.value)}function de(){ue();var e=b.value;return s!==b.type&&O("",b),G(),m(g.identifier(e))}function ge(e,t){var r=[];if(q("("),!Q(")"))for(;;)if(s===b.type){var a=de();if(n.scope&&ne(a),r.push(a),Q(","))continue;if(Q(")"))break}else{if(h===b.type){r.push(Ce()),q(")");break}O(" or '...'",b)}var i=fe();return q("end"),n.scope&&ee(),t=t||!1,m(g.functionStatement(e,r,t,i))}function me(){for(var e,t,n=[];;){if(ue(),l===b.type&&Q("["))e=be(),q("]"),q("="),t=be(),n.push(m(g.tableKey(e,t)));else if(s===b.type)"="===x.value?(e=de(),G(),t=be(),n.push(m(g.tableKeyString(e,t)))):(t=be(),n.push(m(g.tableValue(t))));else{if(null==(t=ye())){oe.pop();break}n.push(m(g.tableValue(t)))}if(!(",;".indexOf(b.value)>=0))break;G()}return q("}"),m(g.tableConstructorExpression(n))}function ye(){return function e(t){var n,r,a=b.value;ie&&(r=ce());if(function(e){return l===e.type?"#-~".indexOf(e.value)>=0:c===e.type&&"not"===e.value}(b)){ue(),G();var i=e(10);null==i&&O("",b),n=m(g.unaryExpression(a,i))}null==n&&null==(n=Ce())&&(n=xe());if(null==n)return null;var o;for(;a=b.value,!(0===(o=l===b.type||c===b.type?ve(a):0)||o<=t);){"^"!==a&&".."!==a||o--,G();var s=e(o);null==s&&O("",b),ie&&oe.push(r),n=m(g.binaryExpression(a,n,s))}return n}(0)}function be(){var e=ye();if(null!=e)return e;O("",b)}function ve(e){var t=e.charCodeAt(0),n=e.length;if(1===n)switch(t){case 94:return 12;case 42:case 47:case 37:return 10;case 43:case 45:return 9;case 38:return 6;case 126:return 5;case 124:return 4;case 60:case 62:return 3}else if(2===n)switch(t){case 47:return 10;case 46:return 8;case 60:case 62:return"<<"===e||">>"===e?7:3;case 61:case 126:return 3;case 111:return 1}else if(97===t&&"and"===e)return 2;return 0}function xe(){var e,t,r,a,i;if(ie&&(r=ce()),s===b.type)t=b.value,e=de(),n.scope&&re(e,ae(t));else{if(!Q("("))return null;e=be(),q(")"),e.inParens=!0}for(;;)if(l===b.type)switch(b.value){case"[":le(r),G(),a=be(),q("]"),e=m(g.indexExpression(e,a));break;case".":le(r),G(),i=de(),e=m(g.memberExpression(e,".",i));break;case":":le(r),G(),i=de(),e=m(g.memberExpression(e,":",i)),le(r),e=Se(e);break;case"(":case"{":le(r),e=Se(e);break;default:return e}else{if(o!==b.type)break;le(r),e=Se(e)}return e}function Se(e){if(l===b.type)switch(b.value){case"(":G();var t=[],n=ye();for(null!=n&&t.push(n);Q(",");)n=be(),t.push(n);return q(")"),m(g.callExpression(e,t));case"{":ue(),G();var r=me();return m(g.tableCallExpression(e,r))}else if(o===b.type)return m(g.stringCallExpression(e,Ce()));O("function arguments",b)}function Ce(){var e,r=o|u|f|p|h,a=b.value,i=b.type;if(ie&&(e=ce()),i&r){le(e);var s=t.slice(b.range[0],b.range[1]);return G(),m(g.literal(i,a,s))}return c===i&&"function"===a?(le(e),G(),n.scope&&Z(),ge(null)):Q("{")?(le(e),me()):void 0}function Ee(n){return t+=String(n),r=t.length,e}function ke(e){void 0!==e&&Ee(e),t&&"#!"===t.substr(0,2)&&(t=t.replace(/^.*/,function(e){return e.replace(/./g," ")})),r=t.length,ie=n.locations||n.ranges,x=I();var a=function(){G(),ue(),n.scope&&Z();var e=fe();return n.scope&&ee(),i!==b.type&&B(b),ie&&!e.length&&(v=b),m(g.chunk(e))}();if(n.comments&&(a.comments=S),n.scope&&(a.globals=A),oe.length>0)throw new Error("Location tracking failed. This is most likely a bug in luaparse");return a}se.prototype.complete=function(){n.locations&&(this.loc.end.line=v.lastLine||v.line,this.loc.end.column=v.range[1]-(v.lastLineStart||v.lineStart)),n.ranges&&(this.range[1]=v.range[1])},se.prototype.bless=function(e){if(this.loc){var t=this.loc;e.loc={start:{line:t.start.line,column:t.start.column},end:{line:t.end.line,column:t.end.column}}}this.range&&(e.range=[this.range[0],this.range[1]])},e.parse=function(i,o){void 0===o&&"object"==typeof i&&(o=i,i=void 0);o||(o={});if(t=i||"",n=function(){for(var e,t,n=T.call(arguments),r={},a=0,i=n.length;a