diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..51d8ee7 --- /dev/null +++ b/.npmignore @@ -0,0 +1,6 @@ +*.test.js +docs/ +examples/ +__snapshots__ +.cache +dist/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 20d15cb..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "python.linting.pylintEnabled": false -} \ No newline at end of file diff --git a/README.md b/README.md index 1ed79db..923359b 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ run( ``` ## Parsing -YALI.js also provides a `parse` function to tokenize and parse lox source code, returning an array of AST nodes that can be manipulated as desired. See any of the [transpiler examples](./transpilers/python) for reference. +YALI.js also provides a `parse` function to tokenize and parse lox source code, returning an array of AST nodes that can be manipulated as desired. See any of the [transpiler examples](./transpilers/python.js) for reference. ## Contribute diff --git a/docs/browser.e9f8be96.js b/docs/browser.e9f8be96.js index 57e24a6..c112cc1 100644 --- a/docs/browser.e9f8be96.js +++ b/docs/browser.e9f8be96.js @@ -9,11 +9,11 @@ function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as },{"./tokenizer":"u74b","./types":"39eF","./errors":"p8GN"}],"brut":[function(require,module,exports) { function e(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function n(e,n){for(var t=0;t1?e-1:0),i=1;i2&&void 0!==arguments[2]&&arguments[2],i=new R(this.closure),r=0;r")}}]),t}(),q=function(t){function n(t,r,a){var o;return s(this,n),(o=e(this,i(n).call(this))).name=t,o.methods=r,o.superclass=a,o}return r(n,Q),u(n,[{key:"call",value:function(t,e){var n=new I(this),i=this.methods.get("init");return i&&i.bind(n).call(t,e,!0),n}},{key:"getMethod",value:function(t,e){return this.methods.has(t)?this.methods.get(t).bind(e):this.superclass?this.superclass.getMethod(t,e):null}},{key:"toString",value:function(){return"<".concat(this.name,">")}}]),n}(),I=function(){function t(e){s(this,t),this.klass=e,this.fields=new Map}return u(t,[{key:"get",value:function(t){var e=t.lexeme;if(this.fields.has(e))return this.fields.get(e);var n=this.klass.getMethod(e,this);if(n)return n;throw c('Undefined property "'.concat(e,'"'),t)}},{key:"set",value:function(t,e){var n=t.lexeme;this.fields.set(n,e)}},{key:"toString",value:function(){return"<+".concat(this.klass.name,">")}}]),t}(),z=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:console.log;s(this,t),this.printfunction=n,this.environment=e||new R,this.environment.setBuiltin("PI",Math.PI),this.environment.setBuiltin("cos",function(t,e){return Math.cos(e[0])}),this.environment.setBuiltin("mod",function(t,e){return e[0]%e[1]}),this.environment.setBuiltin("strlen",function(t,e){return e[0].length}),this.environment.setBuiltin("charAt",function(t,e){return e[0][e[1]]}),this.environment.setBuiltin("clock",function(){return(new Date).getTime()})}return u(t,[{key:"interpret",value:function(t){return this.evaluate(t)}},{key:"evaluate",value:function(t){return t instanceof L?this.visitBlock(t):t instanceof O?this.visitFunction(t):t instanceof G?this.visitAssignment(t):t instanceof g?this.visitClass(t):t instanceof w?this.visitGet(t):t instanceof S?this.visitSet(t):t instanceof B?this.visitThis(t):t instanceof k?this.visitSuper(t):t instanceof d?this.visitLogical(t):t instanceof y?this.visitCall(t):t instanceof A?this.visitWhile(t):t instanceof P?this.visitCondition(t):t instanceof _?this.visitVarStatement(t):t instanceof C?this.visitPrintStatement(t):t instanceof E?this.visitReturnStatement(t):t instanceof U?this.visitGrouping(t):t instanceof x?this.visitGrouping(t):t instanceof b?this.visitVar(t):t instanceof p?this.visitLiteral(t):t instanceof m?this.visitUnary(t):t instanceof f?this.visitBinary(t):void 0}},{key:"visitLiteral",value:function(t){return t.value}},{key:"visitGrouping",value:function(t){return this.evaluate(t.expression)}},{key:"visitPrintStatement",value:function(t){var e=this.evaluate(t.expression);return this.printfunction(null===e?"nil":e.toString()),e}},{key:"visitFunction",value:function(t){var e=new Q(t,this.environment);this.environment.set(t.name,e)}},{key:"visitLogical",value:function(t){var e=this.evaluate(t.left);if(t.operator.type===j.OR){if(T(e))return e}else if(!T(e))return e;return this.evaluate(t.right)}},{key:"visitWhile",value:function(t){for(;T(this.evaluate(t.condition));)this.evaluate(t.body);return null}},{key:"visitReturnStatement",value:function(t){var e=null;throw t.value&&(e=this.evaluate(t.value)),new v(e)}},{key:"visitVar",value:function(t){return this.environment.get(t)}},{key:"visitVarStatement",value:function(t){var e=null;return null!==t.initializer&&(e=this.evaluate(t.initializer)),this.environment.set(t.name,e),null}},{key:"visitClass",value:function(t){var e=null;if(t.superclass&&!((e=this.evaluate(t.superclass))instanceof q))throw c("Superclass must be a class",t.superclass.name);this.environment.set(t.name,null),e&&(this.environment=new R(this.environment),this.environment.set({lexeme:"super"},e));var n=new Map,i=!0,r=!1,a=void 0;try{for(var s,o=t.methods[Symbol.iterator]();!(i=(s=o.next()).done);i=!0){var u=s.value,l=new Q(u,this.environment);n.set(u.name.lexeme,l)}}catch(h){r=!0,a=h}finally{try{i||null==o.return||o.return()}finally{if(r)throw a}}var v=new q(t.name.lexeme,n,e);return e&&(this.environment=this.environment.enclosing),this.environment.assign(t.name,v),null}},{key:"visitGet",value:function(t){var e=this.evaluate(t.object);if(e instanceof I)return e.get(t.name);throw c("Only instances have properties",t.name)}},{key:"visitSet",value:function(t){var e=this.evaluate(t.object);if(!(e instanceof I))throw c("Only instances have fields",t.name);var n=this.evaluate(t.value);return e.set(t.name,n)}},{key:"visitThis",value:function(t){return this.environment.get({name:t.keyword})}},{key:"visitSuper",value:function(t){var e=t.method.lexeme,n=this.environment.get(new b(t.keyword)),i=this.environment.get(new b({lexeme:"this"})),r=n.getMethod(e,i);if(!r)throw c('Undefined property "'.concat(e,'"'),t.method);return r}},{key:"visitBlock",value:function(t){return this.interpretBlock(t.statements,new R(this.environment)),null}},{key:"visitCondition",value:function(t){return T(this.evaluate(t.condition))?this.evaluate(t.thenBranch):t.elseBranch&&this.evaluate(t.elseBranch),null}},{key:"interpretBlock",value:function(t,e){var n=this.environment;try{this.environment=e;var i=!0,r=!1,a=void 0;try{for(var s,o=t[Symbol.iterator]();!(i=(s=o.next()).done);i=!0){var u=s.value;this.interpret(u)}}catch(l){r=!0,a=l}finally{try{i||null==o.return||o.return()}finally{if(r)throw a}}this.environment=n}catch(c){throw this.environment=n,c}}},{key:"visitAssignment",value:function(t){var e=this.evaluate(t.value);return this.environment.assign(t.name,e),e}},{key:"visitCall",value:function(t){var e=this,n=this.evaluate(t.callee),i=t.arguments.map(function(t){return e.evaluate(t)});if(!n.call)throw c("Can only call functions and classes",t.paren);return n.call(this,i)}},{key:"visitUnary",value:function(t){var e=this.evaluate(t.right);switch(t.operator.type){case j.MINUS:return V(t.operator,e),-e;case j.BANG:return!T(e)}}},{key:"visitBinary",value:function(t){var e=this.evaluate(t.left),n=this.evaluate(t.right);switch(t.operator.type){case j.MINUS:return V(t.operator,n,e),e-n;case j.PLUS:return e+n;case j.SLASH:return V(t.operator,n,e),e/n;case j.STAR:return V(t.operator,n,e),e*n;case j.GREATER:return V(t.operator,n,e),e>n;case j.GREATER_EQUAL:return V(t.operator,n,e),e>=n;case j.LESS:return V(t.operator,n,e),e1?e-1:0),i=1;i2&&void 0!==arguments[2]&&arguments[2],i=new R(this.closure),r=0;r")}}]),t}(),Q=function(t){function n(t,r,a){var o;return s(this,n),(o=e(this,i(n).call(this))).name=t,o.methods=r,o.superclass=a,o}return r(n,V),u(n,[{key:"call",value:function(t,e){var n=new q(this),i=this.methods.get("init");return i&&i.bind(n).call(t,e,!0),n}},{key:"getMethod",value:function(t,e){return this.methods.has(t)?this.methods.get(t).bind(e):this.superclass?this.superclass.getMethod(t,e):null}},{key:"toString",value:function(){return"<".concat(this.name,">")}}]),n}(),q=function(){function t(e){s(this,t),this.klass=e,this.fields=new Map}return u(t,[{key:"get",value:function(t){var e=t.lexeme;if(this.fields.has(e))return this.fields.get(e);var n=this.klass.getMethod(e,this);if(n)return n;throw c('Undefined property "'.concat(e,'"'),t)}},{key:"set",value:function(t,e){var n=t.lexeme;this.fields.set(n,e)}},{key:"toString",value:function(){return"<+".concat(this.klass.name,">")}}]),t}(),z=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:console.log;s(this,t),this.printfunction=n,this.environment=e||new R,this.environment.setBuiltin("PI",Math.PI),this.environment.setBuiltin("cos",function(t,e){return Math.cos(e[0])}),this.environment.setBuiltin("mod",function(t,e){return e[0]%e[1]}),this.environment.setBuiltin("strlen",function(t,e){return e[0].length}),this.environment.setBuiltin("charAt",function(t,e){return e[0][e[1]]}),this.environment.setBuiltin("clock",function(){return(new Date).getTime()})}return u(t,[{key:"interpret",value:function(t){return this.evaluate(t)}},{key:"evaluate",value:function(t){return t instanceof A?this.visitBlock(t):t instanceof O?this.visitFunction(t):t instanceof G?this.visitAssignment(t):t instanceof g?this.visitClass(t):t instanceof w?this.visitGet(t):t instanceof S?this.visitSet(t):t instanceof B?this.visitThis(t):t instanceof k?this.visitSuper(t):t instanceof d?this.visitLogical(t):t instanceof y?this.visitCall(t):t instanceof L?this.visitWhile(t):t instanceof P?this.visitCondition(t):t instanceof C?this.visitVarStatement(t):t instanceof _?this.visitPrintStatement(t):t instanceof E?this.visitReturnStatement(t):t instanceof U?this.visitGrouping(t):t instanceof x?this.visitGrouping(t):t instanceof b?this.visitVar(t):t instanceof p?this.visitLiteral(t):t instanceof m?this.visitUnary(t):t instanceof f?this.visitBinary(t):void 0}},{key:"visitLiteral",value:function(t){return t.value}},{key:"visitGrouping",value:function(t){return this.evaluate(t.expression)}},{key:"visitPrintStatement",value:function(t){var e=this.evaluate(t.expression);return this.printfunction(null===e?"nil":e.toString()),e}},{key:"visitFunction",value:function(t){var e=new V(t,this.environment);this.environment.set(t.name,e)}},{key:"visitLogical",value:function(t){var e=this.evaluate(t.left);if(t.operator.type===j.OR){if(T(e))return e}else if(!T(e))return e;return this.evaluate(t.right)}},{key:"visitWhile",value:function(t){for(;T(this.evaluate(t.condition));)this.evaluate(t.body);return null}},{key:"visitReturnStatement",value:function(t){var e=null;throw t.value&&(e=this.evaluate(t.value)),new v(e)}},{key:"visitVar",value:function(t){return this.environment.get(t)}},{key:"visitVarStatement",value:function(t){var e=null;return null!==t.initializer&&(e=this.evaluate(t.initializer)),this.environment.set(t.name,e),null}},{key:"visitClass",value:function(t){var e=null;if(t.superclass&&!((e=this.evaluate(t.superclass))instanceof Q))throw c("Superclass must be a class",t.superclass.name);this.environment.set(t.name,null),e&&(this.environment=new R(this.environment),this.environment.set({lexeme:"super"},e));var n=new Map,i=!0,r=!1,a=void 0;try{for(var s,o=t.methods[Symbol.iterator]();!(i=(s=o.next()).done);i=!0){var u=s.value,l=new V(u,this.environment);n.set(u.name.lexeme,l)}}catch(h){r=!0,a=h}finally{try{i||null==o.return||o.return()}finally{if(r)throw a}}var v=new Q(t.name.lexeme,n,e);return e&&(this.environment=this.environment.enclosing),this.environment.assign(t.name,v),null}},{key:"visitGet",value:function(t){var e=this.evaluate(t.object);if(e instanceof q)return e.get(t.name);throw c("Only instances have properties",t.name)}},{key:"visitSet",value:function(t){var e=this.evaluate(t.object);if(!(e instanceof q))throw c("Only instances have fields",t.name);var n=this.evaluate(t.value);return e.set(t.name,n)}},{key:"visitThis",value:function(t){return this.environment.get({name:t.keyword})}},{key:"visitSuper",value:function(t){var e=t.method.lexeme,n=this.environment.get(new b(t.keyword)),i=this.environment.get(new b({lexeme:"this"})),r=n.getMethod(e,i);if(!r)throw c('Undefined property "'.concat(e,'"'),t.method);return r}},{key:"visitBlock",value:function(t){return this.interpretBlock(t.statements,new R(this.environment)),null}},{key:"visitCondition",value:function(t){return T(this.evaluate(t.condition))?this.evaluate(t.thenBranch):t.elseBranch&&this.evaluate(t.elseBranch),null}},{key:"interpretBlock",value:function(t,e){var n=this.environment;try{this.environment=e;var i=!0,r=!1,a=void 0;try{for(var s,o=t[Symbol.iterator]();!(i=(s=o.next()).done);i=!0){var u=s.value;this.interpret(u)}}catch(l){r=!0,a=l}finally{try{i||null==o.return||o.return()}finally{if(r)throw a}}this.environment=n}catch(c){throw this.environment=n,c}}},{key:"visitAssignment",value:function(t){var e=this.evaluate(t.value);return this.environment.assign(t.name,e),e}},{key:"visitCall",value:function(t){var e=this,n=this.evaluate(t.callee),i=t.arguments.map(function(t){return e.evaluate(t)});if(!n.call)throw c("Can only call functions and classes",t.paren);return n.call(this,i)}},{key:"visitUnary",value:function(t){var e=this.evaluate(t.right);switch(t.operator.type){case j.MINUS:return N(t.operator,e),-e;case j.BANG:return!T(e)}}},{key:"visitBinary",value:function(t){var e=this.evaluate(t.left),n=this.evaluate(t.right);switch(t.operator.type){case j.MINUS:return N(t.operator,n,e),e-n;case j.PLUS:return e+n;case j.SLASH:return N(t.operator,n,e),e/n;case j.STAR:return N(t.operator,n,e),e*n;case j.GREATER:return N(t.operator,n,e),e>n;case j.GREATER_EQUAL:return N(t.operator,n,e),e>=n;case j.LESS:return N(t.operator,n,e),e3&&void 0!==arguments[3]&&arguments[3],l=new r(o).scanTokens();i&&console.log(l);var u=new e(l).parse();i&&console.log(u);var v,s=new n(t,a),c=!0,p=!1,f=void 0;try{for(var w,y=u[Symbol.iterator]();!(c=(w=y.next()).done);c=!0){var d=w.value;v=s.interpret(d)}}catch(m){p=!0,f=m}finally{try{c||null==y.return||y.return()}finally{if(p)throw f}}return v},a=function(n){var o=new r(n).scanTokens();return new e(o).parse()};module.exports={run:t,parse:a,Environment:o}; +var e=require("./tokenizer"),r=require("./parser"),n=require("./interpreter"),t=n.Interpreter,o=n.LoxClass,a=n.LoxInstance,i=require("./environment"),s=function(n,o,a){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=new e(n).scanTokens();i&&console.log(s);var l=new r(s).parse();i&&console.log(l);var u,v=new t(o,a),c=!0,p=!1,f=void 0;try{for(var w,x=l[Symbol.iterator]();!(c=(w=x.next()).done);c=!0){var y=w.value;u=v.interpret(y)}}catch(d){p=!0,f=d}finally{try{c||null==x.return||x.return()}finally{if(p)throw f}}return u},l=function(n){var t=new e(n).scanTokens();return new r(t).parse()};module.exports={run:s,parse:l,Parser:r,LoxClass:o,Tokenizer:e,LoxInstance:a,Interpreter:t,Environment:i}; },{"./tokenizer":"u74b","./parser":"CUYV","./interpreter":"lmrS","./environment":"brut"}],"9/6S":[function(require,module,exports) { -function n(n){return r(n)||e(n)||t()}function t(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function e(n){if(Symbol.iterator in Object(n)||"[object Arguments]"===Object.prototype.toString.call(n))return Array.from(n)}function r(n){if(Array.isArray(n)){for(var t=0,e=new Array(n.length);t1&&void 0!==arguments[1]?arguments[1]:" ";return n?t:""},w=new Map;w.set(g,function(n,t,e){return E(n.expression,0,e)+("forLoop"===n.context?"":";")}),w.set(v,function(n){return"print "+E(n.expression)+";"}),w.set(p,function(n){return"return "+E(n.value)+";"}),w.set(d,function(n){var t=n.name.lexeme,e=n.initializer?E(n.initializer):null;return"var ".concat(t)+(e?" = ".concat(e):"")+";"}),w.set(j,function(n,t,e){var r=n.condition,o=n.thenBranch,a=n.elseBranch,c=E(r),i="if".concat(b(e.spaceBeforeParams),"(").concat(c,") "),u=E(o,t,e,!1),s=a&&E(a,t,e,!1);return i+u+(s?" else ".concat(s):"")}),w.set(m,function(t,e,r){var o=t.bodyStatements,a=t.name.lexeme,c=t.params.map(function(n){return n.lexeme}),i="fun ".concat(a).concat(b(r.spaceBeforeParams),"(").concat(c.join(", "),") {"),u=o.map(function(n){return E(n,e+1,r)}),s=r.indent.repeat(e)+"}"+b(r.functionNewlines,"\n");return[i].concat(n(u),[s]).join("\n")});var B=function(n,t,e){var r=n.body,o=n.condition,a=E(o);return"while".concat(b(e.spaceBeforeParams),"(").concat(a,") ")+E(r,t,e,!1)},L=function(n,t,e){var r=n.body,o=n.condition,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:";",c="forLoop"!==o.context?E(o):"",i="",u=r;if(r instanceof y&&"forLoop"===r.context){var s=r.statements;u=s[0],s.length>1&&(i=E(s[s.length-1],t,e,!1))}var f=E(u,t,e,!1),l=[c,i];return"for".concat(b(e.spaceBeforeParams),"(").concat(a," ").concat(l.join("; "),") ").concat(f)};w.set(f,function(n,t,e){return"forLoop"===n.context?L(n,t,e):B(n,t,e)});var A=function(n,t,e){var r=n.statements,o=E(r[0],t,e,!1);return L(r[1],t,e,o)},S=function(n,t,e){return"{\n"+n.statements.map(function(n){return E(n,t+1,e)}).join("\n")+"\n".concat(e.indent.repeat(t),"}")};w.set(y,function(n,t,e){return"forLoop"===n.context?A(n,t,e):S(n,t,e)}),w.set(i,function(n){return n.name.lexeme}),w.set(l,function(n){var t=n.expression;return"("+E(t)+")"});var P=function(n){return[E(n.left),n.operator.lexeme,E(n.right)].join(" ")};w.set(a,P),w.set(x,P),w.set(c,function(n){return n.operator.lexeme+E(n.right)}),w.set(u,function(n){var t=n.arguments.map(function(n){return E(n)}).join(", "),e=E(n.callee);return"".concat(e,"(").concat(t,")")}),w.set(h,function(n){return n.name.lexeme+" = "+E(n.value)}),w.set(s,function(n){var t=n.value;return"string"==typeof t?'"'.concat(t,'"'):null===t?"nil":t});var E=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=Object.assign({},{indent:"\t",spaceBeforeParams:!0,functionNewlines:!0},e);if(w.has(n.constructor))return(r?o.indent.repeat(t):"")+w.get(n.constructor)(n,t,o);throw new Error("Don't support classes yet",n.constructor)};module.exports={printLoxAST:E}; +function n(n){return r(n)||e(n)||t()}function t(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function e(n){if(Symbol.iterator in Object(n)||"[object Arguments]"===Object.prototype.toString.call(n))return Array.from(n)}function r(n){if(Array.isArray(n)){for(var t=0,e=new Array(n.length);t1&&void 0!==arguments[1]?arguments[1]:" ";return n?t:""},w=new Map;w.set(g,function(n,t,e){return E(n.expression,0,e)+("forLoop"===n.context?"":";")}),w.set(v,function(n){return"print "+E(n.expression)+";"}),w.set(p,function(n){return"return "+E(n.value)+";"}),w.set(d,function(n){var t=n.name.lexeme,e=n.initializer?E(n.initializer):null;return"var ".concat(t)+(e?" = ".concat(e):"")+";"}),w.set(j,function(n,t,e){var r=n.condition,o=n.thenBranch,a=n.elseBranch,c=E(r),i="if".concat(b(e.spaceBeforeParams),"(").concat(c,") "),u=E(o,t,e,!1),s=a&&E(a,t,e,!1);return i+u+(s?" else ".concat(s):"")}),w.set(m,function(t,e,r){var o=t.bodyStatements,a=t.name.lexeme,c=t.params.map(function(n){return n.lexeme}),i="fun ".concat(a).concat(b(r.spaceBeforeParams),"(").concat(c.join(", "),") {"),u=o.map(function(n){return E(n,e+1,r)}),s=r.indent.repeat(e)+"}"+b(r.functionNewlines,"\n");return[i].concat(n(u),[s]).join("\n")});var B=function(n,t,e){var r=n.body,o=n.condition,a=E(o);return"while".concat(b(e.spaceBeforeParams),"(").concat(a,") ")+E(r,t,e,!1)},L=function(n,t,e){var r=n.body,o=n.condition,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:";",c="forLoop"!==o.context?E(o):"",i="",u=r;if(r instanceof y&&"forLoop"===r.context){var s=r.statements;u=s[0],s.length>1&&(i=E(s[s.length-1],t,e,!1))}var f=E(u,t,e,!1),l=[c,i];return"for".concat(b(e.spaceBeforeParams),"(").concat(a," ").concat(l.join("; "),") ").concat(f)};w.set(f,function(n,t,e){return"forLoop"===n.context?L(n,t,e):B(n,t,e)});var A=function(n,t,e){var r=n.statements,o=E(r[0],t,e,!1);return L(r[1],t,e,o)},S=function(n,t,e){return"{\n"+n.statements.map(function(n){return E(n,t+1,e)}).join("\n")+"\n".concat(e.indent.repeat(t),"}")};w.set(y,function(n,t,e){return"forLoop"===n.context?A(n,t,e):S(n,t,e)}),w.set(i,function(n){return n.name.lexeme}),w.set(l,function(n){var t=n.expression;return"("+E(t)+")"});var P=function(n){return[E(n.left),n.operator.lexeme,E(n.right)].join(" ")};w.set(a,P),w.set(x,P),w.set(c,function(n){return n.operator.lexeme+E(n.right)}),w.set(u,function(n){var t=n.arguments.map(function(n){return E(n)}).join(", "),e=E(n.callee);return"".concat(e,"(").concat(t,")")}),w.set(h,function(n){return n.name.lexeme+" = "+E(n.value)}),w.set(s,function(n){var t=n.value;return"string"==typeof t?'"'.concat(t,'"'):null===t?"nil":t});var E=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=Object.assign({},{indent:"\t",spaceBeforeParams:!0,functionNewlines:!0},e);if(w.has(n.constructor))return(r?o.indent.repeat(t):"")+w.get(n.constructor)(n,t,o);throw new Error("Don't support classes yet")};module.exports={printLoxAST:E}; },{"../types":"39eF"}],"KVVd":[function(require,module,exports) { },{}],"3hpa":[function(require,module,exports) { diff --git a/package.json b/package.json index 86bd908..5dcf2ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yali", - "version": "0.10.2", + "version": "1.0.0", "description": "Yet Another Lox Interpreter. Javascript Implementation of the Lox Programming Language", "main": "index.js", "bin": {