-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cmoore
committed
Sep 22, 2015
1 parent
3b4b9f8
commit d64bf9f
Showing
7 changed files
with
106 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <infile> -o <outfile>` | ||
|
||
### 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; | ||
}); | ||
|
||
``` | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
|
||
:components ((:file "package") | ||
(:file "pikey")) | ||
|
||
:build-pathname "pikey" | ||
:entry-point "pikey:main") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
|
||
(in-package #:pikey) | ||
|
||
(eval-when (:compile-toplevel :load-toplevel) | ||
(defpsmacro gebi (element-id) | ||
`((@ document get-Element-By-Id) ,element-id))) | ||
|
||
(defun main () | ||
(let* ((args (apply-argv:parse-argv (cdr sb-ext:*posix-argv*))) | ||
(in-file (getf args :i)) | ||
(out-file (getf args :o)) | ||
(load-file (getf args :l))) | ||
(when (probe-file load-file) | ||
(standard (truename | ||
(asdf:system-relative-pathname :pikey "std.lisp")))) | ||
|
||
(unless (and in-file out-file) | ||
(format t "Need two files.~%") | ||
(sb-ext:quit)) | ||
|
||
(when (probe-file "macros.lisp") | ||
(setf *load-verbose* t) | ||
(setf *load-print* t) | ||
(load "macros.lisp")) | ||
|
||
(when (probe-file standard) | ||
(setf *load-verbose* t) | ||
(setf *load-print* t) | ||
(load load-file)) | ||
(with-open-file (f out-file :if-exists :supersede :direction :output) | ||
(write-string (ps:ps-compile-file in-file) f)))) | ||
(load standard)) | ||
(ignore-errors | ||
(with-open-file (f out-file :if-exists :supersede :direction :output) | ||
(write-string (ps:ps-compile-file in-file) f))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(in-package :pikey) | ||
|
||
(defmacro+ps -> (&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))))))) |