summaryrefslogtreecommitdiff
path: root/cook/debug.sld
blob: 6b7ef3312d22a0d38fcaccac3bf86786a5a2fccf (plain)
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
(define-library (cook debug)
  (export cook->list)
  (import (srfi 1)
          (srfi 9)
          (srfi 69)
          (chibi)
          (cook parse-internals))
  (begin
    (define (cook->list y)
      (cond
        ((amount? y)
         (list 'amount (amount-quantity y) (amount-unit y)))
        ((comment? y)
         (list 'comment (comment-text y)))
        ((component? y)
         (list 'component (component-name y) (cook->list (component-amount y))))
        ((cookware? y)
         (list 'cookware (cookware-name y) (cook->list (cookware-amount y))))
        ((ingredient? y)
         (list 'ingredient (ingredient-name y) (cook->list (ingredient-amount y))))
        ((timer? y)
         (list 'timer (timer-name y) (cook->list (timer-amount y))))
        ((metadata-line? y)
         (list 'metadata-line (metadata-line-key y) (metadata-line-value y)))
        ((step? y)
         (list 'step (map cook->list (step-elements y))))
        ((hash-table? y)
         (list 'metadata (cook->list (hash-table->alist y))))
        ((list? y)
         (map cook->list y))
        (else y)))))