UNPKG

sai-language

Version:

An object-oriented language designed to afford code comprehension and maintenance. Transpiles in-place to Javascript.

1,258 lines (1,223 loc) 110 kB
/* * Generated by PEG.js 0.10.0. * * http://pegjs.org/ */ (function() { "use strict"; function peg$subclass(child, parent) { function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); } function peg$SyntaxError(message, expected, found, location) { this.message = message; this.expected = expected; this.found = found; this.location = location; this.name = "SyntaxError"; if (typeof Error.captureStackTrace === "function") { Error.captureStackTrace(this, peg$SyntaxError); } } peg$subclass(peg$SyntaxError, Error); peg$SyntaxError.buildMessage = function(expected, found) { var DESCRIBE_EXPECTATION_FNS = { literal: function(expectation) { return "\"" + literalEscape(expectation.text) + "\""; }, "class": function(expectation) { var escapedParts = "", i; for (i = 0; i < expectation.parts.length; i++) { escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]); } return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; }, any: function(expectation) { return "any character"; }, end: function(expectation) { return "end of input"; }, other: function(expectation) { return expectation.description; } }; function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } function literalEscape(s) { return s .replace(/\\/g, '\\\\') .replace(/"/g, '\\"') .replace(/\0/g, '\\0') .replace(/\t/g, '\\t') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); } function classEscape(s) { return s .replace(/\\/g, '\\\\') .replace(/\]/g, '\\]') .replace(/\^/g, '\\^') .replace(/-/g, '\\-') .replace(/\0/g, '\\0') .replace(/\t/g, '\\t') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); } function describeExpectation(expectation) { return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); } function describeExpected(expected) { var descriptions = new Array(expected.length), i, j; for (i = 0; i < expected.length; i++) { descriptions[i] = describeExpectation(expected[i]); } descriptions.sort(); if (descriptions.length > 0) { for (i = 1, j = 1; i < descriptions.length; i++) { if (descriptions[i - 1] !== descriptions[i]) { descriptions[j] = descriptions[i]; j++; } } descriptions.length = j; } switch (descriptions.length) { case 1: return descriptions[0]; case 2: return descriptions[0] + " or " + descriptions[1]; default: return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1]; } } function describeFound(found) { return found ? "\"" + literalEscape(found) + "\"" : "end of input"; } return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; }; function peg$parse(input, options) { options = options !== void 0 ? options : {}; var peg$FAILED = {}, peg$startRuleIndices = { startFile: 0, startExpression: 1 }, peg$startRuleIndex = 0, peg$consts = [ function(r, o) { var code=''; if (r) code+=r; code+=o.join('\n') MagicCheck(code); //console.log(code); code=Linker(code,true); if (failures.length) options.failures=failures.join('\n'); code=GetTools()+code; return code; }, function(code) { MagicCheck(code); code=Linker(code); if (failures.length) options.failures=failures.join('\n'); return code; }, function(v) { if (v[0]!='fields') fail("SAI Compiler: REFERENCE requires a trait list."); var code=''; for (var i in v[2]) { var r=v[2][i]; References[lp+r[0]]=true; if (r[1].indexOf('function')==0) { fail("SAI Compiler: Cannot define functions in a reference block. Sorry, maybe someday."); } code+='var '+lp+r[0]+'='+r[1]+';\n'; } return code; }, function(k, typ, v, d, s) { if (!v) v=quoted('0.0.0-unspecified'); var code='',isof=[]; var isa=quoted(k); addToList('lock','isa') addToList('freeze','isof') code+='var isa=prototype.isa='+isa+';\n'; isof.push('version:'+v); isof.push('isa:isa'); isof.push('context:__context'); if (typ) { isof.push('type:"'+typ+'"'); } code+='var $bindfail=function(m){ throw new Error("SAI: A call to "+m+" on object "+isa+" has come unbound from any instance of that object. (If this is not in error, mark the declaration of "+m+" as unbound.)"); }\n'; code+='prototype.isof['+isa+']={'+isof.join(',')+'};\n'; var l; if (l=getList('lock')) code+='prototype.__tobelocked=prototype.__tobelocked.concat('+l+');\n'; if (l=getList('freeze')) code+='prototype.__tobefrozen=prototype.__tobefrozen.concat('+l+');\n'; code+=d.join('\n'); code+=s.join('\n'); clearLists(); return code; }, function(v) { return v }, function(v) { var inherit='['+v.join(',')+']'; var code='prototype.isof[prototype.isa].inherit=prototype.__inherits='+inherit+';\n'; return code; }, function(v) { return 'prototype.__contracts=prototype.__contracts.concat(['+v.join(',')+']);\n'; }, function(v, p1, p2) { addInstanceVar(v); var prop={get: undefined, set: undefined}; prop[p1[0]]=p1[1]; if (p2) { prop[p2[0]]=p2[1]; } var ret='Object.defineProperty(prototype,"'+v+ '",{configurable:true,enumerable:true,get:'+prop.get+ ',set:'+prop.set+ '});\n'; addToList('lock',v); return ret; }, function(g, w, b) { if (!g) g='get'; if (g=='get') w=null; return [g,TaskFormatter({prefix:g,as:w,property:true,body:b,kind:'function'})]; }, function(v, k) { v.body=k; return TaskFormatter(v); }, function(v, unbound, x, w) { if (unbound) { if (References[lp+v]) fail("SAI Compiler: "+v+" redefinition"); References[lp+v]=v; } else { addInstanceVar(v); } return {name:"'"+v+"'",unbound:unbound,expects:x,as:w,kind:'function'}; }, function(v, unbound, x, w) { if (unbound) { if (References[lp+v]) fail("SAI Compiler: "+v+" redefinition"); References[lp+v]=v; } else { addInstanceVar(v); } return {name:v,expects:x,unbound:unbound,as:w,kind:'function*'}; }, function(v, unbound, x, o) { if (unbound) { if (References[lp+v]) fail("SAI Compiler: "+v+" redefinition"); References[lp+v]=v; } else { addInstanceVar(v); } var vn="'"+v+"'"; var isthis='this['+vn+']?this:$bindfail('+vn+')'; if (unbound) { isthis='this'; } return { name:vn ,expects:x ,unbound:unbound ,as:o ,nothis:true ,kind:'function' ,preface:'var $='+isthis+'; return new Promise(function($_resolve,$_reject) {' ,postface:'});' }; }, function(v) { return "Symbol.iterator" }, function(v) { return "'"+v+"'" }, function(x, o, b) { return TaskClauseFormatter({expects:x,as:o,block:b,kind:'function'}); }, ";", peg$literalExpectation(";", false), function(x, o, b) { return TaskClauseFormatter({expects:x,as:o,block:'return '+b+';',kind:'function'}); }, function(x, o, b) { return TaskClauseFormatter({expects:x,as:o,block:b,kind:'function*'}); }, function(x, o, b) { return TaskClauseFormatter({ expects:x ,as:o ,block:b ,kind:'function' ,preface:'return new Promise(function($_resolve,$_reject) {' ,postface:'});' }); }, function(i, t) { return [i[1],t?t:true] }, function(i) {return i}, function(is, i) { is.push(i); return is; }, function(t) { return [[['','_root'],t]] }, "..", peg$literalExpectation("..", false), function(v) { return v+';' }, function(v) { return v.join('') }, function(v, w) { var l=WhereAmI(w); return v + l; }, function(p) { var left='',right=''; for (var i=0; i<p.length; i++) { left=p[i][0]+left; right=right+p[i][1]; } return [left,right]; }, "|", peg$literalExpectation("|", false), function(i) { return options.pipers[i];}, function(i) { return options.pipers[i].clauses[i].expr }, function(i, o) { return o }, function(i) { return options.pipers[i].clauses[i].exprs }, function(i) { return options.pipers[i].clauses[i].outblock }, function(i) { return options.pipers[i].clauses[i].valexpr }, function(i) { return options.pipers[i].clauses[i].valoutblock }, function(i) { return options.pipers[i].clauses[i].valuse }, function(i) { return options.pipers[i].clauses[i].use }, function(i) { return options.pipers[i].clauses[i].none }, function(i, a, cli) { return options.pipers[i].clauses[cli]; }, function(i, a, cli) { return options.pipers[i].clauses[cli].expr }, function(i, a, cli, o) { return o }, function(i, a, cli) { return options.pipers[i].clauses[cli].exprs }, function(i, a, cli) { return options.pipers[i].clauses[cli].outblock }, function(i, a, cli) { return options.pipers[i].clauses[cli].valexpr }, function(i, a, cli) { return options.pipers[i].clauses[cli].valoutblock }, function(i, a, cli) { return options.pipers[i].clauses[cli].valuse }, function(i, a, cli) { return options.pipers[i].clauses[cli].use }, function(i, a, cli) { return options.pipers[i].clauses[cli].none }, function(i, a, cli, cla) {return [cli,cla];}, function(i, a, cl) { var opi=options.pipers[i]; var clauses=[[i,a]].concat(cl); var work=[]; for (var i=0; i<clauses.length; i++) { var cl=clauses[i]; var w={ clause: cl[0], syntax: cl[1].syntax, type: cl[0]+"."+cl[1].syntax, args: cl[1] }; work[i]=w; } var tools={ addlocal:function(v){ if (!v) v=tempvar(); addLocal(v); return v; }, replacer:RV, tasker:TaskClauseFormatter }; var result=opi.handler({work:work[0],clauses:work,tools:tools}); if (result.error) fail(result.error); if (result.tools && result.tools.length) for (var tc=0; tc<result.tools.length; tc++) AddTool(result.tools[tc]); return result.leftright || ['','']; }, function(v, o, b) { return { syntax: 'valoutblock', val: v, out: o, block: b }; }, function(o, b) { return { syntax: 'outblock', out: o, block: b }; }, function(v, u) { return { syntax: 'valuse', val: v, use: u }; }, function(u) { return { syntax: 'use', use: u }; }, function(v, x) { return { syntax: 'valexpr', val: v, expr: x }; }, function(x) { return { syntax: 'exprs', exprs: x }; }, function(x) { return { syntax: 'expr', expr: x }; }, function() { return { syntax: 'none' }; }, function(i) { return options.constructs[i]; }, function(i) {return options.constructs[i].clauses[i].exproutblock}, function(i, ca) {return ca}, function(i) {return options.constructs[i].clauses[i].exprout}, function(i) {return options.constructs[i].clauses[i].exprsblock}, function(i) {return options.constructs[i].clauses[i].exprsoutblock}, function(i) {return options.constructs[i].clauses[i].exprusing}, function(i) {return options.constructs[i].clauses[i].exprsusing}, function(i) {return options.constructs[i].clauses[i].outblock}, function(i) {return options.constructs[i].clauses[i].block}, function(i) {return options.constructs[i].clauses[i].exprs}, function(i) {return options.constructs[i].clauses[i].rvalue}, function(i) {return options.constructs[i].clauses[i].verb}, function(i) {return options.constructs[i].clauses[i].none}, function(i, a, cli) { if (cli===i && !options.constructs[i].repeats) return false; return options.constructs[i].clauses[cli]; }, function(i, a, cli) {return options.constructs[i].clauses[cli].exproutblock}, function(i, a, cli, claa) {return claa}, function(i, a, cli) {return options.constructs[i].clauses[cli].exprout}, function(i, a, cli) {return options.constructs[i].clauses[cli].exprsblock}, function(i, a, cli) {return options.constructs[i].clauses[cli].exprsoutblock}, function(i, a, cli) {return options.constructs[i].clauses[cli].exprusing}, function(i, a, cli) {return options.constructs[i].clauses[cli].exprsusing}, function(i, a, cli) {return options.constructs[i].clauses[cli].outblock}, function(i, a, cli) {return options.constructs[i].clauses[cli].block}, function(i, a, cli) {return options.constructs[i].clauses[cli].exprs}, function(i, a, cli) {return options.constructs[i].clauses[cli].rvalue}, function(i, a, cli) {return options.constructs[i].clauses[cli].verb}, function(i, a, cli) {return options.constructs[i].clauses[cli].none}, function(i, a, cl) { var opi=options.constructs[i]; var work=[[i,a]].concat(cl); var work2=[]; for (var i1=0; i1<work.length; i1++) { var j=work[i1]; if (j[1].syntax === 'error') { fail("SAI Compiler: Error in "+j[0]+" / "+i+" (this is a propogated error, look within the clause for syntax faults).",j[1].location); } work2.push({ clause: j[0], syntax: j[1].syntax, type: j[0]+'.'+j[1].syntax, args: j[1] }); } var result=opi.handler({ clauses:work2, tools:{ addlocal:function(v){ if (!v) v=tempvar(); addLocal(v); return v; }, replacer:RV, tasker:TaskClauseFormatter } }); if (result.error) fail(result.error); if (result.tools && result.tools.length) for (var tc=0; tc<result.tools.length; tc++) AddTool(result.tools[tc]); return result.body; }, peg$anyExpectation(), function() { return { syntax: 'error', location: location().start.offset }; }, function(pl, mo, b) { return { syntax: 'exprsoutblock', exprs: pl, out: mo, block: b }; }, function(x, mo, b) { return { syntax: 'exproutblock', expr: x, out: mo, block: b }; }, function(x, mo) { return { syntax: 'exprout', expr: x, out: mo, }; }, function(x, task) { return { syntax: 'exprusing', expr: x, using: task }; }, function(pl, task) { return { syntax: 'exprsusing', exprs: pl, using: task }; }, function(mo, b) { return { syntax: 'outblock', out: mo, block: b }; }, function(b) { return { syntax: 'block', block: b }; }, function(pl) { return { syntax: 'exprs', exprs: pl }; }, function(pl, b) { return { syntax: 'exprsblock', exprs: pl, block: b }; }, function(v) { return { syntax: 'verb', verb: v }; }, function(v) { return { syntax: 'rvalue', rvalue: v }; }, function() { return { syntax: 'none' }; }, function() { return ';' }, function(a, b) { return RV('var ^{t1}=^{v1}; var ^{t2}=^{v2}; ^{v2}=^{t1}; ^{v1}=^{t2};',{t1:tempvar(),t2:tempvar(),v1:a,v2:b}); }, function(t) { return t }, function(t) { return t.join(''); }, function(v) { return [v] }, function(v) { return v.reduce(function(a,b){return a.concat(b)}) }, "-", peg$literalExpectation("-", false), function(l, op, e) { fail('SAI Compiler: the "set val '+op+' expr" construct is unclear. Please use "set val to '+op+' expr" or "set val self '+op+' expr" as appropriate.'); }, function(l, o, e) { if (readOnlyReference) for (var i in l) if (References[l[i]]) fail("SAI Compiler: Cannot assign to reference variable "+l[i].substr(1)+"."); var code=''; for (var i in l) { code+=RV(itselfops[o], {'1':l[i], '2':RV(e,{self:l[i]}) } )+';\n'; } return code; }, /^[^a-zA-Z0-9_]/, peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_"], true, false), function(l, e) { if (readOnlyReference) for (var i in l) if (References[l[i]]) fail("SAI Compiler: Cannot assign to reference variable "+l[i].substr(1)+"."); if (l.length==1) return l[0]+'='+RV(e,{self:l[0]})+';\n'; var code='var $_='+e+';\n'; for (var i in l) { code+=l[i]+'=$_['+i+'];\n'; } return code; }, function(l, o) { if (readOnlyReference) for (var i in l) if (References[l[i]]) fail("SAI Compiler: Cannot assign to reference variable "+l[i].substr(1)+"."); var code=''; for (var i in l) { code+=RV(unops[o],{'1':l[i]})+';\n'; } return code; }, function(l, o) { if (readOnlyReference) for (var i in l) if (References[l[i]]) fail("SAI Compiler: Cannot assign to reference variable "+l[i].substr(1)+"."); var code=''; var a=tempvar(); addLocal(a); for (var i in l) { code+=a+'='+l[i]+'; '+l[i]+'='+o[0]+a+o[1]+';\n'; } return code; }, function(l, o, e) { fail("SAI compiler: 'local' should only be used when declaring variables, not when modifying them."); }, function(l, e) { for (var i in l) { //console.log("local scope check "+l[i]); if ('$.'==l[i].substring(0,2)) CheckScope(l[i].substring(2),"local-1"); if (lp==l[i].substring(0,lp.length)) CheckScope(l[i],"local-2"); } if (l.length==1) return 'let '+l[0]+'='+RV(e,{self:l[0]})+';\n'; var code='var $_='+e+';\n'; for (var i in l) { code+='let '+l[i]+'=$_['+i+'];\n'; } return code; }, function(l, o) { fail("SAI compiler: 'local' should only be used when declaring variables, not when modifying them."); }, function() { return 'local '; }, "+", peg$literalExpectation("+", false), "**", peg$literalExpectation("**", false), "*", peg$literalExpectation("*", false), "/", peg$literalExpectation("/", false), "%", peg$literalExpectation("%", false), "<<", peg$literalExpectation("<<", false), ">>", peg$literalExpectation(">>", false), ">>>", peg$literalExpectation(">>>", false), "?>", peg$literalExpectation("?>", false), "?<", peg$literalExpectation("?<", false), "?", peg$literalExpectation("?", false), function(v) { return v+';\n'; }, function(v) { return v+";\n"; }, function(v) { return '$AI.drain_op('+v+');\n'; }, function(v, a) { return [v].concat(a) }, ",", peg$literalExpectation(",", false), function(v) { var j=v.length; if (!j) fail("SAI Compiler: Expected something to assign into"); if (j==1) { var pattern=accessors.firststore[v[0][0]]; if (!pattern) fail("SAI Compiler: Couldn't construct recipient from "+v); return pattern[0] + v[0][1] + pattern[1]; } j--; var code=''; var patternbase=accessors.firstfetch; var i=0; while (i<j) { var pattern=patternbase[v[i][0]]; patternbase=accessors.nextfetch; if (!pattern) fail("SAI Compiler: Couldn't construct recipient from "+v); code+=pattern[0] + v[i][1] + pattern[1]; i++; } var pattern=accessors.laststore[v[j][0]]; if (!pattern) fail("SAI Compiler: Couldn't construct recipient from "+v); code= code+pattern[0]+v[j][1]+pattern[1]; return code; }, function(v) { return ValueCompositor(v,false) }, function(v) { return ValueCompositor(v,true) }, function(v) { var verb='',stem=''; if (v[0][0]=='local') { var test=v[0][1].substr(lp.length,v[0][1].length-lp.length); var binding=options.globals[test]; if (binding) { v[0][0]='bound'; v[0][1]=binding; } } var patternbase=accessors.firstfetch; var i=0; while (i<v.length) { var pattern=patternbase[v[i][0]]; patternbase=accessors.nextfetch; if (!pattern) fail("SAI Compiler: VV Couldn't construct dereference from "+v[i]+' because '+pattern+' is false'); stem+=verb; verb=pattern[0] + v[i][1] + pattern[1]; // console.log("VV"+i+": stem:"+stem+" verb:"+verb); i++; } return [stem,verb]; }, function(v) { return [['literal',v]] }, function() { return [['super','']]; }, function(x, y) { var stem=x; for (var i in y) stem=stem.concat(y[i]); return stem }, function(x, y) { var stem=x; for (var i in y) stem=stem.concat(y[i]); return stem }, function() { return [['it','']] }, function() { return [['key','']]}, function() { return [['counter','']]}, function() { return [['trial','']]}, function() { return [['sum','']]}, function() { return [['self','']]}, function() { return [['error','']]}, function(v) { return [[ 'attribute', v ]] }, "'s", peg$literalExpectation("'s", false), function(p) { return [[ 'function', p?p[1]:'' ]] }, function(v) { return [[ 'it', ''],[ 'attribute', v ]] }, function(v) { return [[ 'it', ''],[ 'index', v ]] }, function() { return [[ 'it', '']] }, "[", peg$literalExpectation("[", false), "]", peg$literalExpectation("]", false), function(v) { return [[ 'index', v ]] }, "\\", peg$literalExpectation("\\", false), function(v) { return [['index',v]] }, ".", peg$literalExpectation(".", false), function(v) { return [[ 'paren', v ]] }, function(v) { //console.log("LLocal "+v); if (InstanceVars[v]) { usedMemberVar=v; return [['this',''],[ 'attribute',v ]]; } if (!options.globals[v]) addLocal(lp+v); return [[ 'local',lp+v ]]; }, function(v) { //console.log("RLocal "+v); if (InstanceVars[v]) { usedMemberVar=v; return [['this',''],[ 'attribute',v ]]; } if (!options.globals[v]) { v=checkLocal(lp+v,v); } else { v=lp+v; } return [[ 'local',v ]]; }, "$$", peg$literalExpectation("$$", false), function() { return [['arguments','']]}, "$", peg$literalExpectation("$", false), function(v) { return [[ 'parameters','' ],['attribute',v]] }, function(v) { return [[ 'parameters','' ],['index',v]] }, function() { return [[ 'parameters','' ]]}, function(v) { return [['literal',v]]}, "~", peg$literalExpectation("~", false), function(v) { return [['global',v]] }, "@", peg$literalExpectation("@", false), function(v) { return [['this',''],[ 'attribute',v ]] }, "@@", peg$literalExpectation("@@", false), function(v) { return [['currentthis',''],[ 'attribute',v ]] }, function() { return [['currentthis','']] }, function() { return [['this','']] }, function(k, v) { addToList('freeze',k); addInstanceVar(k); return 'prototype["'+k+'"]='+v[1]+';\n'; }, function(v) { // addToList('lock',i); addInstanceVars(v); var code=''; code+='var t='+v[1]+';\nfor (var i in t) { prototype.__tobelocked.push(i); prototype[i]=t[i]; };\n'; return code; }, function(v) { var ivar=GlobVar(); addInstanceVars(v); var proof='var '+ivar+'=function(){ var $=this; return '+v[1]+'; }\nfor (var i in '+ivar+'()) { prototype[i]=undefined; };\n'; var sup=GlobVar(); var setup= 'var '+sup+'=prototype.Constructor || function(){};\nprototype.Constructor=function() {\n'+sup+'.call(this);\n var t='+ivar+'();\n for (var i in t) if (t[i] !== undefined) this[i]=t[i];\n};\n'; return proof+setup; }, function(maj, min, patch) { return "'"+maj+"."+min+"."+patch+"'"; }, function(v) { return ['array',v.join(','),v] }, function(v) { var w=[]; for (var i in v) { w[i]=v[i][0]+':'+v[i][1]; } return ['fields', '{'+w.join(',')+'}',v] }, function(v) { var w=[]; for (var i in v) { w[i]=v[i][0]+':'+v[i][1]; } return ['fields','{'+w.join(',')+'}',v] }, function() { return null }, function(v) { return ['literal',v] }, function() { return ['literal','[]']; }, function() { return ['literal','{}']; }, function(v) { return ['literal','['+v.join(',')+']'] }, function(v) { var w=[]; for (var i in v) { w[i]=v[i][0]+':'+v[i][1]; } return ['literal','{'+w.join(',')+'}'] }, function(v) { var w=[]; for (var i in v) { w[i]=v[i][0]+':'+v[i][1]; } return ['literal', '{'+w.join(',')+'}'] }, function(v) { v=EnumCheck(v); var w=[]; for (var i in v) { w[i]=v[i][0]+':'+v[i][1]; } return ['literal','{'+w.join(',')+'}'] }, function(v) { v=EnumCheck(v); var w=[]; for (var i in v) { w[i]=v[i][0]+':'+v[i][1]; } return ['literal', '{'+w.join(',')+'}'] }, function(v) { return v[1] }, /^[^\n},);|]/, peg$classExpectation(["\n", "}", ",", ")", ";", "|"], true, false), ")", peg$literalExpectation(")", false), function(v) { return quoted(v.join('').trim()) }, function(v, t) { return v.concat(t) }, function(k) { return [[k,true]] }, function(k, v) { return [[k,v]] }, function(v, t) { var r=[]; for (var i in v) r=r.concat(v[i]); r=r.concat(t); return r; }, function(v, t) { var r=[]; for (var i in v) r=r.concat(v[i]); r=r.concat(t); return r; }, function(v) { return v[0][1] }, function(o) { var v=[]; for (var i in o) v.push(o[i][0][1]); return v; }, function(k) {return k}, function(k, v) { k.push(v); return k; }, function(v) { CheckScope(v,"parameter/as/given"); if (!options.globals[v]) addLocal(lp+v); return [[ 'local',lp+v ]]; }, function(v, c) { if (c) { v=c[0]+v+c[1]; } return v; }, function(l, o, r) { return '('+l+o+r+')' }, function(l, r) { return '($AI.xor_op('+l+','+r+'))' }, function(l, r) { return '(!('+l+' && '+r+'))' }, function(l, r) { return '(!('+l+' || '+r+'))' }, "??", peg$literalExpectation("??", false), "::", peg$literalExpectation("::", false), function(l, a, b) { return RV('((^{l})?(^{a}):(^{b}))',{l:l,a:a,b:b}); }, function(l) { return l }, function(l, result) { return result; }, function() { return '&&' }, function() { return '||' }, function(l, o, r) { return o+'('+l+','+r+')' }, ">=", peg$literalExpectation(">=", false), function() { return '>=' }, ">", peg$literalExpectation(">", false), function() { return '>' }, "=", peg$literalExpectation("=", false), function() { return '==' }, function() { return '!==' }, function() { return '===' }, "<=", peg$literalExpectation("<=", false), function() { return '<=' }, "<>", peg$literalExpectation("<>", false), function() { return '!=' }, "<", peg$literalExpectation("<", false), function() { return '<' }, function() { return '$AI.max_op' }, function() { return '$AI.min_op' }, "<=>", peg$literalExpectation("<=>", false), function() { return '$AI.compare_op' }, function() {return '|' }, function() {return '&'}, function() { return '^'}, function(l, v) { // test 'default*' SafetyFetch=true; return RV('((undefined!==($_b=^{l}))?$_b:^{v})',{l:l,v:v}); }, function(l, v) { // test 'initialized*' SafetyFetch=true; return RV('((undefined!==($_b=^{l}))?$_b:(^{l}=^{v}))',{l:l,v:v}); }, function(l, r) { // test '**' return 'Math.pow('+l+','+r+')' }, function(l, r) { return '('+l+').isof['+r+']'; }, "...", peg$literalExpectation("...", false), function(l, c) { c[0].base=l; return AssembleVerb(c); }, function() { return '>>' }, function() { return '<<' }, function() { return '>>>' }, function(v) { return '(0-('+v+'))' }, function(v) { return '(~('+v+'))' }, function(v) { return '(!('+v+'))' }, function(v) { return 'typeof ('+v+')'; }, function(v) { return 'isNaN('+v+')'; }, function(v) { return '($AI.number_op('+v+'))'; }, function(v) { return '(undefined!=='+v+')' }, function(v) { return '$AI.clone_op('+v+')'; }, function(v) { return 'function(){return ('+v+').apply($,arguments);}'; }, function(o) { return o }, "<-", peg$literalExpectation("<-", false), function(v) { return v; }, function(v, o) { if (o) { addLocal(o); return RV('(^{out}='+v+')',{out:o}); } else { return '('+v+')'; } }, function(x) { return x }, function(op, v) { var code=''; if (v[2].length == 1) { fail("SAI Compiler: the unary (left-side) variation of the "+op.toUpperCase()+" operator needs to be followed by a list with two or more values.") code='false'; } else { var oper='||'; if (op==='and' || op==='nand') oper='&&'; code='('+v[2].join(')'+oper+'(')+')'; if (op==='nand' || op==='nor') code='!('+code+')'; code='('+code+')'; } return code; }, /^[igm]/, peg$classExpectation(["i", "g", "m"], false, false), function(x, m) { var re= '/'+x.join('')+'/'+m.join(''); return re; }, "\\/", peg$literalExpectation("\\/", false), /^[^\n\r\/]/, peg$classExpectation(["\n", "\r", "/"], true, false), /^[.([|]/, peg$classExpectation([".", "(", "[", "|"], false, false), function(v) {var hop=ResWords.hasOwnProperty(v); return hop;}, /^[a-zA-Z_]/, peg$classExpectation([["a", "z"], ["A", "Z"], "_"], false, false), /^[a-zA-Z_0-9]/, peg$classExpectation([["a", "z"], ["A", "Z"], "_", ["0", "9"]], false, false), function(v1, v2) { return v1+v2.join('') }, function() { return 'NaN' }, function() { return 'Infinity' }, function() { return 'it' }, function(v) { return AssembleVerb(v); }, "'d", peg$literalExpectation("'d", false), "!", peg$literalExpectation("!", false), function(v, b, o) { return AssembleVerb([{ base:b, verb:'.'+v, param:(o?o[1]:'')}]); }, function(v, o) { var composite=v[0]+v[1]; if (composite=='^{super}') return [{ base:'^{super}', verb:'.call', param:'$'+(o?(','+o[1]):'') }]; return [{ base:v[0], verb:v[1], param:(o?o[1]:'') }] }, function(v) { var composite=v[0]+v[1]; if (composite=='^{super}') return [{ base:'^{super}', verb:'.call', param:'$' }]; return [{ base:v[0], verb:v[1], param:'' }] }, function(v, c) { c[0].base=v; return AssembleVerb(c); }, function(l) { return l ; }, function(c) { return {left:c[0], right: c[1]} }, function(i, o) { return {verb:'.'+i, param:(o?o[1]:''), test:true}; }, function(v, o) { return '$AI.create_op('+v+',['+(o?o[1]:'undefined')+'])'; }, function(v, o) { return '$AI.singleton_op('+v+',['+(o?o[1]:'undefined')+'])'; }, function(v, o) { return 'new '+v+'('+(o?o[1]:'')+')'; }, "o", peg$literalExpectation("o", false), function(v) { return v*(Math.PI/180) }, "0b", peg$literalExpectation("0b", false), /^[0-1]/, peg$classExpectation([["0", "1"]], false, false), function(v) { var r=0; for (var i=0; i<v.length; r=r*2+Number(v[i++])); return r.toString(); }, "0o", peg$literalExpectation("0o", false), /^[0-7]/, peg$classExpectation([["0", "7"]], false, false), function(v) { var r=0; for (var i=0; i<v.length; r=r*8+Number(v[i++])); return r.toString(); }, "0x", peg$literalExpectation("0x", false), /^[0-9a-fA-F]/, peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false), function(v) { return '0x'+v.join('');}, "e", peg$literalExpectation("e", false), function(r, x) { return r+'e'+x }, function(w, f) { return Number(w+'.'+f) }, function(v) { return -v }, /^[0-9]/, peg$classExpectation([["0", "9"]], false, false), function(v) { return parseInt(v.join('')) }, "&#39", peg$literalExpectation("&#39", false), function(v) { return assembleLiteral(v) }, "&#34", peg$literalExpectation("&#34", false), "'", peg$literalExpectation("'", false), "\"", peg$literalExpectation("\"", false), /^[^'\n]/, peg$classExpectation(["'", "\n"], true, false), function(v) { return [true,v] }, /^[^"\n]/, peg$classExpectation(["\"", "\n"], true, false), "'''", peg$literalExpectation("'''", false), function(v) { return v}, function(v) { return v.join("+'\\n'+"); }, "^", peg$literalExpectation("^", false), function() { return [true, "\\"+"x5e"] }, /^[^\n]/, peg$classExpectation(["\n"], true, false), "\\'", peg$literalExpectation("\\'", false), function() { return [ true, "\x27" ] }, function(c) { return [ true, '\x5c'+c ] }, function() { return [ true, '\\x5e' ]}, "${", peg$literalExpectation("${", false), "}", peg$literalExpectation("}", false), function(v) { return [false,v] }, /^[ ]/, peg$classExpectation([" "], false, false), function(ln) { return ln[0]; }, "//", peg$literalExpectation("//", false), /^[^\r\n]/, peg$classExpectation(["\r", "\n"], true, false), function(ln) { return ln; }, /^[\n\r]/, peg$classExpectation(["\n", "\r"], false, false), ":", peg$literalExpectation(":", false), function(d) { var ln=d.join(''); return ln; }, "{", peg$literalExpectation("{", false), "__source", peg$literalExpectation("__source", false), "__offset", peg$literalExpectation("__offset", false), "__column", peg$literalExpectation("__column", false), "__line", peg$literalExpectation("__line", false), "and", peg$literalExpectation("and", false), "andb", peg$literalExpectation("andb", false), "array", peg$literalExpectation("array", false), "as", peg$literalExpectation("as", false), "bind", peg$literalExpectation("bind", false), "blank", peg$literalExpectation("blank", false), "call", peg$literalExpectation("call", false), "chain", peg$literalExpectation("chain", false), "copy", peg$literalExpectation("copy", false), "contract", peg$literalExpectation("contract", false), "counter", peg$literalExpectation("counter", false), "create", peg$literalExpectation("create", false), "default", peg$literalExpectation("default", false), "empty", peg$literalExpectation("empty", false), "enum", peg$literalExpectation("enum", false), "error", peg$literalExpectation("error", false), "exists", peg$literalExpectation("exists", false), "expects", peg$literalExpectation("expects", false), "fields", peg$literalExpectation("fields", false), "from", peg$literalExpectation("from", false), "get", peg$literalExpectation("get", false), "given", peg$literalExpectation("given", false), "Infinity", peg$literalExpectation("Infinity", false), "instance", peg$literalExpectation("instance", false), "inherit", peg$literalExpectation("inherit", false), "initialized", peg$literalExpectation("initialized", false), "isnt", peg$literalExpectation("isnt", false), "isNaN", peg$literalExpectation("isNaN", false), "is", peg$literalExpectation("is", false), "isof", peg$literalExpectation("isof", false), "Iterator", peg$literalExpectation("Iterator", false), "it", peg$literalExpectation("it", false), "key", peg$literalExpectation("key", false), "list", peg$literalExpectation("list", false), "local", peg$literalExpectation("local", false), "lsh", peg$literalExpectation("lsh", false), "main", peg$literalExpectation("main", false), "NaN", peg$literalExpectation("NaN", false), "nand", peg$literalExpectation("nand", false), "new", peg$literalExpectation("new", false), "nop", peg$literalExpectation("nop", false), "nor", peg$literalExpectation("nor", false), "not", peg$literalExpectation("not", false), "notb", peg$literalExpectation("notb", false), "number", peg$literalExpectation("number", false), "null", peg$literalExpectation("null", false), "object", peg$literalExpectation("object", false), "or", peg$literalExpectation("or", false), "orb", peg$literalExpectation("orb", false), "true", peg$literalExpectation("true", false), "false", peg$literalExpectation("false", false), "promise", peg$literalExpectation("promise", false), "process", peg$literalExpectation("process", false), "reference", peg$literalExpectation("reference", false), "rsh", peg$literalExpectation("rsh", false), "self", peg$literalExpectation("self", false), "set", peg$literalExpectation("set", false), "singleton", peg$literalExpectation("singleton", false), "sum", peg$literalExpectation("sum", false), "swap", peg$literalExpectation("swap", false), "super", peg$literalExpectation("super", false), "task", peg$literalExpectation("task", false), "traits", peg$literalExpectation("traits", false), "trial", peg$literalExpectation("trial", false), "to", peg$literalExpectation("to", false), "typeof", peg$literalExpectation("typeof", false), "unbound", peg$literalExpectation("unbound", false), "undefined", peg$literalExpectation("undefined", false), "ursh", peg$literalExpectation("ursh", false), "using", peg$literalExpectation("using", false), "xor", peg$literalExpectation("xor", false), "xorb", peg$literalExpectation("xorb", false), "#", peg$literalExpectation("#", false), function() { return ':' }, "%%INDENT%%", peg$literalExpectation("%%INDENT%%", false), "%%DEDENT%%", peg$literalExpectation("%%DEDENT%%", false), "(", peg$literalExpectation("(", false) ], peg$bytecode = [ peg$decode("%;\xD1/M#;\".\" &\"/?$$;#/&#0#*;#&&&#/)$8#: #\"! )(#'#(\"'#&'#"), peg$decode("%;\x9D/1#;\xD2/($8\":!\"!!)(\"'#&'#"), peg$decode("%;\u0111/C#;\xCF/:$;\x80/1$;\xD2/($8$:\"$!!)($'#(#'#(\"'#&'#"), peg$decode("%;\u010A/\xA4#;\xCF/\x9B$;\xAE/\x92$;\xCF/\x89$;\u0100.# &;\u0115.\" &\"/u$;\xCF/l$;~.\" &\"/^$;\xCF/U$;\xD2/L$$;$0#*;$&/<$$;%0#*;%&/,$8+:#+%(&$! )(+'#(*'#()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#"), peg$decode("%;&./ &;'.) &;(.# &;}/' 8!:$!! ).# &;\xD2"), peg$decode("%;*/' 8!:$!! ).# &;\xD2"), peg$decode("%;\xF4/C#;\xCF/:$;\x84/1$;\xD2/($8$:%$!!)($'#(#'#(\"'#&'#"), peg$decode("%;\xE5/C#;\xCF/:$;\x84/1$;\xD2/($8$:&$!!)($'#(#'#(\"'#&'#"), peg$decode("%;\xAE/A#;)/8$;).\" &\"/*$8#:'##\"! )(#'#(\"'#&'#"), peg$decode("%;\xCF/k#;\xF0.# &;\u0114/\\$;\xCF/S$;\x9B.\" &\"/E$;\xCF/<$;2/3$;\xD2/*$8':('#%#!)(''#(&'#(%'#($'#(#'#(\"'#&'#"), peg$decode("%;+/;#;2/2$;\xD2/)$8#:)#\"\"!)(#'#(\"'#&'#"), peg$decode("%;\xAE/\xA2#;\xCF/\x99$;\u011C.\" &\"/\x8B$;\xCF/\x82$;\u011E.\" &\"/t$;\xCF/k$;\u0119/b$;\xCF/Y$;1.\" &\"/K$;\xCF/B$;\x9B.\" &\"/4$;\xCF/+$8,:*,$+'#!)(,'#(+'#(*'#()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#.\u013B &%;,/\xA2#;\xCF/\x99$;\u011C.\" &\"/\x8B$;\xCF/\x82$;\u011E.\" &\"/t$;\xCF/k$;\u0110/b$;\xCF/Y$;1.\" &\"/K$;\xCF/B$;\x9B.\" &\"/4$;\xCF/+$8,:+,$+'#!)(,'#(+'#(*'#()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#.\xAC &%;\xAE/\xA2#;\xCF/\x99$;\u011C.\" &\"/\x8B$;\xCF/\x82$;\u011E.\" &\"/t$;\xCF/k$;\u010F/b$;\xCF/Y$;1.\" &\"/K$;\xCF/B$;\x9B.\" &\"/4$;\xCF/+$8,:,,$+'#!)(,'#(+'#(*'#()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#"), peg$decode("%;\xFA/' 8!:-!! )./ &%;\xAE/' 8!:.!! )"), peg$decode("%;1.\" &\"/S#;\xCF/J$;\x9B.\" &\"/<$;\xCF/3$;2/*$8%:/%#$\" )(%'#($'#(#'#(\"'#&'#.\x7F &%;1.\" &\"/p#;\xCF/g$;\x9B.\" &\"/Y$;\xCF/P$20\"\"6071.\" &\"/<$;\xCF/3$;\x9D/*$8':2'#&$ )(''#(&'#(%'#($'#(#'#(\"'#&'#"), peg$decode("%;1.\" &\"/S#;\xCF/J$;\x9B.\" &\"/<$;\xCF/3$;2/*$8%:3%#$\" )(%'#($'#(#'#(\"'#&'#.\x7F &%;1.\" &\"/p#;\xCF/g$;\x9B.\" &\"/Y$;\xCF/P$20\"\"6071.\" &\"/<$;\xCF/3$;\x9D/*$8':3'#&$ )(''#(&'#(%'#($'#(#'#(\"'#&'#"), peg$decode("%;1.\" &\"/S#;\xCF/J$;\x9B.\" &\"/<$;\xCF/3$;2/*$8%:4%#$\" )(%'#($'#(#'#(\"'#&'#"), peg$decode("%;x/I#;\xCF/@$;\x85.\" &\"/2$;\xCF/)$8$:5$\"#!)($'#(#'#(\"'#&'#"), peg$decode("%;\xED/\x8D#;\xCF/\x84$$%;0/:#;\u0128/1$;\xCF/($8#:6#!\")(#'#(\"'#&'#0D*%;0/:#;\u0128/1$;\xCF/($8#:6#!\")(#'#(\"'#&'#&/2$;0/)$8$:7$\"! )($'#(#'#(\"'#&'#.M &%;\xED/C#;\xCF/:$;\x85/1$;\xCF/($8$:8$!!)($'#(#'#(\"'#&'#"), peg$decode("%;\xCF/j#;\xD2/a$;\u012A/X$;\xD2/O$;3/F$;\u012B/=$%<;\xD2=/##&'!&&#/($8':$'!\")(''#(&'#(%'#($'#(#'#(\"'#&'#.h &%;\xCF/^#29\"\"697:/O$;\xCF/F$;5/=$%<;\xD2=/#