fogus (owner)

Revisions

gist: 162729 Download_button fork
public
Public Clone URL: git://gist.github.com/162729.git
Embed All Files: show embed
format.qi #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(define format-row
  C G [#\~ #\A |L] [X|J] -> [(format-AS human X)|(format-row C G L J)]
  C G [#\~ #\S |L] [X|J] -> [(format-AS compu X)|(format-row C G L J)]
  C G [#\~ #\C |L] [X|J] -> [(format-C human X)|(format-row C G L J)]
  C G [#\~ #\@ #\C |L] [X|J] -> [(format-C compu X)|(format-row C G L
J)]
  C G [#\~ #\P |L] [X|J] -> [(if (= X 1) [] [#\s])|(format-row C G L
J)]
  C G [#\~ #\P |L] [X|J] -> [(if (= X 1) [] [#\s])|(format-row C G L
J)]
  C G [#\~ #\: #\P |L] [X|J] -> [(if (= X 1) [] (explode ies)) |
(format-row C G L J)]
  C G [#\~ #\~ |L] [X|J] -> [#\~|(format-row C G L J)]
  C G [#\~ #\% |L] [X|J] -> [#\Newline|(format-row C G L J)]
  C G [#\~ #\} |L] [X|J] -> (FUNCALL C J)
  C G [#\~ #\} |L] [] -> (FUNCALL G L)
  C G [#\~ #\^ |L] M -> (FUNCALL G (format-skip L))
  C G [#\~ #\{ |L] [X|J] -> (let CC NIL
                                 CG (/. LL (format-row C G LL J))
                               (do (SETF CC (/. U (format-row CC CG L U)))
                                   (CC (head X)))))
(define format-skip
  [#\~ #\~|L] -> (format-skip L)
  [#\~ #\}|L] -> L
  [X |L] -> (format-skip L))
(define format-AS
  Kind [X|L] -> (let M (map (format-AS Kind) [X|L])
                     R (reduce (/. X L -> (if (= L [])
                                              X
                                              (append X [#\Space] L)))
                               []
                               M)
                  (append [#\(] R [#\)]))
  Kind NIL -> [#\N #\I #\L]
  Kind X -> (format-string Kind X) where (string? X)
  Kind X -> (format-charac Kind X) where (character? X)
  Kind X -> (format-symbol Kind X) where (symbol? X)
  Kind X -> (format-variab Kind X) where (variable? X)
  Kind X -> (format-number Kind X) where (number? X))
(define format-C
  Kind X -> (format-charac Kind X))