earlgrey
Version:
Programming language compiling to JavaScript, featuring macros, dynamic typing annotations and pattern matching.
4 lines (2 loc) • 11 kB
JavaScript
'use strict';require('earlgrey-runtime/5');var $targ$1=void 0;var $targ$0=void 0;var $0$0=void 0;var unescape$0=void 0;var $1$0=void 0;var Source$0=void 0;var $2$0=void 0;var qq$0=void 0;var overridable$0=void 0;var opg$0=void 0;$0$0=require("../lex");unescape$0=getProperty($0$0,"unescape","../lex");$1$0=require("../location");Source$0=getProperty($1$0,"Source","../location");$2$0=require("./helpers");qq$0=getProperty($2$0,"qq","./helpers");overridable$0=getProperty($2$0,"overridable","./helpers");opg$0=require("opg");if(typeof module==="undefined"){$targ$1=undefined;global["module"]=$targ$1;void 0;}$targ$0=function $targ$0(mac$0){var t0$3=void 0;var t0$6=void 0;var t0$17=void 0;var t1$10=void 0;var t0$21=void 0;var $targ$2=void 0;var unquote_mac$0=void 0;var $targ$3=void 0;var quote_mac$0=void 0;var tok$0=void 0;var gr$0=void 0;var prio$0=void 0;var finalize$0=void 0;var parser$0=void 0;var parse$0=void 0;var $targ$4=void 0;var wq_mac$0=void 0;var $targ$5=void 0;var interpolate_mac$0=void 0;var exports$0=void 0;exports$0={};$targ$2=function $targ$2(temp$0$0,info$0,form$0,expr$0){var t0$0=void 0;var x$0=void 0;var t0$2=void 0;var t1$1=void 0;var t2$0=void 0;var t3$0=void 0;var $targ$6=void 0;var x$1=void 0;var t0$1=void 0;var t1$0=void 0;var context$0=void 0;var ph$0$0=void 0;t0$0=temp$0$0;context$0=t0$0;ph$0$0=t0$0;t0$1=ph$0$0;t1$0=t0$1.length;if(t1$0===2&&t0$1[0]==="expr"&&t0$1[1]==="head"){return["nostep"];}else{if(x$0=ph$0$0,x$0 instanceof Array&&x$0[0]==="pattern"){$targ$6=expr$0;t0$2=$targ$6;if(Array.isArray(t0$2)&&(t1$1=t0$2.length,t1$1===3&&t0$2[0]==="data"&&(t2$0=t0$2[1],Array.isArray(t2$0)&&(t3$0=t2$0.length,t3$0===1&&t2$0[0]==="void")))){x$1=t0$2[2];}else{___match_error($targ$6,"#data{#void{}, x}");}return["calc",x$1];}else{throw send(send(ErrorFactory(["syntax","unquote"]),"create",true),__amp____colon__(["Cannot unquote in context "+context$0+"."],{"expr":expr$0,"::objinsert":1}));}}};t0$3=getProjector(mac$0("^"))($targ$2);if(t0$3[0]){unquote_mac$0=t0$3[1];}else{___match_error($targ$2,"mac{\"^\"}! unquote_mac{match context, info, form, expr}");}$targ$3=function $targ$3(temp$1$0,info$1,form$1,temp$2$0){var t0$4=void 0;var t0$5=void 0;var t1$2=void 0;var parsed$0=void 0;var context$1=void 0;var ph$1$0=void 0;var expr$1=void 0;var s$0=void 0;t0$4=temp$1$0;context$1=t0$4;ph$1$0=t0$4;t0$5=temp$2$0;expr$1=t0$5;if(Array.isArray(t0$5)&&(t1$2=t0$5.length,t1$2===2&&t0$5[0]==="value")){s$0=t0$5[1];}else{___match_error(temp$2$0);}parsed$0=info$1.go(Source$0(s$0,"<quasiquote>"),"source","parse");return info$1.mark(qq$0(parsed$0));};t0$6=getProjector(mac$0("`"))($targ$3);if(t0$6[0]){quote_mac$0=t0$6[1];}else{___match_error($targ$3,"mac{\"`\"}! quote_mac{match context, info, form, expr and #value{s}}");}tok$0=opg$0.tokenize.Tokenizer({"regexps":{"open":"\\{","close":"\\}","other":"(?:\\\\.|[^\\{\\}])+"},"post":[function(temp$3$0){var t0$7=void 0;var t0$8=void 0;var tok$1=void 0;var ph$2$0=void 0;t0$7=temp$3$0;tok$1=t0$7;ph$2$0=t0$7;t0$8=ph$2$0;if(___hasprop(t0$8,"type")&&t0$8.type==="open"){return[{"token":"","type":"other","location":tok$1.location.at_start()},tok$1];}else{return tok$1;}}]});gr$0=new opg$0.parse.TokenGroups({"open":["open"],"close":["close"],"other":["str","other"]});prio$0=new opg$0.parse.PriorityOrder(gr$0,{"open":{"left":1002,"right":0},"close":{"left":0,"right":1003},"other":{"left":1000,"right":1000}});finalize$0=function finalize(temp$4$0){var t0$9=void 0;var t0$11=void 0;var t1$4=void 0;var t2$2=void 0;var tag$0=void 0;var arg$0=void 0;var text$0=void 0;var bridge$$19314$0=void 0;var m$0=void 0;var rval$0=void 0;var text$1=void 0;var args$0=void 0;var token$0=void 0;var open$0=void 0;var ph$4$0=void 0;var _arg$0=void 0;var close$0=void 0;var $$19317$0=void 0;var $$19318$0=void 0;var t0$10=void 0;var t1$3=void 0;var t2$1=void 0;var t3$1=void 0;var t4$0=void 0;var zazz$0=void 0;var ph$3$0=void 0;t0$9=temp$4$0;zazz$0=t0$9;ph$3$0=t0$9;t0$10=ph$3$0;t1$3=t0$10.length;if(t1$3===5&&t0$10[0]===null&&(t2$1=t0$10[1],___hasprop(t2$1,"type")&&t2$1.type==="open"&&___hasprop(t2$1,"token")&&(t3$1=t2$1.token,open$0=t3$1,ph$4$0=t3$1,_arg$0=t0$10[2],t4$0=t0$10[3],___hasprop(t4$0,"type")&&t4$0.type==="close"&&___hasprop(t4$0,"token")&&(close$0=t4$0.token,t0$10[4]===null)))){arg$0=_arg$0||__amp__(["join",""],{"text":""});text$0=open$0+arg$0.text+close$0;bridge$$19314$0=ph$4$0;if((t0$11=getProjector(RegExp("\\$([^\\{]*){",""))(bridge$$19314$0),t0$11[0]&&(t1$4=t0$11[1],t2$2=t1$4.length,t2$2===2&&(t1$4[0],tag$0=t1$4[1],true)))||(tag$0="",true)){return __amp____colon__(["bracket",tag$0,arg$0.text],{"text":text$0});}else{return ___match_error(ph$4$0,"R\"\\$([^\\{]*){\"! {_, tag} or tag is \"\"");}}else{if(t1$3===3&&t0$10[0]===null&&(t2$1=t0$10[1],___hasprop(t2$1,"token")&&(token$0=t2$1.token,t0$10[2]===null))){return __amp____colon__(["join",token$0],{"text":token$0});}else{args$0=ph$3$0;rval$0=["join"];text$1="";m$0=null;var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{$3:for(var _iterator=enumerate(args$0)[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){m$0=_step.value;var x$2=void 0;var sub$0=void 0;var token$1=void 0;var $$19419$0=void 0;var t0$13=void 0;var t1$6=void 0;var i$0=void 0;var arg$1=void 0;var ph$5$0=void 0;var t0$12=void 0;var t1$5=void 0;var t2$3=void 0;t0$12=m$0;if(Array.isArray(t0$12)&&(t1$5=t0$12.length,t1$5===2)){i$0=t0$12[0];t2$3=t0$12[1];arg$1=t2$3;ph$5$0=t2$3;t0$13=ph$5$0;if(___hasprop(t0$13,"token")&&(token$1=t0$13.token,equal(i$0%2,1))){rval$0.push(token$1);text$1=text$1+token$1;}else{if(Array.isArray(t0$13)&&(t1$6=t0$13.length,t1$6>=1&&t0$13[0]==="join")){sub$0=Array.prototype.slice.call(t0$13,1);text$1=text$1+arg$1.text;rval$0=rval$0.concat(sub$0);}else{if(x$2=ph$5$0,x$2 instanceof Array&&x$2[0]==="bracket"){text$1=text$1+arg$1.text;rval$0.push(arg$1);}else{if(ph$5$0===null){undefined;}else{___match_error(ph$5$0);}}}}}else{___match_error(m$0);}}}catch(err){_didIteratorError=true;_iteratorError=err;}finally{try{if(!_iteratorNormalCompletion&&_iterator.return){_iterator.return();}}finally{if(_didIteratorError){throw _iteratorError;}}}return __amp____colon__(rval$0,{"text":text$1});}}};parser$0=new opg$0.parse.Parser(tok$0,prio$0.getOrder(),finalize$0);parse$0=function parse(text$2){return parser$0.parse(text$2);};$targ$4=function $targ$4(context$2,info$2,form$2,temp$5$0){var t0$14=void 0;var t1$7=void 0;var f$0=void 0;var f$1=void 0;var v$0=void 0;var $$19501$0=void 0;var $$19502$0=void 0;var $$19503$0=void 0;var t0$16=void 0;var t1$9=void 0;var t2$5=void 0;var t3$3=void 0;var elements$0=void 0;var ph$6$0=void 0;var t0$15=void 0;var t1$8=void 0;var t2$4=void 0;var t3$2=void 0;var t4$1=void 0;var t5$0=void 0;var t6$0=void 0;var t7$0=void 0;var t8$0=void 0;var t9$0=void 0;var t10$0=void 0;var t11$0=void 0;var t12$0=void 0;var m$1$0=void 0;var x$3=void 0;t0$14=temp$5$0;if(Array.isArray(t0$14)&&(t1$7=t0$14.length,t1$7===2&&t0$14[0]==="data")){x$3=t0$14[1];}else{___match_error(temp$5$0);}m$1$0=x$3;if(Array.isArray(m$1$0)&&(t0$15=m$1$0.length,t0$15===3&&m$1$0[0]==="send"&&(t1$8=m$1$0[1],Array.isArray(t1$8)&&(t2$4=t1$8.length,t2$4===2&&t1$8[0]==="symbol"&&t1$8[1]==="ENode"&&(t3$2=m$1$0[2],Array.isArray(t3$2)&&(t4$1=t3$2.length,t4$1===4&&t3$2[0]==="data"&&(t5$0=t3$2[1],Array.isArray(t5$0)&&(t6$0=t5$0.length,t6$0===1&&t5$0[0]==="data"&&(t7$0=t3$2[2],Array.isArray(t7$0)&&(t8$0=t7$0.length,t8$0===2&&t7$0[0]==="data"&&(t9$0=t7$0[1],Array.isArray(t9$0)&&(t10$0=t9$0.length,t10$0===2&&t9$0[0]==="symbol"&&t9$0[1]==="="&&(t11$0=t3$2[3],Array.isArray(t11$0)&&(t12$0=t11$0.length,t12$0>=1&&t11$0[0]==="data")))))))))))))){elements$0=Array.prototype.slice.call(t11$0,1);ph$6$0=elements$0;t0$16=ph$6$0;if(($$19502$0=Array.isArray(t0$16))&&(t1$9=t0$16.length,t1$9===1&&(t2$5=t0$16[0],v$0=t2$5,Array.isArray(t2$5)&&(t3$3=t2$5.length,t3$3===2&&t2$5[0]==="value"&&typeof t2$5[1]==="string")))){return v$0;}else{if($$19502$0&&t1$9>=1&&(t2$5=t0$16[0],Array.isArray(t2$5)&&(t3$3=t2$5.length,t3$3===2&&t2$5[0]==="value"&&typeof t2$5[1]==="string"))){Array.prototype.slice.call(t0$16,1);f$0=function f(x$4,y$0){return["send",["symbol","+"],["data",x$4,y$0]];};return elements$0.reduce(f$0);}else{f$1=function f(x$5,y$1){return["send",["symbol","+"],["data",x$5,y$1]];};return elements$0.reduce(f$1,["value",""]);}}}else{return["send",["send",x$3,["send",["symbol","."],["data",["void"],["symbol","to-string"]]]],["data"]];}};t0$17=getProjector(overridable$0)($targ$4);if(t0$17[0]&&(t1$10=getProjector(mac$0("wrap-quote"))(t0$17[1]),t1$10[0])){wq_mac$0=t1$10[1];}else{___match_error($targ$4,"overridable! mac{\"wrap-quote\"}! wq_mac{context, info, form, `{^x}`}");}$targ$5=function $targ$5(context$3,info$3,form$3,temp$6$0){var t0$18=void 0;var t1$11=void 0;var t0$19=void 0;var bridge$$19682$0=void 0;var m$2=void 0;var $targ$7=void 0;var contents$0=void 0;var parts$0=void 0;var current$0=void 0;var push$0=void 0;var wq$0=void 0;var s$1=void 0;t0$18=temp$6$0;if(Array.isArray(t0$18)&&(t1$11=t0$18.length,t1$11===2&&t0$18[0]==="value")){s$1=t0$18[1];}else{___match_error(temp$6$0);}$targ$7=parse$0(s$1);bridge$$19682$0=$targ$7;if(Array.isArray(bridge$$19682$0)&&(t0$19=bridge$$19682$0.length,t0$19>=1&&bridge$$19682$0[0]==="join"&&(contents$0=Array.prototype.slice.call(bridge$$19682$0,1),true))||(contents$0=[],true)){}else{___match_error($targ$7,"#join{*contents} or contents is {}");}parts$0=[];current$0="";push$0=function push(){if(nequal(current$0,"")){parts$0.push(["value",current$0]);current$0="";return current$0;}};m$2=null;var _iteratorNormalCompletion2=true;var _didIteratorError2=false;var _iteratorError2=undefined;try{$4:for(var _iterator2=contents$0[Symbol.iterator](),_step2;!(_iteratorNormalCompletion2=(_step2=_iterator2.next()).done);_iteratorNormalCompletion2=true){m$2=_step2.value;var p$0=void 0;var ph$7$0=void 0;var expr$2=void 0;var s$2=void 0;var $$19691$0=void 0;var t0$20=void 0;var t1$12=void 0;t0$20=m$2;if(typeof t0$20==="string"){s$2=t0$20;current$0=current$0+unescape$0(s$2);}else{if(Array.isArray(t0$20)&&(t1$12=t0$20.length,t1$12===3&&t0$20[0]==="bracket")){ph$7$0=t0$20[1];expr$2=t0$20[2];push$0();p$0=form$3.env.mark(["parse",expr$2]);if(ph$7$0===""){parts$0.push(p$0);}else{___match_error(ph$7$0);}}else{___match_error(m$2);}}}}catch(err){_didIteratorError2=true;_iteratorError2=err;}finally{try{if(!_iteratorNormalCompletion2&&_iterator2.return){_iterator2.return();}}finally{if(_didIteratorError2){throw _iteratorError2;}}}push$0();wq$0=form$3.env.mark(["symbol","wrap-quote"]);return["send",wq$0,["data",["send",["symbol","ENode"],["data",["data"],["data",["symbol","="]],["data"].concat(parts$0)]]]];};t0$21=getProjector(mac$0("'"))($targ$5);if(t0$21[0]){interpolate_mac$0=t0$21[1];}else{___match_error($targ$5,"mac{\"'\"}! interpolate_mac{context, info, form, #value{s}}");}return exports$0;};module["exports"]=$targ$0;void 0;
//# sourceMappingURL=quote.js.map