Browse code
Update README, add a simple smoke test
Ed Langley authored on 25/07/2018 19:04:57
Showing 6 changed files
Showing 6 changed files
... | ... |
@@ -15,11 +15,48 @@ |
15 | 15 |
|
16 | 16 |
<ul> |
17 | 17 |
<li>Clone this repository somewhere ASDF can find the system: e.g. <code>git clone https://github.com/fiddlerwoaroof/cl-edn.git ~/quicklisp/local-projects/cl-edn/</code></li> |
18 |
-<li>At a REPL, <code>(ql:quickload :cl-edn)</code></li> |
|
18 |
+<li>At a REPL, <code>(ql:quickload :cl-edn/fset)</code></li> |
|
19 | 19 |
</ul> |
20 | 20 |
|
21 | 21 |
<h1>Usage</h1> |
22 | 22 |
|
23 |
+<h2>Conceptual Model:</h2> |
|
24 |
+ |
|
25 |
+<p><code> |
|
26 |
+ +-------------+ |
|
27 |
+ | SYNTHESIZER | |
|
28 |
+ +------+------+ |
|
29 |
+ | |
|
30 |
+ V |
|
31 |
++----------+ +----------------------------+ |
|
32 |
+| READ-EDN +----->| (PARSE string synthesizer) | |
|
33 |
++----------+ +----------------------------+ |
|
34 |
+</code></p> |
|
35 |
+ |
|
36 |
+<h2>Systems for Components:</h2> |
|
37 |
+ |
|
38 |
+<ul> |
|
39 |
+<li>CL-EDN: |
|
40 |
+<ul> |
|
41 |
+<li>READ-EDN</li> |
|
42 |
+<li>PARSE</li> |
|
43 |
+</ul></li> |
|
44 |
+<li>CL-EDN/FSET: |
|
45 |
+<ul> |
|
46 |
+<li>'EDN:FSET: a synthesizer that uses FSET datastructures but |
|
47 |
+preserves the case of keywords and symbols.</li> |
|
48 |
+</ul></li> |
|
49 |
+<li>CL-EDN/FSET-LOSSY: |
|
50 |
+<ul> |
|
51 |
+<li>'EDN:FSET-LOSSY: a synthesizer that uses FSET datastructures but |
|
52 |
+uppercases keywords and symbols. This is probably preferable for |
|
53 |
+most cases where the data is only going to be used by Common Lisp, |
|
54 |
+because CL symbols are uppercase by default</li> |
|
55 |
+</ul></li> |
|
56 |
+</ul> |
|
57 |
+ |
|
58 |
+<h2>Notes:</h2> |
|
59 |
+ |
|
23 | 60 |
<p>This library divides the task of parsing EDN into two stages. In the |
24 | 61 |
first stage, implemented by <code>(EDN:READ-EDN string)</code> an EDN file is is |
25 | 62 |
parsed into an AST where primitives are converted into lisp values and |
... | ... |
@@ -2,11 +2,43 @@ Installation |
2 | 2 |
============ |
3 | 3 |
|
4 | 4 |
- Clone this repository somewhere ASDF can find the system: e.g. ```git clone https://github.com/fiddlerwoaroof/cl-edn.git ~/quicklisp/local-projects/cl-edn/``` |
5 |
-- At a REPL, ```(ql:quickload :cl-edn)``` |
|
5 |
+- At a REPL, ```(ql:quickload :cl-edn/fset)``` |
|
6 | 6 |
|
7 | 7 |
Usage |
8 | 8 |
===== |
9 | 9 |
|
10 |
+Conceptual Model: |
|
11 |
+----------------- |
|
12 |
+ |
|
13 |
+``` |
|
14 |
+ +-------------+ |
|
15 |
+ | SYNTHESIZER | |
|
16 |
+ +------+------+ |
|
17 |
+ | |
|
18 |
+ V |
|
19 |
++----------+ +----------------------------+ |
|
20 |
+| READ-EDN +----->| (PARSE string synthesizer) | |
|
21 |
++----------+ +----------------------------+ |
|
22 |
+``` |
|
23 |
+ |
|
24 |
+Systems for Components: |
|
25 |
+----------------------- |
|
26 |
+ |
|
27 |
+- CL-EDN: |
|
28 |
+ - READ-EDN |
|
29 |
+ - PARSE |
|
30 |
+- CL-EDN/FSET: |
|
31 |
+ - 'EDN:FSET: a synthesizer that uses FSET datastructures but |
|
32 |
+ preserves the case of keywords and symbols. |
|
33 |
+- CL-EDN/FSET-LOSSY: |
|
34 |
+ - 'EDN:FSET-LOSSY: a synthesizer that uses FSET datastructures but |
|
35 |
+ uppercases keywords and symbols. This is probably preferable for |
|
36 |
+ most cases where the data is only going to be used by Common Lisp, |
|
37 |
+ because CL symbols are uppercase by default |
|
38 |
+ |
|
39 |
+Notes: |
|
40 |
+------ |
|
41 |
+ |
|
10 | 42 |
This library divides the task of parsing EDN into two stages. In the |
11 | 43 |
first stage, implemented by `(EDN:READ-EDN string)` an EDN file is is |
12 | 44 |
parsed into an AST where primitives are converted into lisp values and |
... | ... |
@@ -5,7 +5,17 @@ |
5 | 5 |
until (<= min-nodes nodes max-nodes) |
6 | 6 |
finally (return (values edn nodes)))) |
7 | 7 |
|
8 |
+(defvar *last-edn*) |
|
8 | 9 |
(defun generate-edn () |
10 |
+ (multiple-value-bind (edn nodes) (%generate-edn) |
|
11 |
+ (values (setf *last-edn* edn) |
|
12 |
+ nodes))) |
|
13 |
+ |
|
14 |
+(defun last-generated () |
|
15 |
+ (when (boundp '*last-edn*) |
|
16 |
+ *last-edn*)) |
|
17 |
+ |
|
18 |
+(defun %generate-edn () |
|
9 | 19 |
(case (random 3) |
10 | 20 |
(0 (generate-map)) |
11 | 21 |
(1 (generate-set)) |
... | ... |
@@ -124,7 +134,7 @@ |
124 | 134 |
|
125 | 135 |
(defun compound-or-primitive (&optional (primitive-func 'generate-primitive)) |
126 | 136 |
(case (random 10) |
127 |
- (0 (generate-edn)) |
|
137 |
+ (0 (%generate-edn)) |
|
128 | 138 |
(1 (funcall primitive-func)) |
129 | 139 |
(2 (funcall primitive-func)) |
130 | 140 |
(3 (funcall primitive-func)) |
... | ... |
@@ -113,3 +113,10 @@ |
113 | 113 |
(format nil "foobar~%qwer") |
114 | 114 |
"asdf" |
115 | 115 |
(smug:parse (edn::.string-ending) "foobar\\nqwer\"asdf"))) |
116 |
+ |
|
117 |
+(deftest smoke () |
|
118 |
+ (should be = |
|
119 |
+ 0 |
|
120 |
+ (loop repeat 0 |
|
121 |
+ for res = (edn:read-edn (edn.generate:generate-edn)) |
|
122 |
+ unless res sum 1))) |