You've already forked factorio-blueprint-editor
mirror of
https://github.com/teoxoy/factorio-blueprint-editor.git
synced 2025-11-23 22:15:01 +02:00
1441 lines
58 KiB
JavaScript
1441 lines
58 KiB
JavaScript
|
|
/* parser generated by jison 0.4.18 */
|
||
|
|
/*
|
||
|
|
Returns a Parser object of the following structure:
|
||
|
|
|
||
|
|
Parser: {
|
||
|
|
yy: {}
|
||
|
|
}
|
||
|
|
|
||
|
|
Parser.prototype: {
|
||
|
|
yy: {},
|
||
|
|
trace: function(),
|
||
|
|
symbols_: {associative list: name ==> number},
|
||
|
|
terminals_: {associative list: number ==> name},
|
||
|
|
productions_: [...],
|
||
|
|
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
|
||
|
|
table: [...],
|
||
|
|
defaultActions: {...},
|
||
|
|
parseError: function(str, hash),
|
||
|
|
parse: function(input),
|
||
|
|
|
||
|
|
lexer: {
|
||
|
|
EOF: 1,
|
||
|
|
parseError: function(str, hash),
|
||
|
|
setInput: function(input),
|
||
|
|
input: function(),
|
||
|
|
unput: function(str),
|
||
|
|
more: function(),
|
||
|
|
less: function(n),
|
||
|
|
pastInput: function(),
|
||
|
|
upcomingInput: function(),
|
||
|
|
showPosition: function(),
|
||
|
|
test_match: function(regex_match_array, rule_index),
|
||
|
|
next: function(),
|
||
|
|
lex: function(),
|
||
|
|
begin: function(condition),
|
||
|
|
popState: function(),
|
||
|
|
_currentRules: function(),
|
||
|
|
topState: function(),
|
||
|
|
pushState: function(condition),
|
||
|
|
|
||
|
|
options: {
|
||
|
|
ranges: boolean (optional: true ==> token location info will include a .range[] member)
|
||
|
|
flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
|
||
|
|
backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
|
||
|
|
},
|
||
|
|
|
||
|
|
performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
|
||
|
|
rules: [...],
|
||
|
|
conditions: {associative list: name ==> set},
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
token location info (@$, _$, etc.): {
|
||
|
|
first_line: n,
|
||
|
|
last_line: n,
|
||
|
|
first_column: n,
|
||
|
|
last_column: n,
|
||
|
|
range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
the parseError function receives a 'hash' object with these members for lexer and parser errors: {
|
||
|
|
text: (matched text)
|
||
|
|
token: (the produced terminal token, if any)
|
||
|
|
line: (yylineno)
|
||
|
|
}
|
||
|
|
while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
|
||
|
|
loc: (yylloc)
|
||
|
|
expected: (string describing the set of expected tokens)
|
||
|
|
recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
|
||
|
|
}
|
||
|
|
*/
|
||
|
|
var lua_parser = (function(){
|
||
|
|
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[7,20,27,29,30,31,32,33,34,36,40,44,47,48,50,52],$V1=[2,2],$V2=[7,30,33,47,48,50,52],$V3=[2,17],$V4=[1,18],$V5=[1,7],$V6=[1,9],$V7=[1,10],$V8=[1,11],$V9=[1,12],$Va=[1,13],$Vb=[1,14],$Vc=[1,17],$Vd=[7,30,33,50,52],$Ve=[2,3],$Vf=[2,10],$Vg=[1,24],$Vh=[2,14],$Vi=[2,21],$Vj=[1,40],$Vk=[1,33],$Vl=[1,34],$Vm=[1,35],$Vn=[1,36],$Vo=[1,38],$Vp=[1,41],$Vq=[1,42],$Vr=[1,43],$Vs=[1,44],$Vt=[1,45],$Vu=[20,27,29,30,31,32,33,34,36,40,44,47,48],$Vv=[2,8],$Vw=[7,14,20,22,27,29,30,31,32,33,34,36,40,43,44,47,48,50,52,53,55,57,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,80,81,85,86],$Vx=[2,13],$Vy=[2,41],$Vz=[1,61],$VA=[1,58],$VB=[1,60],$VC=[1,63],$VD=[1,59],$VE=[7,14,20,22,25,27,29,30,31,32,33,34,36,38,40,43,44,47,48,50,52,53,55,57,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,80,81,85,86],$VF=[2,91],$VG=[7,14,30,33,50,52],$VH=[7,14,20,27,29,30,31,32,33,34,36,40,44,47,48,50,52],$VI=[7,14,20,25,27,29,30,31,32,33,34,36,38,40,44,47,48,50,52],$VJ=[1,79],$VK=[1,80],$VL=[1,81],$VM=[1,82],$VN=[1,83],$VO=[1,84],$VP=[1,85],$VQ=[1,86],$VR=[1,87],$VS=[1,88],$VT=[1,89],$VU=[1,90],$VV=[1,91],$VW=[1,92],$VX=[1,93],$VY=[7,14,20,22,27,29,30,31,32,33,34,36,38,40,44,47,48,50,52,53,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,81,86],$VZ=[1,104],$V_=[1,105],$V$=[7,14,20,22,27,29,30,31,32,33,34,36,38,40,43,44,47,48,50,52,53,55,57,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,80,81,85,86],$V01=[30,50,52],$V11=[20,43,55],$V21=[1,123],$V31=[7,14,20,22,27,29,30,31,32,33,34,36,38,40,44,47,48,50,52],$V41=[2,40],$V51=[7,14,20,22,27,29,30,31,32,33,34,36,38,40,44,47,48,50,52,53,62,63,68,69,70,71,72,73,74,75,76,81,86],$V61=[7,14,20,22,27,29,30,31,32,33,34,36,38,40,44,47,48,50,52,53,62,63,64,65,67,68,69,70,71,72,73,74,75,76,81,86],$V71=[14,38,81],$V81=[25,38,39],$V91=[7,14,20,22,27,29,30,31,32,33,34,36,38,40,44,47,48,50,52,53,69,70,71,72,73,74,75,76,81,86],$Va1=[1,169],$Vb1=[20,40,44,56,57,58,59,61,63,77,78,79,80,85],$Vc1=[22,38],$Vd1=[1,192];
|
||
|
|
var parser = {trace: function trace() { },
|
||
|
|
yy: {},
|
||
|
|
symbols_: {"error":2,"script":3,"indent":4,"chunk":5,"unindent":6,"EOF":7,"funcindent":8,"funcunindent":9,"block":10,"loopblock":11,"setinloop":12,"semi":13,";":14,"statlist":15,"laststat":16,"prefixexp":17,"var":18,"functioncall":19,"(":20,"exp":21,")":22,"stat":23,"varlist":24,"=":25,"explist":26,"LOCAL":27,"namelist":28,"DO":29,"END":30,"WHILE":31,"REPEAT":32,"UNTIL":33,"IF":34,"conds":35,"FOR":36,"namelist_setlocals":37,",":38,"IN":39,"FUNCTION":40,"funcname":41,"funcbody":42,":":43,"NAME":44,"mfuncbody":45,"name_setlocals":46,"RETURN":47,"BREAK":48,"condlist":49,"ELSE":50,"cond":51,"ELSEIF":52,"THEN":53,"arglist":54,".":55,"NUMBER":56,"STRING":57,"TRUE":58,"FALSE":59,"tableconstructor":60,"NIL":61,"+":62,"-":63,"*":64,"/":65,"^":66,"%":67,"..":68,"<":69,">":70,"<=":71,">=":72,"==":73,"~=":74,"AND":75,"OR":76,"NOT":77,"#":78,"...":79,"{":80,"}":81,"fieldlist":82,"fieldsepend":83,"addself":84,"[":85,"]":86,"args":87,"field":88,"fieldsep":89,"$accept":0,"$end":1},
|
||
|
|
terminals_: {2:"error",7:"EOF",14:";",20:"(",22:")",25:"=",27:"LOCAL",29:"DO",30:"END",31:"WHILE",32:"REPEAT",33:"UNTIL",34:"IF",36:"FOR",38:",",39:"IN",40:"FUNCTION",43:":",44:"NAME",47:"RETURN",48:"BREAK",50:"ELSE",52:"ELSEIF",53:"THEN",55:".",56:"NUMBER",57:"STRING",58:"TRUE",59:"FALSE",61:"NIL",62:"+",63:"-",64:"*",65:"/",66:"^",67:"%",68:"..",69:"<",70:">",71:"<=",72:">=",73:"==",74:"~=",75:"AND",76:"OR",77:"NOT",78:"#",79:"...",80:"{",81:"}",85:"[",86:"]"},
|
||
|
|
productions_: [0,[3,4],[4,0],[6,0],[8,1],[9,1],[10,3],[11,4],[12,0],[13,1],[13,0],[5,1],[5,3],[17,1],[17,1],[17,3],[15,3],[15,0],[23,3],[23,4],[23,2],[23,1],[23,3],[23,5],[23,4],[23,3],[23,11],[23,13],[23,9],[23,3],[23,5],[23,4],[16,2],[16,1],[16,1],[35,1],[35,3],[49,1],[49,3],[51,3],[24,3],[24,1],[26,3],[26,1],[37,3],[37,1],[28,3],[28,1],[46,1],[54,3],[54,1],[41,3],[41,1],[21,1],[21,1],[21,1],[21,1],[21,1],[21,1],[21,1],[21,2],[21,3],[21,3],[21,3],[21,3],[21,3],[21,3],[21,3],[21,3],[21,3],[21,3],[21,3],[21,3],[21,3],[21,3],[21,3],[21,2],[21,2],[21,2],[21,1],[60,2],[60,4],[42,6],[42,7],[42,7],[42,9],[45,7],[45,8],[45,8],[45,10],[84,0],[18,1],[18,4],[18,3],[19,2],[19,4],[87,3],[87,2],[87,1],[87,1],[82,1],[82,3],[88,1],[88,3],[88,5],[89,1],[89,1],[83,1],[83,1],[83,0]],
|
||
|
|
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
|
||
|
|
/* this == yyval */
|
||
|
|
|
||
|
|
var $0 = $$.length - 1;
|
||
|
|
switch (yystate) {
|
||
|
|
case 1:
|
||
|
|
|
||
|
|
return "var tmp;\n" +
|
||
|
|
"var G = lua_newtable2(lua_core);\n" +
|
||
|
|
"for (var i in lua_libs) {\n" +
|
||
|
|
" G.str[i] = lua_newtable2(lua_libs[i]);\n" +
|
||
|
|
"}\n" +
|
||
|
|
"G.str['arg'] = lua_newtable();\n" +
|
||
|
|
"G.str['_G'] = G;\n" +
|
||
|
|
"G.str['module'] = function (name) {\n" +
|
||
|
|
" lua_createmodule(G, name, slice(arguments, 1));\n" +
|
||
|
|
"};\n" +
|
||
|
|
"G.str['require'] = function (name) {\n" +
|
||
|
|
" lua_require(G, name);\n" +
|
||
|
|
"};\n" +
|
||
|
|
"G.str['package'].str['seeall'] = function (module) {\n" +
|
||
|
|
" if (!module.metatable) {\n" +
|
||
|
|
" module.metatable = lua_newtable();\n" +
|
||
|
|
" }\n" +
|
||
|
|
" module.metatable.str['__index'] = G;\n" +
|
||
|
|
"};\n" +
|
||
|
|
"{\n" +
|
||
|
|
$$[$0-2].simple_form + "\n" +
|
||
|
|
"};\n" +
|
||
|
|
"return [G];";
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 2:
|
||
|
|
|
||
|
|
var localsCopy = {}
|
||
|
|
for (var i in locals) {
|
||
|
|
localsCopy[i] = locals[i];
|
||
|
|
}
|
||
|
|
stack.push({locals: localsCopy, blockId: blockId, inLoop: inLoop});
|
||
|
|
|
||
|
|
indentLevel++;
|
||
|
|
blockIdMax++;
|
||
|
|
this.$ = blockId = blockIdMax;
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 3:
|
||
|
|
|
||
|
|
var stackData = stack.pop();
|
||
|
|
indentLevel--;
|
||
|
|
locals = stackData.locals;
|
||
|
|
inLoop = stackData.inLoop;
|
||
|
|
if (!inLoop) {
|
||
|
|
functionBlockAdded = false;
|
||
|
|
}
|
||
|
|
this.$ = blockId = stackData.blockId;
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 4:
|
||
|
|
|
||
|
|
functionBlockAdded = false;
|
||
|
|
inLoop = false;
|
||
|
|
this.$ = $$[$0];
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 5:
|
||
|
|
|
||
|
|
functionBlockAdded = true;
|
||
|
|
this.$ = $$[$0];
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 6:
|
||
|
|
this.$ = $$[$0-1]
|
||
|
|
break;
|
||
|
|
case 7:
|
||
|
|
|
||
|
|
// if a function is declared inside of a loop, there are some differences
|
||
|
|
// with how variables behave due to the difference in scoping in JS and Lua
|
||
|
|
// by wrapping a loop block in a function call, we resolve these problems, but it
|
||
|
|
// is only necessary for situations where functions are declared inside of a loop
|
||
|
|
|
||
|
|
if (functionBlockAdded) {
|
||
|
|
this.$ = {
|
||
|
|
block: $$[$0-1].varfix_form || $$[$0-1].simple_form,
|
||
|
|
use_function_block: true
|
||
|
|
};
|
||
|
|
} else {
|
||
|
|
this.$ = {block: $$[$0-1].simple_form};
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 8:
|
||
|
|
inLoop = true;
|
||
|
|
break;
|
||
|
|
case 9: case 10: case 105: case 106: case 107: case 108:
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 11:
|
||
|
|
|
||
|
|
this.$ = {simple_form: indentStatlist($$[$0].simple_form)};
|
||
|
|
if ($$[$0].varfix_form) {
|
||
|
|
this.$.varfix_form = indentStatlist($$[$0].varfix_form);
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 12:
|
||
|
|
|
||
|
|
this.$ = {simple_form: indentStatlist($$[$0-2].simple_form, $$[$0-1].simple_form)};
|
||
|
|
if ($$[$0-2].varfix_form || $$[$0-1].varfix_form) {
|
||
|
|
this.$.varfix_form = indentStatlist(
|
||
|
|
$$[$0-2].varfix_form || $$[$0-2].simple_form, $$[$0-1].varfix_form || $$[$0-1].simple_form);
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 13:
|
||
|
|
|
||
|
|
if ($$[$0].access) {
|
||
|
|
this.$ = {single: "lua_tableget(" + $$[$0].prefixexp + ", " + $$[$0].access + ")", single_tableget: $$[$0]};
|
||
|
|
} else {
|
||
|
|
this.$ = {single: $$[$0].prefixexp};
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 14:
|
||
|
|
this.$ = {single: $$[$0] + "[0]", endmulti: $$[$0]};
|
||
|
|
break;
|
||
|
|
case 15:
|
||
|
|
this.$ = {single: "(" + $$[$0-1].single + ")", simple_form: $$[$0-1].simple_form};
|
||
|
|
break;
|
||
|
|
case 16:
|
||
|
|
|
||
|
|
if ($$[$0].simple_form) {
|
||
|
|
this.$ = {simple_form: $$[$0-2].simple_form + "\n" + $$[$0].simple_form};
|
||
|
|
if ($$[$0-2].varfix_form || $$[$0].varfix_form) {
|
||
|
|
this.$.varfix_form = ($$[$0-2].varfix_form || $$[$0-2].simple_form) + "\n" + ($$[$0].varfix_form || $$[$0].simple_form);
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
this.$ = $$[$0-2];
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 17:
|
||
|
|
this.$ = {simple_form: ""};
|
||
|
|
break;
|
||
|
|
case 18:
|
||
|
|
|
||
|
|
var tmp;
|
||
|
|
if ($$[$0-2].length == 1) {
|
||
|
|
// avoid tmp entirely for certain situations
|
||
|
|
if ($$[$0].exps.length == 1) {
|
||
|
|
if ($$[$0-2][0].access) {
|
||
|
|
tmp = "lua_tableset(" + $$[$0-2][0].prefixexp + ", " + $$[$0-2][0].access + ", " + $$[$0].exps[0] + ");";
|
||
|
|
} else {
|
||
|
|
tmp = $$[$0-2][0].prefixexp + " = " + $$[$0].exps[0] + ";";
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
if ($$[$0-2][0].access) {
|
||
|
|
tmp = "lua_tableset(" + $$[$0-2][0].prefixexp + ", " + $$[$0-2][0].access + ", " + getTempDecl($$[$0]) + "[0]);";
|
||
|
|
} else {
|
||
|
|
tmp = $$[$0-2][0].prefixexp + " = " + getTempDecl($$[$0]) + "[0];";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
tmp = "tmp = " + getTempDecl($$[$0]) + "; ";
|
||
|
|
for (var i = 0; i < $$[$0-2].length; i++) {
|
||
|
|
if ($$[$0-2][i].access) {
|
||
|
|
tmp += "lua_tableset(" + $$[$0-2][i].prefixexp + ", " + $$[$0-2][i].access + ", tmp[" + i + "]); ";
|
||
|
|
} else {
|
||
|
|
tmp += $$[$0-2][i].prefixexp + " = tmp[" + i + "]; ";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
tmp += "tmp = null;";
|
||
|
|
}
|
||
|
|
this.$ = {simple_form: tmp};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 19:
|
||
|
|
|
||
|
|
var tmp;
|
||
|
|
$$[$0-2] = setLocals($$[$0-2]);
|
||
|
|
if ($$[$0-2].length == 1) {
|
||
|
|
// avoid tmp entirely for certain situations
|
||
|
|
if ($$[$0].exps.length == 1) {
|
||
|
|
tmp = "var " + $$[$0-2][0] + " = " + $$[$0].exps[0] + ";";
|
||
|
|
} else {
|
||
|
|
tmp = "var " + $$[$0-2][0] + " = " + getTempDecl($$[$0]) + "[0];";
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
tmp = "tmp = " + getTempDecl($$[$0]) + "; ";
|
||
|
|
for (var i = 0; i < $$[$0-2].length; i++) {
|
||
|
|
tmp += "var " + $$[$0-2][i] + " = tmp[" + i + "]; ";
|
||
|
|
}
|
||
|
|
tmp += "tmp = null;";
|
||
|
|
}
|
||
|
|
this.$ = {simple_form: tmp};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 20:
|
||
|
|
this.$ = {simple_form: "var " + setLocals($$[$0]).join(", ") + ";"};
|
||
|
|
break;
|
||
|
|
case 21:
|
||
|
|
this.$ = {simple_form: $$[$0] + ";"};
|
||
|
|
break;
|
||
|
|
case 22:
|
||
|
|
|
||
|
|
this.$ = {simple_form: "// do\n" + $$[$0-1].simple_form + "\n// end"};
|
||
|
|
if ($$[$0-1].varfix_form) {
|
||
|
|
this.$.varfix_form = "// do\n" + $$[$0-1].varfix_form + "\n// end";
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 23:
|
||
|
|
this.$ = {simple_form: "while (" + getIfExp($$[$0-3]) + ") " + autoFunctionBlock($$[$0-1])};
|
||
|
|
break;
|
||
|
|
case 24:
|
||
|
|
this.$ = {simple_form: "do " + autoFunctionBlock($$[$0-2]) + " while (!(" + getIfExp($$[$0]) + "));"};
|
||
|
|
break;
|
||
|
|
case 25:
|
||
|
|
|
||
|
|
this.$ = $$[$0-1]
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 26:
|
||
|
|
|
||
|
|
if ($$[$0-8].length != 1) {
|
||
|
|
throw new Error("Only one value allowed in for..= loop");
|
||
|
|
}
|
||
|
|
if ($$[$0-2].use_function_block) {
|
||
|
|
this.$ = {simple_form: "var var_" + $$[$0-9] + " = " + autoAssertFloat($$[$0-6]) + ", " +
|
||
|
|
"stop_" + $$[$0-9] + " = " + autoAssertFloat($$[$0-4]) + ";\n" +
|
||
|
|
"for (; var_" + $$[$0-9] + " <= stop_" + $$[$0-9] + "; var_" + $$[$0-9] + "++) (function() {\n" +
|
||
|
|
" var " + $$[$0-8][0] + " = var_" + $$[$0-9] + ";\n" +
|
||
|
|
$$[$0-2].block + "\n" +
|
||
|
|
"})();"};
|
||
|
|
} else {
|
||
|
|
this.$ = {simple_form: "var var_" + $$[$0-9] + " = " + autoAssertFloat($$[$0-6]) + ", " +
|
||
|
|
"stop_" + $$[$0-9] + " = " + autoAssertFloat($$[$0-4]) + ";\n" +
|
||
|
|
"for (; var_" + $$[$0-9] + " <= stop_" + $$[$0-9] + "; var_" + $$[$0-9] + "++) {\n" +
|
||
|
|
" var " + $$[$0-8][0] + " = var_" + $$[$0-9] + ";\n" +
|
||
|
|
$$[$0-2].block +
|
||
|
|
"\n}"};
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 27:
|
||
|
|
|
||
|
|
if ($$[$0-10].length != 1) {
|
||
|
|
throw new Error("Only one value allowed in for..= loop");
|
||
|
|
}
|
||
|
|
|
||
|
|
var tmp = "var var_" + $$[$0-11] + " = " + autoAssertFloat($$[$0-8]) + ", " +
|
||
|
|
"stop_" + $$[$0-11] + " = " + autoAssertFloat($$[$0-6]) + ", " +
|
||
|
|
"step_" + $$[$0-11] + " = " + autoAssertFloat($$[$0-4]) + ";\n" +
|
||
|
|
"for (; step_" + $$[$0-11] + " > 0 ? var_" + $$[$0-11] + " <= stop_" + $$[$0-11] + " : var_" + $$[$0-11] + " >= stop_" + $$[$0-11] + "; var_" + $$[$0-11] + " += step_" + $$[$0-11] + ") ";
|
||
|
|
if ($$[$0-2].use_function_block) {
|
||
|
|
tmp += "(function () {\n";
|
||
|
|
} else {
|
||
|
|
tmp += "{\n";
|
||
|
|
}
|
||
|
|
tmp += " var " + $$[$0-10][0] + " = var_" + $$[$0-11] + ";\n" +
|
||
|
|
$$[$0-2].block + "\n";
|
||
|
|
if ($$[$0-2].use_function_block) {
|
||
|
|
tmp += "\n})();";
|
||
|
|
} else {
|
||
|
|
tmp += "\n}";
|
||
|
|
}
|
||
|
|
this.$ = {simple_form: tmp};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 28:
|
||
|
|
|
||
|
|
var tmp;
|
||
|
|
tmp = "tmp = " + getTempDecl($$[$0-4]) + ";\n" +
|
||
|
|
"var f_" + $$[$0-7] + " = tmp[0], " +
|
||
|
|
"s_" + $$[$0-7] + " = tmp[1], " +
|
||
|
|
"var_" + $$[$0-7] + " = tmp[2];\n";
|
||
|
|
|
||
|
|
if ($$[$0-6].length == 1 && !$$[$0-2].use_function_block) {
|
||
|
|
// simple form of this loop that works in certain situations
|
||
|
|
tmp += "tmp = null;\n" +
|
||
|
|
"while ((var_" + $$[$0-7] + " = lua_call(f_" + $$[$0-7] + ", [s_" + $$[$0-7] + ", var_" + $$[$0-7] + "])[0]) != null) {\n" +
|
||
|
|
" var " + $$[$0-6][0] + " = var_" + $$[$0-7] + ";\n" +
|
||
|
|
$$[$0-2].block +
|
||
|
|
"\n}";
|
||
|
|
} else {
|
||
|
|
tmp += "while ((tmp = lua_call(f_" + $$[$0-7] + ", [s_" + $$[$0-7] + ", var_" + $$[$0-7] + "]))[0] != null) ";
|
||
|
|
if ($$[$0-2].use_function_block) {
|
||
|
|
tmp += "(function () {\n";
|
||
|
|
} else {
|
||
|
|
tmp += "{\n";
|
||
|
|
}
|
||
|
|
tmp += " var_" + $$[$0-7] + " = tmp[0];\n" +
|
||
|
|
" var " + $$[$0-6][0] + " = var_" + $$[$0-7];
|
||
|
|
for (var i = 1; i < $$[$0-6].length; i++) {
|
||
|
|
tmp += ", " + $$[$0-6][i] + " = tmp[" + i + "]";
|
||
|
|
}
|
||
|
|
tmp += ";\n" +
|
||
|
|
" tmp = null;\n" +
|
||
|
|
$$[$0-2].block + "\n";
|
||
|
|
if ($$[$0-2].use_function_block) {
|
||
|
|
tmp += "})();";
|
||
|
|
} else {
|
||
|
|
tmp += "}";
|
||
|
|
}
|
||
|
|
tmp += "\ntmp = null;";
|
||
|
|
}
|
||
|
|
this.$ = {simple_form: tmp};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 29:
|
||
|
|
|
||
|
|
var tmp = getLocal($$[$0-1][0], "G.str['" + $$[$0-1][0] + "']");
|
||
|
|
if ($$[$0-1].length > 1) {
|
||
|
|
for (var i = 1; i < $$[$0-1].length - 1; i++) {
|
||
|
|
tmp = "lua_tableget(" + tmp + ", '" + $$[$0-1][i] + "')";
|
||
|
|
}
|
||
|
|
this.$ = {simple_form: "lua_tableset(" + tmp + ", '" + $$[$0-1][i] + "', " + $$[$0] + ")"};
|
||
|
|
} else {
|
||
|
|
this.$ = {simple_form: tmp + " = " + $$[$0]};
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 30:
|
||
|
|
|
||
|
|
var tmp = getLocal($$[$0-3][0], "G.str['" + $$[$0-3][0] + "']");
|
||
|
|
for (var i = 1; i < $$[$0-3].length; i++) {
|
||
|
|
tmp = "lua_tableget(" + tmp + ", '" + $$[$0-3][i] + "')";
|
||
|
|
}
|
||
|
|
this.$ = {simple_form: "lua_tableset(" + tmp + ", '" + $$[$0-1] + "', " + $$[$0] + ")"};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 31:
|
||
|
|
|
||
|
|
this.$ = {simple_form: "var " + $$[$0-1] + " = " + $$[$0] + ";"};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 32:
|
||
|
|
|
||
|
|
this.$ = {
|
||
|
|
simple_form: "return " + getTempDecl($$[$0]) + ";",
|
||
|
|
varfix_form: "throw new ReturnValues(" + getTempDecl($$[$0]) + ");"
|
||
|
|
};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 33:
|
||
|
|
|
||
|
|
this.$ = {
|
||
|
|
simple_form: "return [];",
|
||
|
|
varfix_form: "throw new ReturnValues();"
|
||
|
|
};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 34:
|
||
|
|
|
||
|
|
this.$ = {
|
||
|
|
simple_form: "break;",
|
||
|
|
varfix_form: "return;"
|
||
|
|
};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 35: case 37:
|
||
|
|
|
||
|
|
this.$ = $$[$0];
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 36:
|
||
|
|
|
||
|
|
this.$ = {simple_form: $$[$0-2].simple_form + " else {\n" + $$[$0].simple_form + "\n}"};
|
||
|
|
if ($$[$0-2].varfix_form || $$[$0].varfix_form) {
|
||
|
|
this.$.varfix_form = ($$[$0-2].varfix_form || $$[$0-2].simple_form) + " else {\n" + ($$[$0].varfix_form || $$[$0].simple_form) + "\n}";
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 38:
|
||
|
|
|
||
|
|
this.$ = {simple_form: $$[$0-2].simple_form + " else " + $$[$0].simple_form};
|
||
|
|
if ($$[$0-2].varfix_form || $$[$0].varfix_form) {
|
||
|
|
this.$.varfix_form = ($$[$0-2].varfix_form || $$[$0-2].simple_form) + " else " + ($$[$0].varfix_form || $$[$0].simple_form)
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 39:
|
||
|
|
|
||
|
|
this.$ = {simple_form: "if (" + getIfExp($$[$0-2]) + ") {\n" + $$[$0].simple_form + "\n}"};
|
||
|
|
if ($$[$0].varfix_form) {
|
||
|
|
this.$.varfix_form = "if (" + getIfExp($$[$0-2]) + ") {\n" + $$[$0].varfix_form + "\n}";
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 40: case 46: case 51:
|
||
|
|
this.$ = $$[$0-2].concat([$$[$0]]);
|
||
|
|
break;
|
||
|
|
case 41: case 47: case 52:
|
||
|
|
this.$ = [$$[$0]];
|
||
|
|
break;
|
||
|
|
case 42:
|
||
|
|
this.$ = {exps: $$[$0-2].exps.concat([$$[$0].single]), endmulti: $$[$0].endmulti};
|
||
|
|
break;
|
||
|
|
case 43:
|
||
|
|
this.$ = {exps: [$$[$0].single], endmulti: $$[$0].endmulti};
|
||
|
|
break;
|
||
|
|
case 44:
|
||
|
|
this.$ = $$[$0-2].concat([setLocal($$[$0])]);
|
||
|
|
break;
|
||
|
|
case 45:
|
||
|
|
this.$ = [setLocal($$[$0])];
|
||
|
|
break;
|
||
|
|
case 48:
|
||
|
|
this.$ = setLocal($$[$0]);
|
||
|
|
break;
|
||
|
|
case 49:
|
||
|
|
this.$ = $$[$0-2].concat([setLocal($$[$0], "_" + $$[$0])]);
|
||
|
|
break;
|
||
|
|
case 50:
|
||
|
|
this.$ = [setLocal($$[$0], "_" + $$[$0])];
|
||
|
|
break;
|
||
|
|
case 53:
|
||
|
|
this.$ = {single: $$[$0], is_number: true};
|
||
|
|
break;
|
||
|
|
case 54: case 57:
|
||
|
|
this.$ = {single: $$[$0]};
|
||
|
|
break;
|
||
|
|
case 55:
|
||
|
|
this.$ = {single: 'true', simple_form: 'true'};
|
||
|
|
break;
|
||
|
|
case 56:
|
||
|
|
this.$ = {single: 'false', simple_form: 'false'};
|
||
|
|
break;
|
||
|
|
case 58:
|
||
|
|
this.$ = {single: 'null', simple_form: 'null'};
|
||
|
|
break;
|
||
|
|
case 59: case 100:
|
||
|
|
this.$ = $$[$0];
|
||
|
|
break;
|
||
|
|
case 60:
|
||
|
|
|
||
|
|
this.$ = {single: $$[$0]};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 61:
|
||
|
|
|
||
|
|
if ($$[$0-2].is_number && $$[$0].is_number) {
|
||
|
|
this.$ = {single: '(' + $$[$0-2].single + ' + ' + $$[$0].single + ')', is_number: true};
|
||
|
|
} else {
|
||
|
|
this.$ = {single: 'lua_add(' + $$[$0-2].single + ', ' + $$[$0].single + ')'};
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 62:
|
||
|
|
|
||
|
|
if ($$[$0-2].is_number && $$[$0].is_number) {
|
||
|
|
this.$ = {single: '(' + $$[$0-2].single + ' - ' + $$[$0].single + ')', is_number: true};
|
||
|
|
} else {
|
||
|
|
this.$ = {single: 'lua_subtract(' + $$[$0-2].single + ', ' + $$[$0].single + ')'};
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 63:
|
||
|
|
|
||
|
|
if ($$[$0-2].is_number && $$[$0].is_number) {
|
||
|
|
this.$ = {single: '(' + $$[$0-2].single + ' * ' + $$[$0].single + ')', is_number: true};
|
||
|
|
} else {
|
||
|
|
this.$ = {single: 'lua_multiply(' + $$[$0-2].single + ', ' + $$[$0].single + ')'};
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 64:
|
||
|
|
|
||
|
|
if ($$[$0-2].is_number && $$[$0].is_number) {
|
||
|
|
this.$ = {single: '(' + $$[$0-2].single + ' / ' + $$[$0].single + ')', is_number: true};
|
||
|
|
} else {
|
||
|
|
this.$ = {single: 'lua_divide(' + $$[$0-2].single + ', ' + $$[$0].single + ')'};
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 65:
|
||
|
|
|
||
|
|
if ($$[$0-2].is_number && $$[$0].is_number) {
|
||
|
|
this.$ = {single: 'Math.pow(' + $$[$0-2].single + ', ' + $$[$0].single + ')', is_number: true};
|
||
|
|
} else {
|
||
|
|
this.$ = {single: 'lua_power(' + $$[$0-2].single + ', ' + $$[$0].single + ')'};
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 66:
|
||
|
|
this.$ = {single: 'lua_mod(' + $$[$0-2].single + ', ' + $$[$0].single + ')'};
|
||
|
|
break;
|
||
|
|
case 67:
|
||
|
|
this.$ = {single: 'lua_concat(' + $$[$0-2].single + ', ' + $$[$0].single + ')'};
|
||
|
|
break;
|
||
|
|
case 68:
|
||
|
|
|
||
|
|
this.$ = {
|
||
|
|
single: 'lua_lt(' + $$[$0-2].single + ', ' + $$[$0].single + ')',
|
||
|
|
simple_form: 'lua_lt(' + $$[$0-2].single + ', ' + $$[$0].single + ')'
|
||
|
|
};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 69:
|
||
|
|
|
||
|
|
this.$ = {
|
||
|
|
single: 'lua_lt(' + $$[$0].single + ', ' + $$[$0-2].single + ')',
|
||
|
|
simple_form: 'lua_lt(' + $$[$0].single + ', ' + $$[$0-2].single + ')'
|
||
|
|
};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 70:
|
||
|
|
|
||
|
|
this.$ = {
|
||
|
|
single: 'lua_lte(' + $$[$0-2].single + ', ' + $$[$0].single + ')',
|
||
|
|
simple_form: 'lua_lte(' + $$[$0-2].single + ', ' + $$[$0].single + ')'
|
||
|
|
};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 71:
|
||
|
|
|
||
|
|
this.$ = {
|
||
|
|
single: 'lua_lte(' + $$[$0].single + ', ' + $$[$0-2].single + ')',
|
||
|
|
simple_form: 'lua_lte(' + $$[$0].single + ', ' + $$[$0-2].single + ')'
|
||
|
|
};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 72:
|
||
|
|
|
||
|
|
this.$ = {
|
||
|
|
single: 'lua_eq(' + $$[$0-2].single + ', ' + $$[$0].single + ')',
|
||
|
|
simple_form: 'lua_eq(' + $$[$0-2].single + ', ' + $$[$0].single + ')'
|
||
|
|
};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 73:
|
||
|
|
|
||
|
|
this.$ = {
|
||
|
|
single: '!lua_eq(' + $$[$0-2].single + ', ' + $$[$0].single + ')',
|
||
|
|
simple_form: '!lua_eq(' + $$[$0-2].single + ', ' + $$[$0].single + ')'
|
||
|
|
};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 74:
|
||
|
|
|
||
|
|
this.$ = {
|
||
|
|
single: 'lua_and(' + $$[$0-2].single + ', function () {return ' + $$[$0].single + ';})',
|
||
|
|
simple_form: '(' + getIfExp($$[$0-2]) + ' && ' + getIfExp($$[$0]) + ')'
|
||
|
|
};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 75:
|
||
|
|
|
||
|
|
this.$ = {
|
||
|
|
single: 'lua_or(' + $$[$0-2].single + ', function () {return ' + $$[$0].single + ';})',
|
||
|
|
simple_form: '(' + getIfExp($$[$0-2]) + ' || ' + getIfExp($$[$0]) + ')'
|
||
|
|
};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 76:
|
||
|
|
this.$ = {single: $$[$0].is_number ? ('-' + $$[$0].single) : ('lua_unm(' + $$[$0].single + ')'), is_number: $$[$0].is_number};
|
||
|
|
break;
|
||
|
|
case 77:
|
||
|
|
|
||
|
|
this.$ = {
|
||
|
|
single: 'lua_not(' + $$[$0].single + ')',
|
||
|
|
simple_form: 'lua_not(' + $$[$0].single + ')'
|
||
|
|
};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 78:
|
||
|
|
this.$ = {single: 'lua_len(' + $$[$0].single + ')'};
|
||
|
|
break;
|
||
|
|
case 79:
|
||
|
|
this.$ = {single: 'varargs[0]', endmulti: 'varargs'};
|
||
|
|
break;
|
||
|
|
case 80:
|
||
|
|
this.$ = "lua_newtable()";
|
||
|
|
break;
|
||
|
|
case 81:
|
||
|
|
|
||
|
|
this.$ = "lua_newtable(" + getTempDecl($$[$0-2]);
|
||
|
|
if ($$[$0-2].keyed) {
|
||
|
|
for (var i in $$[$0-2].keyed) {
|
||
|
|
this.$ += ", " + $$[$0-2].keyed[i][0] + ", " + $$[$0-2].keyed[i][1];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.$ += ")";
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 82:
|
||
|
|
this.$ = createFunction([], $$[$0-2]);
|
||
|
|
break;
|
||
|
|
case 83:
|
||
|
|
this.$ = createFunction($$[$0-4], $$[$0-2]);
|
||
|
|
break;
|
||
|
|
case 84:
|
||
|
|
this.$ = createFunction([], $$[$0-2], true);
|
||
|
|
break;
|
||
|
|
case 85:
|
||
|
|
this.$ = createFunction($$[$0-6], $$[$0-2], true);
|
||
|
|
break;
|
||
|
|
case 86:
|
||
|
|
this.$ = createFunction(["self"], $$[$0-2]);
|
||
|
|
break;
|
||
|
|
case 87:
|
||
|
|
this.$ = createFunction(["self"].concat($$[$0-4]), $$[$0-2]);
|
||
|
|
break;
|
||
|
|
case 88:
|
||
|
|
this.$ = createFunction(["self"], $$[$0-2], true);
|
||
|
|
break;
|
||
|
|
case 89:
|
||
|
|
this.$ = createFunction(["self"].concat($$[$0-6]), $$[$0-2], true);
|
||
|
|
break;
|
||
|
|
case 90:
|
||
|
|
setLocal("self", "self")
|
||
|
|
break;
|
||
|
|
case 91:
|
||
|
|
this.$ = {prefixexp: getLocal($$[$0], "G.str['" + $$[$0] + "']")};
|
||
|
|
break;
|
||
|
|
case 92:
|
||
|
|
this.$ = {prefixexp: $$[$0-3].single, access: $$[$0-1].single};
|
||
|
|
break;
|
||
|
|
case 93:
|
||
|
|
this.$ = {prefixexp: $$[$0-2].single, access: "'" + $$[$0] + "'"};
|
||
|
|
break;
|
||
|
|
case 94:
|
||
|
|
|
||
|
|
if ($$[$0-1].single_tableget) {
|
||
|
|
this.$ = "lua_tablegetcall(" + $$[$0-1].single_tableget.prefixexp + ", " + $$[$0-1].single_tableget.access + ", " + getTempDecl($$[$0]) + ")";
|
||
|
|
} else {
|
||
|
|
this.$ = "lua_call(" + $$[$0-1].single + ", " + getTempDecl($$[$0]) + ")";
|
||
|
|
}
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 95:
|
||
|
|
this.$ = "lua_mcall(" + $$[$0-3].single + ", '" + $$[$0-1] + "', " + getTempDecl($$[$0]) + ")";
|
||
|
|
break;
|
||
|
|
case 96:
|
||
|
|
this.$ = $$[$0-1];
|
||
|
|
break;
|
||
|
|
case 97:
|
||
|
|
this.$ = {exps: []};
|
||
|
|
break;
|
||
|
|
case 98: case 99:
|
||
|
|
this.$ = {exps: [$$[$0]]};
|
||
|
|
break;
|
||
|
|
case 101:
|
||
|
|
|
||
|
|
this.$ = {
|
||
|
|
keyed: $$[$0-2].keyed.concat($$[$0].keyed),
|
||
|
|
exps: $$[$0-2].exps.concat($$[$0].exps),
|
||
|
|
endmulti: $$[$0].endmulti
|
||
|
|
};
|
||
|
|
|
||
|
|
break;
|
||
|
|
case 102:
|
||
|
|
this.$ = {keyed: [], exps: [$$[$0].single], endmulti: $$[$0].endmulti};
|
||
|
|
break;
|
||
|
|
case 103:
|
||
|
|
this.$ = {keyed: [["'" + $$[$0-2] + "'", $$[$0].single]], exps: []};
|
||
|
|
break;
|
||
|
|
case 104:
|
||
|
|
this.$ = {keyed: [[$$[$0-3].single, $$[$0].single]], exps: []};
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
table: [o($V0,$V1,{3:1,4:2}),{1:[3]},o($V2,$V3,{5:3,15:4,23:5,24:6,19:8,18:15,17:16,20:$V4,27:$V5,29:$V6,31:$V7,32:$V8,34:$V9,36:$Va,40:$Vb,44:$Vc}),o($Vd,$Ve,{6:19}),o($Vd,[2,11],{16:20,47:[1,21],48:[1,22]}),o($V0,$Vf,{13:23,14:$Vg}),{25:[1,25],38:[1,26]},{28:27,40:[1,28],44:[1,29]},o([22,38,43,53,55,57,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,80,81,85,86],$Vh,{7:$Vi,14:$Vi,20:$Vi,27:$Vi,29:$Vi,30:$Vi,31:$Vi,32:$Vi,33:$Vi,34:$Vi,36:$Vi,40:$Vi,44:$Vi,47:$Vi,48:$Vi,50:$Vi,52:$Vi}),o($V0,$V1,{10:30,4:31}),{17:39,18:46,19:47,20:$V4,21:32,40:$Vj,44:$Vc,56:$Vk,57:$Vl,58:$Vm,59:$Vn,60:37,61:$Vo,63:$Vp,77:$Vq,78:$Vr,79:$Vs,80:$Vt},o($Vu,$Vv,{11:48,12:49}),{17:39,18:46,19:47,20:$V4,21:53,35:50,40:$Vj,44:$Vc,49:51,51:52,56:$Vk,57:$Vl,58:$Vm,59:$Vn,60:37,61:$Vo,63:$Vp,77:$Vq,78:$Vr,79:$Vs,80:$Vt},o($V0,$V1,{4:54}),{41:55,44:[1,56]},o($Vw,$Vx,{25:$Vy,38:$Vy}),{20:$Vz,43:$VA,55:$VB,57:$VC,60:62,80:$Vt,85:$VD,87:57},o($VE,$VF),{17:39,18:46,19:47,20:$V4,21:64,40:$Vj,44:$Vc,56:$Vk,57:$Vl,58:$Vm,59:$Vn,60:37,61:$Vo,63:$Vp,77:$Vq,78:$Vr,79:$Vs,80:$Vt},{7:[1,65]},o($V0,$Vf,{13:66,14:$Vg}),o($VG,[2,33],{60:37,17:39,18:46,19:47,26:67,21:68,20:$V4,40:$Vj,44:$Vc,56:$Vk,57:$Vl,58:$Vm,59:$Vn,61:$Vo,63:$Vp,77:$Vq,78:$Vr,79:$Vs,80:$Vt}),o($VG,[2,34]),o($V2,$V3,{23:5,24:6,19:8,18:15,17:16,15:69,20:$V4,27:$V5,29:$V6,31:$V7,32:$V8,34:$V9,36:$Va,40:$Vb,44:$Vc}),o($V0,[2,9]),{17:39,18:46,19:47,20:$V4,21:68,26:70,40:$Vj,44:$Vc,56:$Vk,57:$Vl,58:$Vm,59:$Vn,60:37,61:$Vo,63:$Vp,77:$Vq,78:$Vr,79:$Vs,80:$Vt},{17:16,18:71,19:47,20:$V4,44:$Vc},o($VH,[2,20],{25:[1,72],38:[1,73]}),{44:[1,75],46:74},o($VI,[2,47]),{30:[1,76]},o($V2,$V3,{15:4,23:5,24:6,19:8,18:15,17:16,5:77,20:$V4,27:$V5,29:$V6,31:$V7,32:$V8,34:$V9,36:$Va,40:$Vb,44:$Vc}),{29:[1,78],62:$VJ,63:$VK,64:$VL,65:$VM,66:$VN,67:$VO,68:$VP,69:$VQ,70:$VR,71:$VS,72:$VT,73:$VU,74:$VV,75:$VW,76:$VX},o($VY,[2,53]),o($VY,[2,54]),o($VY,[2,55]),o($VY,[2,56]),o($VY,[2,57]),o($VY,[2,58]),o([7,14,22,27,29,30,31,32,33,34,36,38,40,44,47,48,50,52,53,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,81,86],[2,59],{87:57,60:62,20:$Vz,43:$VA,55:$VB,57:$VC,80:$Vt,85:$VD}),o($V0,$V1,{42:94,8:95,4:96}),{17:39,18:46,19:47,20:$V4,21:97,40:$Vj,44:$Vc,56:$Vk,57:$Vl,58:$Vm,59:$Vn,60:37,61:$Vo,63:$Vp,77:$Vq,78:$Vr,79:$Vs,80:$Vt},{17:39,18:46,19:47,20:$V4,21:98,40:$Vj,44:$Vc,56:$Vk,57:$Vl,58:$Vm,59:$Vn,60:37,61:$Vo,63:$Vp,77:$Vq,78:$Vr,79:$Vs,80:$Vt},{17:39,18:46,19:47,20:$V4,21:99,40:$Vj,44:$Vc,56:$Vk,57:$Vl,58:$Vm,59:$Vn,60:37,61:$Vo,63:$Vp,77:$Vq,78:$Vr,79:$Vs,80:$Vt},o($VY,[2,79]),{17:39,18:46,19:47,20:$V4,21:103,40:$Vj,44:$VZ,56:$Vk,57:$Vl,58:$Vm,59:$Vn,60:37,61:$Vo,63:$Vp,77:$Vq,78:$Vr,79:$Vs,80:$Vt,81:[1,100],82:101,85:$V_,88:102},o($V$,$Vx),o($V$,$Vh),{33:[1,106]},o($V0,$V1,{4:107}),{30:[1,108]},{30:[2,35],50:[1,109],52:[1,110]},o($V01,[2,37]),{53:[1,111],62:$VJ,63:$VK,64:$VL,65:$VM,66:$VN,67:$VO,68:$VP,69:$VQ,70:$VR,71:$VS,72:$VT,73:$VU,74:$VV,75:$VW,76:$VX},{37:112,44:[1,113]},o($V0,$V1,{8:95,4:96,42:114,43:[1,115],55:[1,116]}),o($V11,[2,52]),o($V$,[2,94]),{44:[1,117]},{17:39,18:46,19:47,20:$V4,21:118,40:$Vj,44:$Vc,56:$Vk,57:$Vl,58:$Vm,59:$Vn,60:37,61:$Vo,63:$Vp,77:$Vq,78:$Vr,79:$Vs,80:$Vt},{44:[1,119]},{17:39,18:46,19:47,20:$V4,21:68,22:[1,121],26:120,40:$Vj,44:$Vc,56:$Vk,57:$Vl,58:$Vm,59:$Vn,60:37,61:$Vo,63:$Vp,77:$Vq,78:$Vr,79:$Vs,80:$Vt},o($V$,[2,98]),o($V$,[2,99]),{22:[1,122],62:$VJ,63:$VK,64:$VL,65:$VM,66:$VN,67:$VO,68:$VP,69:$VQ,70:$VR,71:$VS,72:$VT,73:$VU,74:$VV,75:$VW,76:$VX},{1:[2,1]},o($Vd,[2,12]),o($VG,[2,32],{38:$V21}),o($V31,[2,43],{62:$VJ,63:$VK,64:$VL,65:$VM,66:$VN,67:$VO,68:$VP,69:$VQ,70:$VR,71:$VS,72:$VT,73:$VU,74:$VV,75:$VW,76:$VX}),o($V2,[2,16]),o($VH,[2,18],{38:$V21}),o($Vw,$Vx,{25:$V41,38:$V41}),{17:39,18:46,19:47,20:$V4,21:68,26:124,40:$Vj,44:$Vc,56:$Vk,57:$Vl,58:$Vm,59:$Vn,60:37,61:$Vo,63:$Vp,77:$Vq,78:$Vr,79:$Vs,80:$Vt},{44:[1,125]},o($V0,$V1,{8:95,4:96,42:126}),{20:[2,48]},o($VH,[2,22]),o($Vd,$Ve,{6:127}),o($Vu,$Vv,{12:49,11:128}),{17:39,18:46,19:47,20:$V4,21:129,40:$Vj,44:$Vc,56:$Vk,57:$Vl,58:$Vm,59:$Vn,60:37,61:$Vo,63:$Vp,77:$Vq,78:$Vr,79:$Vs,80:$Vt},{17:39,18:46,19:47,20:$V4,21:130,40:$Vj,44:$Vc,
|
||
|
|
defaultActions: {65:[2,1],75:[2,48],96:[2,4],153:[2,36],189:[2,5]},
|
||
|
|
parseError: function parseError(str, hash) {
|
||
|
|
if (hash.recoverable) {
|
||
|
|
this.trace(str);
|
||
|
|
} else {
|
||
|
|
var error = new Error(str);
|
||
|
|
error.hash = hash;
|
||
|
|
throw error;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
parse: function parse(input) {
|
||
|
|
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
|
||
|
|
var args = lstack.slice.call(arguments, 1);
|
||
|
|
var lexer = Object.create(this.lexer);
|
||
|
|
var sharedState = { yy: {} };
|
||
|
|
for (var k in this.yy) {
|
||
|
|
if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
||
|
|
sharedState.yy[k] = this.yy[k];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
lexer.setInput(input, sharedState.yy);
|
||
|
|
sharedState.yy.lexer = lexer;
|
||
|
|
sharedState.yy.parser = this;
|
||
|
|
if (typeof lexer.yylloc == 'undefined') {
|
||
|
|
lexer.yylloc = {};
|
||
|
|
}
|
||
|
|
var yyloc = lexer.yylloc;
|
||
|
|
lstack.push(yyloc);
|
||
|
|
var ranges = lexer.options && lexer.options.ranges;
|
||
|
|
if (typeof sharedState.yy.parseError === 'function') {
|
||
|
|
this.parseError = sharedState.yy.parseError;
|
||
|
|
} else {
|
||
|
|
this.parseError = Object.getPrototypeOf(this).parseError;
|
||
|
|
}
|
||
|
|
function popStack(n) {
|
||
|
|
stack.length = stack.length - 2 * n;
|
||
|
|
vstack.length = vstack.length - n;
|
||
|
|
lstack.length = lstack.length - n;
|
||
|
|
}
|
||
|
|
_token_stack:
|
||
|
|
var lex = function () {
|
||
|
|
var token;
|
||
|
|
token = lexer.lex() || EOF;
|
||
|
|
if (typeof token !== 'number') {
|
||
|
|
token = self.symbols_[token] || token;
|
||
|
|
}
|
||
|
|
return token;
|
||
|
|
};
|
||
|
|
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
|
||
|
|
while (true) {
|
||
|
|
state = stack[stack.length - 1];
|
||
|
|
if (this.defaultActions[state]) {
|
||
|
|
action = this.defaultActions[state];
|
||
|
|
} else {
|
||
|
|
if (symbol === null || typeof symbol == 'undefined') {
|
||
|
|
symbol = lex();
|
||
|
|
}
|
||
|
|
action = table[state] && table[state][symbol];
|
||
|
|
}
|
||
|
|
if (typeof action === 'undefined' || !action.length || !action[0]) {
|
||
|
|
var errStr = '';
|
||
|
|
expected = [];
|
||
|
|
for (p in table[state]) {
|
||
|
|
if (this.terminals_[p] && p > TERROR) {
|
||
|
|
expected.push('\'' + this.terminals_[p] + '\'');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (lexer.showPosition) {
|
||
|
|
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
|
||
|
|
} else {
|
||
|
|
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
|
||
|
|
}
|
||
|
|
this.parseError(errStr, {
|
||
|
|
text: lexer.match,
|
||
|
|
token: this.terminals_[symbol] || symbol,
|
||
|
|
line: lexer.yylineno,
|
||
|
|
loc: yyloc,
|
||
|
|
expected: expected
|
||
|
|
});
|
||
|
|
}
|
||
|
|
if (action[0] instanceof Array && action.length > 1) {
|
||
|
|
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
|
||
|
|
}
|
||
|
|
switch (action[0]) {
|
||
|
|
case 1:
|
||
|
|
stack.push(symbol);
|
||
|
|
vstack.push(lexer.yytext);
|
||
|
|
lstack.push(lexer.yylloc);
|
||
|
|
stack.push(action[1]);
|
||
|
|
symbol = null;
|
||
|
|
if (!preErrorSymbol) {
|
||
|
|
yyleng = lexer.yyleng;
|
||
|
|
yytext = lexer.yytext;
|
||
|
|
yylineno = lexer.yylineno;
|
||
|
|
yyloc = lexer.yylloc;
|
||
|
|
if (recovering > 0) {
|
||
|
|
recovering--;
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
symbol = preErrorSymbol;
|
||
|
|
preErrorSymbol = null;
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case 2:
|
||
|
|
len = this.productions_[action[1]][1];
|
||
|
|
yyval.$ = vstack[vstack.length - len];
|
||
|
|
yyval._$ = {
|
||
|
|
first_line: lstack[lstack.length - (len || 1)].first_line,
|
||
|
|
last_line: lstack[lstack.length - 1].last_line,
|
||
|
|
first_column: lstack[lstack.length - (len || 1)].first_column,
|
||
|
|
last_column: lstack[lstack.length - 1].last_column
|
||
|
|
};
|
||
|
|
if (ranges) {
|
||
|
|
yyval._$.range = [
|
||
|
|
lstack[lstack.length - (len || 1)].range[0],
|
||
|
|
lstack[lstack.length - 1].range[1]
|
||
|
|
];
|
||
|
|
}
|
||
|
|
r = this.performAction.apply(yyval, [
|
||
|
|
yytext,
|
||
|
|
yyleng,
|
||
|
|
yylineno,
|
||
|
|
sharedState.yy,
|
||
|
|
action[1],
|
||
|
|
vstack,
|
||
|
|
lstack
|
||
|
|
].concat(args));
|
||
|
|
if (typeof r !== 'undefined') {
|
||
|
|
return r;
|
||
|
|
}
|
||
|
|
if (len) {
|
||
|
|
stack = stack.slice(0, -1 * len * 2);
|
||
|
|
vstack = vstack.slice(0, -1 * len);
|
||
|
|
lstack = lstack.slice(0, -1 * len);
|
||
|
|
}
|
||
|
|
stack.push(this.productions_[action[1]][0]);
|
||
|
|
vstack.push(yyval.$);
|
||
|
|
lstack.push(yyval._$);
|
||
|
|
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
||
|
|
stack.push(newState);
|
||
|
|
break;
|
||
|
|
case 3:
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}};
|
||
|
|
|
||
|
|
|
||
|
|
var indentLevel = 0;
|
||
|
|
var blockId = 0;
|
||
|
|
var blockIdMax = 0;
|
||
|
|
var locals = {};
|
||
|
|
var stack = [];
|
||
|
|
var functionBlockAdded = false;
|
||
|
|
var inLoop = false;
|
||
|
|
|
||
|
|
function getLocal(name, alternative) {
|
||
|
|
if (!locals[name]) {
|
||
|
|
if (alternative) {
|
||
|
|
return alternative;
|
||
|
|
}
|
||
|
|
locals[name] = "_" + name + "_" + blockId;
|
||
|
|
}
|
||
|
|
return locals[name];
|
||
|
|
}
|
||
|
|
|
||
|
|
function setLocal(name, localName) {
|
||
|
|
return locals[name] = localName || "_" + name + "_" + blockId;
|
||
|
|
}
|
||
|
|
|
||
|
|
function setLocals(names) {
|
||
|
|
var result = []
|
||
|
|
for (var i = 0; i < names.length; i++) {
|
||
|
|
result[i] = setLocal(names[i]);
|
||
|
|
}
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
function getTempDecl(explist) {
|
||
|
|
if (explist.endmulti) {
|
||
|
|
if (explist.exps.length > 1) {
|
||
|
|
return "[" + explist.exps.slice(0, -1).join(", ") + "].concat(" + explist.endmulti + ")";
|
||
|
|
} else {
|
||
|
|
return explist.endmulti;
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
return "[" + explist.exps.join(", ") + "]";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function longStringToString(str) {
|
||
|
|
return '"' + str.substring(0, str.length - 2).replace(/^\[\[(\r\n|\r|\n)?/m, "").replace(/\n/mg, "\\n").replace(/\r/mg, "\\r").replace(/\"/mg, "\\\"") + '"';
|
||
|
|
}
|
||
|
|
|
||
|
|
function createFunction(args, body, hasVarargs) {
|
||
|
|
var result = "(function (" + args.join(", ") + ") {\n" +
|
||
|
|
" var tmp;\n";
|
||
|
|
if (hasVarargs) {
|
||
|
|
result += " var varargs = slice(arguments, " + args.length + ");\n";
|
||
|
|
}
|
||
|
|
return result +
|
||
|
|
body.simple_form + "\n" +
|
||
|
|
" return [];\n" +
|
||
|
|
"})";
|
||
|
|
}
|
||
|
|
|
||
|
|
function getIfExp(exp) {
|
||
|
|
return exp.simple_form || "lua_true(" + exp.single + ")";
|
||
|
|
}
|
||
|
|
|
||
|
|
function indentStatlist(statlist, laststat) {
|
||
|
|
return " " + ((statlist && laststat) ? statlist + "\n" + laststat : statlist + (laststat || "")).split("\n").join("\n ");
|
||
|
|
}
|
||
|
|
|
||
|
|
function autoAssertFloat(possibleNumber) {
|
||
|
|
return possibleNumber.is_number ? possibleNumber.single : "lua_assertfloat(" + possibleNumber.single + ")";
|
||
|
|
}
|
||
|
|
|
||
|
|
function autoFunctionBlock(loopblock) {
|
||
|
|
return loopblock.use_function_block ?
|
||
|
|
"(function() {\n" + loopblock.block + "\n})();" : "{\n" + loopblock.block + "\n}";
|
||
|
|
}
|
||
|
|
/* generated by jison-lex 0.3.4 */
|
||
|
|
var lexer = (function(){
|
||
|
|
var lexer = ({
|
||
|
|
|
||
|
|
EOF:1,
|
||
|
|
|
||
|
|
parseError:function parseError(str, hash) {
|
||
|
|
if (this.yy.parser) {
|
||
|
|
this.yy.parser.parseError(str, hash);
|
||
|
|
} else {
|
||
|
|
throw new Error(str);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// resets the lexer, sets new input
|
||
|
|
setInput:function (input, yy) {
|
||
|
|
this.yy = yy || this.yy || {};
|
||
|
|
this._input = input;
|
||
|
|
this._more = this._backtrack = this.done = false;
|
||
|
|
this.yylineno = this.yyleng = 0;
|
||
|
|
this.yytext = this.matched = this.match = '';
|
||
|
|
this.conditionStack = ['INITIAL'];
|
||
|
|
this.yylloc = {
|
||
|
|
first_line: 1,
|
||
|
|
first_column: 0,
|
||
|
|
last_line: 1,
|
||
|
|
last_column: 0
|
||
|
|
};
|
||
|
|
if (this.options.ranges) {
|
||
|
|
this.yylloc.range = [0,0];
|
||
|
|
}
|
||
|
|
this.offset = 0;
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
// consumes and returns one char from the input
|
||
|
|
input:function () {
|
||
|
|
var ch = this._input[0];
|
||
|
|
this.yytext += ch;
|
||
|
|
this.yyleng++;
|
||
|
|
this.offset++;
|
||
|
|
this.match += ch;
|
||
|
|
this.matched += ch;
|
||
|
|
var lines = ch.match(/(?:\r\n?|\n).*/g);
|
||
|
|
if (lines) {
|
||
|
|
this.yylineno++;
|
||
|
|
this.yylloc.last_line++;
|
||
|
|
} else {
|
||
|
|
this.yylloc.last_column++;
|
||
|
|
}
|
||
|
|
if (this.options.ranges) {
|
||
|
|
this.yylloc.range[1]++;
|
||
|
|
}
|
||
|
|
|
||
|
|
this._input = this._input.slice(1);
|
||
|
|
return ch;
|
||
|
|
},
|
||
|
|
|
||
|
|
// unshifts one char (or a string) into the input
|
||
|
|
unput:function (ch) {
|
||
|
|
var len = ch.length;
|
||
|
|
var lines = ch.split(/(?:\r\n?|\n)/g);
|
||
|
|
|
||
|
|
this._input = ch + this._input;
|
||
|
|
this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
||
|
|
//this.yyleng -= len;
|
||
|
|
this.offset -= len;
|
||
|
|
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
||
|
|
this.match = this.match.substr(0, this.match.length - 1);
|
||
|
|
this.matched = this.matched.substr(0, this.matched.length - 1);
|
||
|
|
|
||
|
|
if (lines.length - 1) {
|
||
|
|
this.yylineno -= lines.length - 1;
|
||
|
|
}
|
||
|
|
var r = this.yylloc.range;
|
||
|
|
|
||
|
|
this.yylloc = {
|
||
|
|
first_line: this.yylloc.first_line,
|
||
|
|
last_line: this.yylineno + 1,
|
||
|
|
first_column: this.yylloc.first_column,
|
||
|
|
last_column: lines ?
|
||
|
|
(lines.length === oldLines.length ? this.yylloc.first_column : 0)
|
||
|
|
+ oldLines[oldLines.length - lines.length].length - lines[0].length :
|
||
|
|
this.yylloc.first_column - len
|
||
|
|
};
|
||
|
|
|
||
|
|
if (this.options.ranges) {
|
||
|
|
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
||
|
|
}
|
||
|
|
this.yyleng = this.yytext.length;
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
// When called from action, caches matched text and appends it on next action
|
||
|
|
more:function () {
|
||
|
|
this._more = true;
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
|
||
|
|
reject:function () {
|
||
|
|
if (this.options.backtrack_lexer) {
|
||
|
|
this._backtrack = true;
|
||
|
|
} else {
|
||
|
|
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
|
||
|
|
text: "",
|
||
|
|
token: null,
|
||
|
|
line: this.yylineno
|
||
|
|
});
|
||
|
|
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
},
|
||
|
|
|
||
|
|
// retain first n characters of the match
|
||
|
|
less:function (n) {
|
||
|
|
this.unput(this.match.slice(n));
|
||
|
|
},
|
||
|
|
|
||
|
|
// displays already matched input, i.e. for error messages
|
||
|
|
pastInput:function () {
|
||
|
|
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
||
|
|
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
||
|
|
},
|
||
|
|
|
||
|
|
// displays upcoming input, i.e. for error messages
|
||
|
|
upcomingInput:function () {
|
||
|
|
var next = this.match;
|
||
|
|
if (next.length < 20) {
|
||
|
|
next += this._input.substr(0, 20-next.length);
|
||
|
|
}
|
||
|
|
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
|
||
|
|
},
|
||
|
|
|
||
|
|
// displays the character position where the lexing error occurred, i.e. for error messages
|
||
|
|
showPosition:function () {
|
||
|
|
var pre = this.pastInput();
|
||
|
|
var c = new Array(pre.length + 1).join("-");
|
||
|
|
return pre + this.upcomingInput() + "\n" + c + "^";
|
||
|
|
},
|
||
|
|
|
||
|
|
// test the lexed token: return FALSE when not a match, otherwise return token
|
||
|
|
test_match:function (match, indexed_rule) {
|
||
|
|
var token,
|
||
|
|
lines,
|
||
|
|
backup;
|
||
|
|
|
||
|
|
if (this.options.backtrack_lexer) {
|
||
|
|
// save context
|
||
|
|
backup = {
|
||
|
|
yylineno: this.yylineno,
|
||
|
|
yylloc: {
|
||
|
|
first_line: this.yylloc.first_line,
|
||
|
|
last_line: this.last_line,
|
||
|
|
first_column: this.yylloc.first_column,
|
||
|
|
last_column: this.yylloc.last_column
|
||
|
|
},
|
||
|
|
yytext: this.yytext,
|
||
|
|
match: this.match,
|
||
|
|
matches: this.matches,
|
||
|
|
matched: this.matched,
|
||
|
|
yyleng: this.yyleng,
|
||
|
|
offset: this.offset,
|
||
|
|
_more: this._more,
|
||
|
|
_input: this._input,
|
||
|
|
yy: this.yy,
|
||
|
|
conditionStack: this.conditionStack.slice(0),
|
||
|
|
done: this.done
|
||
|
|
};
|
||
|
|
if (this.options.ranges) {
|
||
|
|
backup.yylloc.range = this.yylloc.range.slice(0);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
lines = match[0].match(/(?:\r\n?|\n).*/g);
|
||
|
|
if (lines) {
|
||
|
|
this.yylineno += lines.length;
|
||
|
|
}
|
||
|
|
this.yylloc = {
|
||
|
|
first_line: this.yylloc.last_line,
|
||
|
|
last_line: this.yylineno + 1,
|
||
|
|
first_column: this.yylloc.last_column,
|
||
|
|
last_column: lines ?
|
||
|
|
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
|
||
|
|
this.yylloc.last_column + match[0].length
|
||
|
|
};
|
||
|
|
this.yytext += match[0];
|
||
|
|
this.match += match[0];
|
||
|
|
this.matches = match;
|
||
|
|
this.yyleng = this.yytext.length;
|
||
|
|
if (this.options.ranges) {
|
||
|
|
this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
||
|
|
}
|
||
|
|
this._more = false;
|
||
|
|
this._backtrack = false;
|
||
|
|
this._input = this._input.slice(match[0].length);
|
||
|
|
this.matched += match[0];
|
||
|
|
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
||
|
|
if (this.done && this._input) {
|
||
|
|
this.done = false;
|
||
|
|
}
|
||
|
|
if (token) {
|
||
|
|
return token;
|
||
|
|
} else if (this._backtrack) {
|
||
|
|
// recover context
|
||
|
|
for (var k in backup) {
|
||
|
|
this[k] = backup[k];
|
||
|
|
}
|
||
|
|
return false; // rule action called reject() implying the next rule should be tested instead.
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
},
|
||
|
|
|
||
|
|
// return next match in input
|
||
|
|
next:function () {
|
||
|
|
if (this.done) {
|
||
|
|
return this.EOF;
|
||
|
|
}
|
||
|
|
if (!this._input) {
|
||
|
|
this.done = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
var token,
|
||
|
|
match,
|
||
|
|
tempMatch,
|
||
|
|
index;
|
||
|
|
if (!this._more) {
|
||
|
|
this.yytext = '';
|
||
|
|
this.match = '';
|
||
|
|
}
|
||
|
|
var rules = this._currentRules();
|
||
|
|
for (var i = 0; i < rules.length; i++) {
|
||
|
|
tempMatch = this._input.match(this.rules[rules[i]]);
|
||
|
|
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
||
|
|
match = tempMatch;
|
||
|
|
index = i;
|
||
|
|
if (this.options.backtrack_lexer) {
|
||
|
|
token = this.test_match(tempMatch, rules[i]);
|
||
|
|
if (token !== false) {
|
||
|
|
return token;
|
||
|
|
} else if (this._backtrack) {
|
||
|
|
match = false;
|
||
|
|
continue; // rule action called reject() implying a rule MISmatch.
|
||
|
|
} else {
|
||
|
|
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
} else if (!this.options.flex) {
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (match) {
|
||
|
|
token = this.test_match(match, rules[index]);
|
||
|
|
if (token !== false) {
|
||
|
|
return token;
|
||
|
|
}
|
||
|
|
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if (this._input === "") {
|
||
|
|
return this.EOF;
|
||
|
|
} else {
|
||
|
|
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
|
||
|
|
text: "",
|
||
|
|
token: null,
|
||
|
|
line: this.yylineno
|
||
|
|
});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// return next match that has a token
|
||
|
|
lex:function lex() {
|
||
|
|
var r = this.next();
|
||
|
|
if (r) {
|
||
|
|
return r;
|
||
|
|
} else {
|
||
|
|
return this.lex();
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
|
||
|
|
begin:function begin(condition) {
|
||
|
|
this.conditionStack.push(condition);
|
||
|
|
},
|
||
|
|
|
||
|
|
// pop the previously active lexer condition state off the condition stack
|
||
|
|
popState:function popState() {
|
||
|
|
var n = this.conditionStack.length - 1;
|
||
|
|
if (n > 0) {
|
||
|
|
return this.conditionStack.pop();
|
||
|
|
} else {
|
||
|
|
return this.conditionStack[0];
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// produce the lexer rule set which is active for the currently active lexer condition state
|
||
|
|
_currentRules:function _currentRules() {
|
||
|
|
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
||
|
|
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
||
|
|
} else {
|
||
|
|
return this.conditions["INITIAL"].rules;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
|
||
|
|
topState:function topState(n) {
|
||
|
|
n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
||
|
|
if (n >= 0) {
|
||
|
|
return this.conditionStack[n];
|
||
|
|
} else {
|
||
|
|
return "INITIAL";
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// alias for begin(condition)
|
||
|
|
pushState:function pushState(condition) {
|
||
|
|
this.begin(condition);
|
||
|
|
},
|
||
|
|
|
||
|
|
// return the number of states currently on the stack
|
||
|
|
stateStackSize:function stateStackSize() {
|
||
|
|
return this.conditionStack.length;
|
||
|
|
},
|
||
|
|
options: {},
|
||
|
|
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
||
|
|
var YYSTATE=YY_START;
|
||
|
|
switch($avoiding_name_collisions) {
|
||
|
|
case 0:/* skip whitespace */
|
||
|
|
break;
|
||
|
|
case 1:/* skip multiline comment */
|
||
|
|
break;
|
||
|
|
case 2:/* skip comment */
|
||
|
|
break;
|
||
|
|
case 3:return 56;
|
||
|
|
break;
|
||
|
|
case 4:return 56;
|
||
|
|
break;
|
||
|
|
case 5:return 56;
|
||
|
|
break;
|
||
|
|
case 6:return 57;
|
||
|
|
break;
|
||
|
|
case 7:return 57;
|
||
|
|
break;
|
||
|
|
case 8:yy_.yytext = longStringToString(yy_.yytext); return 57;
|
||
|
|
break;
|
||
|
|
case 9:return 43;
|
||
|
|
break;
|
||
|
|
case 10:return 14;
|
||
|
|
break;
|
||
|
|
case 11:return 20;
|
||
|
|
break;
|
||
|
|
case 12:return 22;
|
||
|
|
break;
|
||
|
|
case 13:return 85;
|
||
|
|
break;
|
||
|
|
case 14:return 86;
|
||
|
|
break;
|
||
|
|
case 15:return 80;
|
||
|
|
break;
|
||
|
|
case 16:return 81;
|
||
|
|
break;
|
||
|
|
case 17:return 62;
|
||
|
|
break;
|
||
|
|
case 18:return 63;
|
||
|
|
break;
|
||
|
|
case 19:return 64;
|
||
|
|
break;
|
||
|
|
case 20:return 65;
|
||
|
|
break;
|
||
|
|
case 21:return 67;
|
||
|
|
break;
|
||
|
|
case 22:return 66;
|
||
|
|
break;
|
||
|
|
case 23:return 73;
|
||
|
|
break;
|
||
|
|
case 24:return 25;
|
||
|
|
break;
|
||
|
|
case 25:return 74;
|
||
|
|
break;
|
||
|
|
case 26:return 71;
|
||
|
|
break;
|
||
|
|
case 27:return 72;
|
||
|
|
break;
|
||
|
|
case 28:return 69;
|
||
|
|
break;
|
||
|
|
case 29:return 70;
|
||
|
|
break;
|
||
|
|
case 30:return 78;
|
||
|
|
break;
|
||
|
|
case 31:return 38;
|
||
|
|
break;
|
||
|
|
case 32:return 79;
|
||
|
|
break;
|
||
|
|
case 33:return 68;
|
||
|
|
break;
|
||
|
|
case 34:return 55;
|
||
|
|
break;
|
||
|
|
case 35:return 77;
|
||
|
|
break;
|
||
|
|
case 36:return 75;
|
||
|
|
break;
|
||
|
|
case 37:return 76;
|
||
|
|
break;
|
||
|
|
case 38:return 58;
|
||
|
|
break;
|
||
|
|
case 39:return 59;
|
||
|
|
break;
|
||
|
|
case 40:return 61;
|
||
|
|
break;
|
||
|
|
case 41:return 40;
|
||
|
|
break;
|
||
|
|
case 42:return 33;
|
||
|
|
break;
|
||
|
|
case 43:return 29;
|
||
|
|
break;
|
||
|
|
case 44:return 30;
|
||
|
|
break;
|
||
|
|
case 45:return 31;
|
||
|
|
break;
|
||
|
|
case 46:return 34;
|
||
|
|
break;
|
||
|
|
case 47:return 53;
|
||
|
|
break;
|
||
|
|
case 48:return 52;
|
||
|
|
break;
|
||
|
|
case 49:return 50;
|
||
|
|
break;
|
||
|
|
case 50:return 36;
|
||
|
|
break;
|
||
|
|
case 51:return 27;
|
||
|
|
break;
|
||
|
|
case 52:return 32;
|
||
|
|
break;
|
||
|
|
case 53:return 39;
|
||
|
|
break;
|
||
|
|
case 54:return 47;
|
||
|
|
break;
|
||
|
|
case 55:return 48;
|
||
|
|
break;
|
||
|
|
case 56:return 44;
|
||
|
|
break;
|
||
|
|
case 57:return 7;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
rules: [/^(?:\s+)/,/^(?:--\[\[(.|\n|\r)*?\]\])/,/^(?:--.*)/,/^(?:0x[0-9a-fA-f]+)/,/^(?:\d+(\.\d*)?([eE]-?\d+)?)/,/^(?:\.\d+([eE]-?\d+)?)/,/^(?:"(\\.|[^"])*")/,/^(?:'(\\.|[^'])*')/,/^(?:\[\[(.|\n|\r)*?\]\])/,/^(?::)/,/^(?:;)/,/^(?:\()/,/^(?:\))/,/^(?:\[)/,/^(?:\])/,/^(?:\{)/,/^(?:\})/,/^(?:\+)/,/^(?:-)/,/^(?:\*)/,/^(?:\/)/,/^(?:%)/,/^(?:\^)/,/^(?:==)/,/^(?:=)/,/^(?:~=)/,/^(?:<=)/,/^(?:>=)/,/^(?:<)/,/^(?:>)/,/^(?:#)/,/^(?:,)/,/^(?:\.\.\.)/,/^(?:\.\.)/,/^(?:\.)/,/^(?:not\b)/,/^(?:and\b)/,/^(?:or\b)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:nil\b)/,/^(?:function\b)/,/^(?:until\b)/,/^(?:do\b)/,/^(?:end\b)/,/^(?:while\b)/,/^(?:if\b)/,/^(?:then\b)/,/^(?:elseif\b)/,/^(?:else\b)/,/^(?:for\b)/,/^(?:local\b)/,/^(?:repeat\b)/,/^(?:in\b)/,/^(?:return\b)/,/^(?:break\b)/,/^(?:[a-zA-Z_][a-zA-Z0-9_]*)/,/^(?:$)/],
|
||
|
|
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57],"inclusive":true}}
|
||
|
|
});
|
||
|
|
return lexer;
|
||
|
|
})();
|
||
|
|
parser.lexer = lexer;
|
||
|
|
function Parser () {
|
||
|
|
this.yy = {};
|
||
|
|
}
|
||
|
|
Parser.prototype = parser;parser.Parser = Parser;
|
||
|
|
return new Parser;
|
||
|
|
})();
|
||
|
|
|
||
|
|
|
||
|
|
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
||
|
|
exports.parser = lua_parser;
|
||
|
|
exports.Parser = lua_parser.Parser;
|
||
|
|
exports.parse = function () { return lua_parser.parse.apply(lua_parser, arguments); };
|
||
|
|
exports.main = function commonjsMain(args) {
|
||
|
|
if (!args[1]) {
|
||
|
|
console.log('Usage: '+args[0]+' FILE');
|
||
|
|
process.exit(1);
|
||
|
|
}
|
||
|
|
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8");
|
||
|
|
return exports.parser.parse(source);
|
||
|
|
};
|
||
|
|
if (typeof module !== 'undefined' && require.main === module) {
|
||
|
|
exports.main(process.argv.slice(1));
|
||
|
|
}
|
||
|
|
}
|