From d64bf9f35816d9364e932946a7a175e29f9853f7 Mon Sep 17 00:00:00 2001 From: cmoore Date: Tue, 22 Sep 2015 10:34:51 -0700 Subject: [PATCH] Dags. --- README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ README.txt | 12 ------------ build.lisp | 12 ++++++++++++ dags.jpg | Bin 0 -> 4375 bytes pikey.asd | 2 +- pikey.lisp | 26 +++++++++++++++++--------- std.lisp | 27 +++++++++++++++++++++++++++ 7 files changed, 106 insertions(+), 22 deletions(-) create mode 100644 README.md delete mode 100644 README.txt create mode 100644 build.lisp create mode 100644 dags.jpg create mode 100644 std.lisp diff --git a/README.md b/README.md new file mode 100644 index 0000000..3c75a95 --- /dev/null +++ b/README.md @@ -0,0 +1,49 @@ + +![](dags.jpg) + +Pikey is a Javascript compiler using Parenscript. + +It's work in progress. To build it, you need SBCL and quicklisp. +Then, just `sbcl --load build.lisp` + + +## Usage + +`pikey -i -o ` + +### Macros + +This is really the whole reason for using Pikey. + +Pikey will load macros from `macros.lisp` in the current working directory. + +So, for instance, if `macros.lisp` contains + +``` lisp + +(in-package :pikey) + +(defmacro+ps dr (&rest body) + `((@ ($ document) ready) (lambda () + ,@body))) + +``` + +and your source file contains + +``` lisp + +(dr (defvar x 1)) + +``` + +`pikey -i source.lisp -o test.js` will produce + +``` javascript + +$(document).ready(function () { + var x = 1; +}); + +``` + diff --git a/README.txt b/README.txt deleted file mode 100644 index 162e723..0000000 --- a/README.txt +++ /dev/null @@ -1,12 +0,0 @@ - -Pikey is a Javascript compiler using Parenscript. - -It's work in progress. To build it, you need SBCL and quicklisp. Then evaluate - -(asdf:operate :program-op :pikey) - -and look in your fasl cache for the executable. I haven't looked up how to put -it in the current working directory yet. - -Your fasl cache is usually ~/.cache/common-lisp//path/to/source/etc. - diff --git a/build.lisp b/build.lisp new file mode 100644 index 0000000..3277d53 --- /dev/null +++ b/build.lisp @@ -0,0 +1,12 @@ + +(ql:quickload 'pikey) + +(require :asdf) + +(defmethod asdf:output-files ((o asdf:program-op) (s (eql (asdf:find-system :pikey)))) + (let ((exe-path (uiop/os:getcwd))) + (if exe-path + (values (list (concatenate 'string (directory-namestring exe-path) "pikey")) t) + (call-next-method)))) + +(asdf:operate :program-op :pikey) diff --git a/dags.jpg b/dags.jpg new file mode 100644 index 0000000000000000000000000000000000000000..77355e60f78ea271ce022ff76213ac29e297dad5 GIT binary patch literal 4375 zcmZWr2|Sc*7ax>vq*8+-+_IZNWnU|WW-ya=nz3|Skj7*m>+rRxYfD)RLuFrv%wRB# zvK2xMqcJgt(Ab3`+kCp;z2EP<_dCz~KIfe0ocDkJzu$SD=lAkH^F{%Oq2>^C03RO! zz_&X9JSN~FV85Us@W^2x@F-AR3@Cm~OhW7!P)rOc20SKpOadqY1Og?b6lEli%SlQA zWi@`4Q&Itg!D2FJv`?#QD}ul(eEWrj4jwotdFYU&hWv?>VAb6)7_9X(3k=rS^>!_l zpYI>f?wZO^^AG)VRtNLm0z`iSumNlVzEc2xQ9c1tK3)qzYL_6tz)!0Gl|6g;1qAu_ z?FP*c1Niy)`2~N<{=I)B@bL?X?m4;l$e9Z^*9DLIK6_Ph>g+w@yIwghQ(M19puFad zM7DzV#rv;G&3#K^b~l^Gc5#mJ{UQIYuxsq%?AeVdiSCx>=M&h&&-WkvpApfM0!Pjq zJ$1qN>~)(xruQlqc|(8$0=s#l0-}I(0QTE`;&1=L646WFD9QLN$bhJo_Al9tk0PKs z-Y;TsZ4?{N6IQM}%i3DQ-qvAV! z>bfON^+$DWY3H3I7z{jpH43 zIW9G8&2@KERl~q*+K0XFesLK5JufENl}=yT*&~^$FDx#$lxi9KWg*Q|(4QU@A=D(| z)s06;q*}xXq6%L(i^SM|T@SaZFV3Hn@3a#K0Al`G{cy!|j~R<0s{E(DTFASvQmVO6 zXN>yoG1!c$7kUHc#fuoE!rh?7iUQ#W)qbR~+9P7O$+u|X`1j7`=#posGc`dV?V1Fk zEpnoci@a57N&Jb`}*nl%8{P4 zEdn}o=l{uP*B7JN+QF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Q2bD8lfKUFaUqfi895*e7uJz<8e z<&<0CFTLvcY|aV~Fn>{vn(VhEeA$*fchb9s>LKka{(xDrgM1KYZJ%M$vup zh||3O%qG|OjyBs?4cdz!!NZAIM$)3{@85e|l<Ke>kPk6x4TPs<^7^fNtdyS7gxguv0 zhwd-J{n|HtEAV=S@eJMD-5Ja%&(Tf>8HXrS%NP_~;Y3ios46bIg{qit4fUUJ`^aG! zh9T!E%!-!rBILHbhDU0>!}suRO=(kGUn13UcGA0i_ir%iOIL2QOf#60Wp*p!yv~O| z`vzeQ?@~ZvyQ`ajK@%Jz?{X?tY9f8qXyciS;<*vQCznkFkKG;zk+MA)Tw~ zDwI!5Vuf!Kb*DXWn+HNEh9&+}TOGz3AwG4DQ`K$19sY~Y-*s@4#ml|_0_@i_P=#9O z&gN93V)d2lH>Ko+?-|&07#oO6oG`^@1Pj+Nb8=vTXQ_0j9MjagIG28c)UZ1qiX9nB zsajL-%DZai1&MoegwJsO7 (&rest body) + `(chain ,@body)) + +(defmacro+ps _ (function &rest body) + `(-> _ (,function ,@body))) + +(defmacro+ps add-entity () + (with-ps-gensyms (ball) + `(progn + (defvar ,ball (chain game add (sprite 0 0 "balloon"))) + + (chain game physics (enable ,ball (chain -phaser -physics -a-r-c-a-d-e))) + (setf (@ ,ball check-world-bounds) t) + (chain ,ball body bounce (set 1)) + + (setf (chain ,ball input-enabled) t) + (chain ,ball events on-input-down (add click-handler ,ball)) + + (setf (chain ,ball body velocity y) (random-range -20 -50)) + + (chain all-balloons (push ,ball)) + (drop-balloon ,ball)))) + +(defmacro+ps random-range (min max) + `(+ ,min (-> -math (floor (* (-> -math (random)) (+ 1 (- ,max ,min)))))))