diff options
-rw-r--r-- | cook/debug.sld | 44 | ||||
-rw-r--r-- | cook/parse-internals.sld | 12 |
2 files changed, 33 insertions, 23 deletions
diff --git a/cook/debug.sld b/cook/debug.sld index 638c13a..c35f8f9 100644 --- a/cook/debug.sld +++ b/cook/debug.sld @@ -4,31 +4,31 @@ (srfi 9) (srfi 69) (chibi) + (chibi match) (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) + (match y + (($ <amount> quantity unit) + (list 'amount quantity unit)) + (($ <comment> text) + (list 'comment text)) + (($ <component> name amount) + (list 'component name (cook->list amount))) + (($ <cookware> name amount) + (list 'cookware name (cook->list amount))) + (($ <ingredient> name amount) + (list 'ingredient name (cook->list amount))) + (($ <timer> name amount) + (list 'timer name (cook->list amount))) + (($ <metadata-line> key value) + (list 'metadata-line key value)) + (($ <step> elements) + (list 'step (map cook->list elements ))) + ((? hash-table? y) (list 'metadata (cook->list (hash-table->alist y)))) - ((recipe? y) - (list 'recipe (cook->list (recipe-metadata y)) - (cook->list (recipe-body y)))) - ((list? y) + (($ <recipe> metadata body) + (list 'recipe (cook->list metadata) (cook->list body))) + ((? list? y) (map cook->list y)) (else y))))) diff --git a/cook/parse-internals.sld b/cook/parse-internals.sld index d73a3c3..d2099e1 100644 --- a/cook/parse-internals.sld +++ b/cook/parse-internals.sld @@ -10,31 +10,41 @@ (chibi regexp) (chibi string) (cook unicode)) - (export amount? + (export <amount> + amount? amount-quantity amount-unit + <ingredient> ingredient? ingredient-name ingredient-amount + <timer> timer? timer-name timer-amount + <component> component? component-name component-amount + <cookware> cookware? cookware-name cookware-amount + <metadata-line> metadata-line? metadata-line-key metadata-line-value + <recipe> recipe? recipe-metadata recipe-body + <step> step? step-elements + <comment> comment? comment-text + ;; Functions parse-cook nl whitespace |