From 9edce9caa52adb556b7fc2482f005744212e2fc6 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Mon, 12 Aug 2024 10:53:53 +0200 Subject: Full recipe parsing to a structure --- cook/parse.scm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'cook/parse.scm') diff --git a/cook/parse.scm b/cook/parse.scm index bfb50a7..2ccc4a6 100644 --- a/cook/parse.scm +++ b/cook/parse.scm @@ -56,6 +56,12 @@ https://github.com/cooklang/spec/blob/main/EBNF.md comment? (text comment-text)) +(define-record-type + (make-recipe metadata body) + recipe? + (metadata recipe-metadata) + (body recipe-body)) + (define (metadata-line-list->hash-table meta-lines) (let ((metadata (make-hash-table))) (for-each (lambda (line) @@ -176,4 +182,6 @@ https://github.com/cooklang/spec/blob/main/EBNF.md (concatenate els)))) (define (parse-cook str) - (parse-fully recipe str)) + (let ((lis (parse-fully recipe str))) + (let-values (((meta-lines body) (partition metadata-line? lis))) + (make-recipe (metadata-line-list->hash-table meta-lines) body)))) -- cgit v1.2.3