UNPKG

earlgrey

Version:

Programming language compiling to JavaScript, featuring macros, dynamic typing annotations and pattern matching.

5 lines (2 loc) 5.9 kB
'use strict';require('earlgrey-runtime/6');let $targ$0;let $targ$1;let $targ$2;let $targ$3;let pr_terminus$0;let pr$0;let __lt____gt__$0;let repr$0;let escape_html$0;let quotify$0;let HTML$0;pr_terminus$0=(function pr_terminus(node$0){let r$0;let pre$0;let post$0;r$0=HTML$0(node$0,"span");pre$0=(String.fromCharCode(27)+"[?0;7y+h <div class=\"ug\">");post$0=("</div>"+String.fromCharCode(7));return console.log(((pre$0+r$0)+post$0));});pr$0=(function pr(ph$0$0,r$1){let x$0;let n$0;let t0$0;t0$0=ph$0$0;if(getChecker(ENode)(t0$0)){n$0=t0$0;return pr_terminus$0(n$0);}else{x$0=ph$0$0;return pr_terminus$0((r$1||repr$0)(x$0));}});__lt____gt__$0=(function(temp$0$0,x$1){return pr$0(x$1);});repr$0=(function repr(){let m$1;let acc$0;let temp$1;let m$2;let acc$1;let temp$2;let other$0;let entries$0;let $$25932$0;let t0$2;let x$2;let ph$2$0;let recur$0;let t0$1;let t1$0;let t2$0;let m$0$0;m$0$0=arguments;t0$1=m$0$0.length;if((((t0$1>=1)&&(t0$1<=2))&&((t1$0=m$0$0[0]),(x$2=t1$0),(ph$2$0=t1$0),(t2$0=((1>=t0$1)?repr$0:m$0$0[1])),(typeof(t2$0)==="function")))){recur$0=t2$0;if((ph$2$0===true)){return ENode([".special",".true"],({}),"true");}else{if((ph$2$0===false)){return ENode([".special",".false"],({}),"false");}else{if((ph$2$0===null)){return ENode([".special",".nil"],({}),"null");}else{if((ph$2$0===(void 0))){return ENode([".special",".nil"],({}),"undefined");}else{if((typeof(ph$2$0)==="number")){return ENode([".num"],({}),String(x$2));}else{if((typeof(ph$2$0)==="string")){return ENode([".str"],({}),x$2);}else{t0$2=ph$2$0;if(Array.isArray(t0$2)){entries$0=t0$2;return ENode([".sequence"],({}),((acc$0=[]),(temp$1=null),(m$1=null),(function(){$0:for(m$1 of entries$0){let x$3;x$3=m$1;temp$1=recur$0(x$3,repr$0);acc$0.push(temp$1);}})(),acc$0));}else{if(x$2["::repr"]){return x$2["::repr"](recur$0);}else{if((Object.getPrototypeOf(x$2)===Object.prototype)){return ENode(["table",".object"],({}),((acc$1=[]),(temp$2=null),(m$2=null),(function(){$1:for(m$2 of items(x$2)){let k$0;let v$0;let t0$3;let t1$1;t0$3=m$2;if((Array.isArray(t0$3)&&((t1$1=t0$3.length),(t1$1===2)))){k$0=t0$3[0];v$0=t0$3[1];temp$2=ENode(["tr"],({}),[ENode(["th"],({}),recur$0(k$0,repr$0)),ENode(["td"],({}),recur$0(v$0,repr$0))]);acc$1.push(temp$2);}else{___match_error(m$2);}}})(),acc$1));}else{other$0=ph$2$0;return ENode([".unknown"],({}),other$0.toString());}}}}}}}}}}else{return ___match_error(m$0$0,"{x and match, Function? recur = repr}");}});escape_html$0=(function escape_html(temp$3$0){let t0$4;let repl$0;let s$0;t0$4=[true,String(temp$3$0)];if(t0$4[0]){s$0=t0$4[1];}else{___match_error(temp$3$0);}repl$0=({"&":"&amp;","<":"&lt;",">":"&gt;"});return s$0.replace(RegExp("[&<>]","g"),(function(x$4){return send(repl$0,x$4);}));});quotify$0=(function quotify(temp$4$0){let t0$5;let s$1;t0$5=[true,String(temp$4$0)];if(t0$5[0]){s$1=t0$5[1];}else{___match_error(temp$4$0);}return s$1.replace(RegExp("[\\\"\\\\]","g"),(function(x$5){return ("\\"+x$5);}));});HTML$0=(function HTML(ph$3$0,default_tag$0){let m$3;let acc$2;let temp$5;let chs$0;let m$5;let m$6;let m$7;let acc$3;let temp$6;let m$9;let acc$4;let temp$7;let m$10;let acc$5;let temp$8;let other$2;let m$8$0;let x$6;let other$3;let m$4$0;let tag$0;let classes$0;let id$0;let kv$0;let sub$0;let accum$0;let children2$0;let other$4;let tags$0;let props$0;let children$1;let children$0;let s$2;let $$26115$0;let t0$6;t0$6=ph$3$0;if((typeof(t0$6)==="string")){s$2=t0$6;return escape_html$0(s$2);}else{if(Array.isArray(t0$6)){children$0=t0$6;acc$2=[];temp$5=null;m$3=null;$2:for(m$3 of children$0){let child$0;child$0=m$3;temp$5=HTML$0(child$0,default_tag$0);acc$2.push(temp$5);}chs$0=acc$2;return chs$0.join("");}else{if((getChecker(ENode)(t0$6)&&(___hasprop(t0$6,"tags")&&((tags$0=t0$6.tags),(___hasprop(t0$6,"props")&&((props$0=t0$6.props),___hasprop(t0$6,"children"))))))){children$1=t0$6.children;tag$0=(default_tag$0||"span");classes$0=[];id$0=null;kv$0=[];sub$0=[];m$5=null;$3:for(m$5 of tags$0){let other$1;let cls$0;let t0$7;let t1$2;let t2$1;t0$7=getProjector(RegExp("^\\.(.*)",""))(m$5);if((t0$7[0]&&((t1$2=t0$7[1]),(t2$1=t1$2.length),(t2$1===2)))){t1$2[0];cls$0=t1$2[1];classes$0.push(cls$0);}else{other$1=m$5;tag$0=other$1;tag$0;}}m$6=null;$4:for(m$6 of items(props$0)){let k$1;let v$1;let t0$8;let t1$3;t0$8=m$6;if((Array.isArray(t0$8)&&((t1$3=t0$8.length),(t1$3===2)))){k$1=t0$8[0];v$1=t0$8[1];kv$0.push([k$1,v$1]);}else{___match_error(m$6);}}if((tag$0==="raw")){accum$0=[];}else{accum$0=["<",tag$0];}if(id$0){accum$0=accum$0.concat(" id=\"",id$0,"\"");accum$0;}if(classes$0.length){accum$0=accum$0.concat(" class=\"",quotify$0(classes$0.join(" ")),"\"");accum$0;}if(kv$0){acc$3=[];temp$6=null;m$7=null;$5:for(m$7 of kv$0){let k$2;let v$2;let t0$9;let t1$4;t0$9=m$7;if((Array.isArray(t0$9)&&((t1$4=t0$9.length),(t1$4===2)))){k$2=t0$9[0];v$2=t0$9[1];accum$0=accum$0.concat(((v$2!==null)?[" ",k$2,"=\"",quotify$0(v$2),"\""]:[" ",k$2]));temp$6=accum$0;acc$3.push(temp$6);}else{___match_error(m$7);}}acc$3;}m$8$0=tag$0;if((m$8$0==="raw")){acc$4=[];temp$7=null;m$9=null;$6:for(m$9 of children$1){let c$0;let s$3;let t0$10;t0$10=m$9;if((typeof(t0$10)==="string")){s$3=t0$10;temp$7=s$3;acc$4.push(temp$7);}else{c$0=m$9;temp$7=HTML$0(c$0,default_tag$0);acc$4.push(temp$7);}}children2$0=acc$4;}else{other$2=m$8$0;acc$5=[];temp$8=null;m$10=null;$7:for(m$10 of children$1){let c$1;c$1=m$10;temp$8=HTML$0(c$1,default_tag$0);acc$5.push(temp$8);}children2$0=acc$5;}m$4$0=tag$0;if((m$4$0==="raw")){return accum$0.concat(children2$0).join("");}else{other$3=m$4$0;x$6=[">"].concat(children2$0).concat(["</",tag$0,">"]);return accum$0.concat(x$6).join("");}}else{other$4=ph$3$0;return HTML$0([true,String(other$4)][1],default_tag$0);}}}});$targ$0=pr_terminus$0;(exports["pr_terminus"]=$targ$0);$targ$1=pr$0;(exports["pr"]=$targ$1);$targ$2=__lt____gt__$0;(exports["<>"]=$targ$2);$targ$3=repr$0;(exports["repr"]=$targ$3);(void 0); //# sourceMappingURL=pp.js.map