Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Yes, work is actually being done on some of these modules, starting

with Json.lsp.
;
; Changed the syntax, it's now (Json:Json->Lisp) instead of
;  (Json:json->lisp)
;
  • Loading branch information...
commit d40c8872560298cd6b3f6d8ecfd81a3d828dd083 1 parent 5954314
Kanen Flowers authored
Showing with 157 additions and 163 deletions.
  1. +118 −113 install-db.lsp
  2. +39 −50 json.lsp
View
231 install-db.lsp
@@ -1,119 +1,124 @@
(context 'packages)
-(set '_acode '(MAIN:repository (MAIN:title "Artful Code") (MAIN:identifier "acode")
- (MAIN:contact "Jeff Ober <jeffober@gmail.com>, Kanen Flowers <kanendosei@gmail.com>")
- (MAIN:version 1000)
- (MAIN:module (MAIN:title "csv") (MAIN:description "A simple parser and serialization utility for delimited text.")
- (MAIN:url "http://static.artfulcode.net/newlisp/csv.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/csv.qwerty")
- (MAIN:version 1010)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends nil))
- (MAIN:module (MAIN:title "element") (MAIN:description "A simple way of generating valid XML content.")
- (MAIN:url "http://static.artfulcode.net/newlisp/element.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/element.qwerty")
- (MAIN:version 1000)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends nil))
- (MAIN:module (MAIN:title "http") (MAIN:description "A bare bones HTTP 1.0 parser and serializer.")
- (MAIN:url "http://static.artfulcode.net/newlisp/http.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/http.qwerty")
- (MAIN:version 1010)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends nil))
- (MAIN:module (MAIN:title "json") (MAIN:description "JSON parser and encoder.")
- (MAIN:url "http://static.artfulcode.net/newlisp/json.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/json.qwerty")
- (MAIN:version 1020)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends "acode:util"))
- (MAIN:module (MAIN:title "matching") (MAIN:description "Complex conditionals using match and unify.")
- (MAIN:url "http://static.artfulcode.net/newlisp/matching.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/matching.qwerty")
- (MAIN:version 1000)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends nil))
- (MAIN:module (MAIN:title "memcached") (MAIN:description "Interface to libmemcached (http://tangent.org/552/libmemcached.html).")
- (MAIN:url "http://static.artfulcode.net/newlisp/memcached.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/memcached.qwerty")
- (MAIN:version 330)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends nil))
- (MAIN:module (MAIN:title "mp") (MAIN:description "Classes for multi-processing and synchronization.")
- (MAIN:url "http://static.artfulcode.net/newlisp/mp.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/mp.qwerty")
- (MAIN:version 1000)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends "acode:util"))
- (MAIN:module (MAIN:title "mysql") (MAIN:description "A new MySQL module to replace the distribution standard module.")
- (MAIN:url "http://static.artfulcode.net/newlisp/mysql.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/mysql.qwerty")
- (MAIN:version 1020)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends nil))
- (MAIN:module (MAIN:title "profiler") (MAIN:description "Profiles applications to help identify bottlenecks.")
- (MAIN:url "http://static.artfulcode.net/newlisp/profiler.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/profiler.qwerty")
- (MAIN:version 1000)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends nil))
- (MAIN:module (MAIN:title "qwerty") (MAIN:description "Provides a dependency-managing library loading mechanism.")
- (MAIN:url "http://static.artfulcode.net/newlisp/qwerty.lsp")
- (MAIN:version 1000)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends nil))
- (MAIN:module (MAIN:title "request") (MAIN:description "Request module to replace input functions in the standard CGI module.")
- (MAIN:url "http://static.artfulcode.net/newlisp/request.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/request.qwerty")
- (MAIN:version 1010)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends nil))
- (MAIN:module (MAIN:title "response") (MAIN:description "Response module to replace output functions in the standard CGI module.")
- (MAIN:url "http://static.artfulcode.net/newlisp/response.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/response.qwerty")
- (MAIN:version 1021)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends nil))
- (MAIN:module (MAIN:title "sockets") (MAIN:description "Classes for socket operations.")
- (MAIN:url "http://static.artfulcode.net/newlisp/sockets.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/sockets.qwerty")
- (MAIN:version 1000)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends nil))
- (MAIN:module (MAIN:title "util") (MAIN:description "Various functions that the other Artful Code libraries depend on.")
- (MAIN:url "http://static.artfulcode.net/newlisp/util.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/util.qwerty")
- (MAIN:version 2010)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends nil))
- (MAIN:module (MAIN:title "xml") (MAIN:description "Parsing and serializing of XML data.")
- (MAIN:url "http://static.artfulcode.net/newlisp/xml.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/xml.qwerty")
- (MAIN:version 2010)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
- (MAIN:depends "acode:matching"))
- (MAIN:module (MAIN:title "xmlrpc-server") (MAIN:description "A simple XML-RPC server.")
- (MAIN:url "http://static.artfulcode.net/newlisp/xmlrpc-server.lsp")
- (MAIN:qwerty "http://static.artfulcode.net/newlisp/xmlrpc-server.qwerty")
- (MAIN:version 1010)
- (MAIN:newlisp-min-version 10000)
- (MAIN:newlisp-max-version 10001)
+; updated to the correct repository
+; Nov 2012, Kanen
+; !! None of this works, yet -- need to change the format because newLisp doesn't support
+; https at all, much less with tokens.
+;
+(set '_acode '(MAIN:repository (MAIN:title "Artful Code") (MAIN:identifier "acode")
+ (MAIN:contact "Jeff Ober <jeffober@gmail.com>, Kanen Flowers <kanendosei@gmail.com>")
+ (MAIN:version 1000)
+ (MAIN:module (MAIN:title "csv") (MAIN:description "A simple parser and serialization utility for delimited text.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/csv.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/csv.qwerty")
+ (MAIN:version 1010)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends nil))
+ (MAIN:module (MAIN:title "element") (MAIN:description "A simple way of generating valid XML content.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/element.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/element.qwerty")
+ (MAIN:version 1000)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends nil))
+ (MAIN:module (MAIN:title "http") (MAIN:description "A bare bones HTTP 1.0 parser and serializer.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/http.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/http.qwerty")
+ (MAIN:version 1010)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends nil))
+ (MAIN:module (MAIN:title "json") (MAIN:description "JSON parser and encoder.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/json.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/json.qwerty")
+ (MAIN:version 1020)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends "acode:util"))
+ (MAIN:module (MAIN:title "matching") (MAIN:description "Complex conditionals using match and unify.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/matching.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/matching.qwerty")
+ (MAIN:version 1000)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends nil))
+ (MAIN:module (MAIN:title "memcached") (MAIN:description "Interface to libmemcached (https://tangent.org/552/libmemcached.html).")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/memcached.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/memcached.qwerty")
+ (MAIN:version 330)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends nil))
+ (MAIN:module (MAIN:title "mp") (MAIN:description "Classes for multi-processing and synchronization.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/mp.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/mp.qwerty")
+ (MAIN:version 1000)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends "acode:util"))
+ (MAIN:module (MAIN:title "mysql") (MAIN:description "A new MySQL module to replace the distribution standard module.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/mysql.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/mysql.qwerty")
+ (MAIN:version 1020)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends nil))
+ (MAIN:module (MAIN:title "profiler") (MAIN:description "Profiles applications to help identify bottlenecks.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/profiler.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/profiler.qwerty")
+ (MAIN:version 1000)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends nil))
+ (MAIN:module (MAIN:title "qwerty") (MAIN:description "Provides a dependency-managing library loading mechanism.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/qwerty.lsp")
+ (MAIN:version 1000)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends nil))
+ (MAIN:module (MAIN:title "request") (MAIN:description "Request module to replace input functions in the standard CGI module.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/request.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/request.qwerty")
+ (MAIN:version 1010)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends nil))
+ (MAIN:module (MAIN:title "response") (MAIN:description "Response module to replace output functions in the standard CGI module.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/response.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/response.qwerty")
+ (MAIN:version 1021)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends nil))
+ (MAIN:module (MAIN:title "sockets") (MAIN:description "Classes for socket operations.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/sockets.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/sockets.qwerty")
+ (MAIN:version 1000)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends nil))
+ (MAIN:module (MAIN:title "util") (MAIN:description "Various functions that the other Artful Code libraries depend on.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/util.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/util.qwerty")
+ (MAIN:version 2010)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends nil))
+ (MAIN:module (MAIN:title "xml") (MAIN:description "Parsing and serializing of XML data.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/xml.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/xml.qwerty")
+ (MAIN:version 2010)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
+ (MAIN:depends "acode:matching"))
+ (MAIN:module (MAIN:title "xmlrpc-server") (MAIN:description "A simple XML-RPC server.")
+ (MAIN:url "https://raw.github.com/kanendosei/artful-newlisp/master/xmlrpc-server.lsp")
+ (MAIN:qwerty "https://raw.github.com/kanendosei/artful-newlisp/master/xmlrpc-server.qwerty")
+ (MAIN:version 1010)
+ (MAIN:newlisp-min-version 10000)
+ (MAIN:newlisp-max-version 10001)
(MAIN:depends "acode:element" "acode:http" "acode:sockets" "acode:util"))))
View
89 json.lsp
@@ -1,39 +1,28 @@
-;; @module Json
-;; @author Jeff Ober <jeffober@gmail.com>, Kanen Flowers <kanendosei@gmail.com>
-;; @version 2.0
-;; @location http://static.artfulcode.net/newlisp/json.lsp
-;; @package http://static.artfulcode.net/newlisp/json.qwerty
-;; @description JSON parser and encoder; requires util.lsp (updated for newlisp 10)
-;; <p>Library for parsing JSON data and serializing lisp into JSON.</p>
-;; <h4>Version history</h4>
-;; <b>2.0</b>
-;; &bull; completely rewrite of decoder (thanks to Andrew Pennebaker for pointing out the bugs in the original)
-;;
-;; <b>1.2</b>
-;; &bull; fixed incompatibilities with newlisp 10
-;;
-;; <b>1.1</b>
-;; &bull; added simple escape routine to outputted string values
-;;
-;; <b>1.0</b>
-;; &bull; initial release
+; @module Json
+; @author Jeff Ober <jeffober@gmail.com>, Kanen Flowers <kanendosei@gmail.com>
+; @version 2.1
+; @location https://raw.github.com/kanendosei/artful-newlisp/master/json.lsp
+; @package https://raw.github.com/kanendosei/artful-newlisp/master/json.qwerty
+; @description JSON parser and encoder
+; <p>Library for parsing JSON data and serializing lisp into JSON.</p>
+;
(context 'Json)
-;; @syntax (Json:lisp->json <expr>)
-;; @param <expr> expression to be converted to JSON
-;; <p>Converts expression <expr> to JSON. Association lists and
-;; contexts are converted into objects. Other lists and arrays are
-;; converted into JSON arrays.</p>
-;; @example
-;; (Json:lisp->json '((a 1) (b 2)))
-;; => "{ 'A': 1, 'b': 2 }"
-;; (Json:lisp->json '(1 2 3 4 5))
-;; => "[1, 2, 3, 4, 5]"
-(define (lisp->json lisp)
+; @syntax (Json:Lisp->Json <expr>)
+; @param <expr> expression to be converted to JSON
+; <p>Converts expression <expr> to JSON. Association lists and
+; contexts are converted into objects. Other lists and arrays are
+; converted into JSON arrays.</p>
+; @example
+; (Json:Lisp->Json '((a 1) (b 2)))
+; => "{ 'A': 1, 'b': 2 }"
+; (Json:Lisp->Json '(1 2 3 4 5))
+; => "[1, 2, 3, 4, 5]"
+(define (Lisp->Json lisp)
(case (type-of lisp)
("boolean" (if lisp "true" "false"))
- ("quote" (lisp->json (eval lisp)))
+ ("quote" (Lisp->Json (eval lisp)))
("symbol" (format "'%s'" (name lisp)))
("string" (format "'%s'" (simple-escape lisp)))
("integer" (string lisp))
@@ -45,36 +34,36 @@
(if (symbol? (pair 0))
(name (pair 0))
(string (pair 0)))
- (lisp->json (pair 1))))
+ (Lisp->Json (pair 1))))
lisp)
", "))
- (string "[" (join (map lisp->json lisp) ", ") "]")))
- ("array" (string "[" (join (map lisp->json lisp) ", ") "]"))
+ (string "[" (join (map Lisp->Json lisp) ", ") "]")))
+ ("array" (string "[" (join (map Lisp->Json lisp) ", ") "]"))
("context" (let ((values '()))
(dotree (s lisp)
(push (format "'%s': %s"
(name s)
- (lisp->json (eval s)))
+ (Lisp->Json (eval s)))
values -1))
(format "{ %s }" (join values ", "))))
- (true (throw-error (format "invalid lisp->json type: %s" lisp)))))
+ (true (throw-error (format "invalid Lisp->Json type: %s" lisp)))))
(define (simple-escape str)
(replace {[\n\r]+} str {\n} 4)
(replace {'} str {\'} 4)
str)
-;; @syntax (Json:json->lisp <str-json>)
-;; @param <str-json> a valid JSON string
-;; <p>Parses a valid JSON string and returns a lisp structure.
-;; Arrays are converted to lists and objects are converted to
-;; assocation lists.</p>
-;; @example
-;; (Json:json->lisp "[1, 2, 3, 4]")
-;; => (1 2 3 4)
-;; (Json:json->lisp "{ 'x': 3, 'y': 4, 'z': [1, 2, 3] }")
-;; => (("x" 3) ("y" 4) ("z" (1 2 3)))
-(define (json->lisp json)
+; @syntax (Json:Json->Lisp <str-json>)
+; @param <str-json> a valid JSON string
+; <p>Parses a valid JSON string and returns a lisp structure.
+; Arrays are converted to lists and objects are converted to
+; assocation lists.</p>
+; @example
+; (Json:Json->Lisp "[1, 2, 3, 4]")
+; => (1 2 3 4)
+; (Json:Json->Lisp "{ 'x': 3, 'y': 4, 'z': [1, 2, 3] }")
+; => (("x" 3) ("y" 4) ("z" (1 2 3)))
+(define (Json->Lisp json)
(first (lex (tokenize json))))
(define number-re (regex-comp {^([-+\deE.]+)} 1))
@@ -140,9 +129,9 @@
(tokenize tail acc))))
(define (lex tokens, (tree '()) (loc '(-1)) (depth 0) (mark 0))
- ;; Note: mark is used to match colon-pairings' depth against the current
- ;; depth to prevent commas in a paired value (e.g. foo: [...] or foo: {})
- ;; from popping the stack.
+ ; Note: mark is used to match colon-pairings' depth against the current
+ ; depth to prevent commas in a paired value (e.g. foo: [...] or foo: {})
+ ; from popping the stack.
(unless (find (first tokens) '(OPEN_BRACKET OPEN_BRACE))
(throw-error "A JSON object must be an object or array."))
(dolist (tok tokens)
Please sign in to comment.
Something went wrong with that request. Please try again.