277982735a9d

Poke at Parenscript
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 09 Jul 2016 16:00:42 +0000
parents b4c25632115a
children 3c908eea3940
branches/tags (none)
files package.lisp sand.asd src/parenscript/compiler.lisp src/parenscript/hello.js src/parenscript/hello.paren src/parenscript/index.html src/random-numbers.lisp

Changes

--- a/package.lisp	Wed Jul 06 18:47:17 2016 +0000
+++ b/package.lisp	Sat Jul 09 16:00:42 2016 +0000
@@ -53,3 +53,17 @@
   (:shadowing-import-from #:cl-arrows
     #:->))
 
+(defpackage #:sand.parenscript
+  (:use
+    #:cl
+    #:defstar
+    #:sand.quickutils
+    #:cl-arrows
+    #:cl-fad
+
+    #:parenscript)
+  (:shadowing-import-from #:cl-arrows
+    #:->)
+  (:import-from #:sand.utils)
+  )
+
--- a/sand.asd	Wed Jul 06 18:47:17 2016 +0000
+++ b/sand.asd	Sat Jul 09 16:00:42 2016 +0000
@@ -9,7 +9,9 @@
 
   :depends-on (#:defstar
                #:iterate
-               #:cl-arrows)
+               #:cl-arrows
+               #:cl-fad
+               #:parenscript)
 
   :serial t
   :components
@@ -19,4 +21,6 @@
     :serial t
     :components ((:file "utils")
                  (:file "random-numbers")
-                 ))))
+                 (:module "parenscript"
+                  :serial t
+                  :components ((:file "compiler")))))))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parenscript/compiler.lisp	Sat Jul 09 16:00:42 2016 +0000
@@ -0,0 +1,11 @@
+(in-package #:sand.parenscript)
+
+(defun compile-parenscript-file (source)
+  (let* ((source-path (pathname source))
+         (target-path (make-pathname :type "js"
+                                     :defaults source-path)))
+    (with-open-file (output target-path
+                            :direction :output
+                            :if-exists :supersede)
+      (write-string (ps-compile-file source-path) output)))
+  (values))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parenscript/hello.js	Sat Jul 09 16:00:42 2016 +0000
@@ -0,0 +1,4 @@
+function sayHello(name) {
+    return alert('Hello, ' + name + '!');
+};
+sayHello('cocks');
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parenscript/hello.paren	Sat Jul 09 16:00:42 2016 +0000
@@ -0,0 +1,9 @@
+(in-package #:cl-user)
+
+(defun say-hello (name)
+  (alert (+ "Hello, " name "!")))
+
+
+(say-hello "cocks")
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parenscript/index.html	Sat Jul 09 16:00:42 2016 +0000
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+
+<html>
+    <head>
+        <title>Parenscript Test</title>
+        <script src='hello.js'></script>
+    </head>
+    <body>
+        Testing...
+    </body>
+</html>
--- a/src/random-numbers.lisp	Wed Jul 06 18:47:17 2016 +0000
+++ b/src/random-numbers.lisp	Sat Jul 09 16:00:42 2016 +0000
@@ -53,15 +53,3 @@
     form))
 
 
-(defun dammit () (make-linear-congruential-rng 50 2 3 2))
-(defparameter *r* (dammit))
-(disassemble *r*)
-
-(defparameter m 40)
-
-(defun run ()
-  (let ((r (make-linear-congruential-rng 50 2 3 2)))
-    (disassemble r)
-    (funcall r 100000000)))
-
-(time (run))