summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cook/parse.scm14
1 files changed, 8 insertions, 6 deletions
diff --git a/cook/parse.scm b/cook/parse.scm
index ae645f6..2953b70 100644
--- a/cook/parse.scm
+++ b/cook/parse.scm
@@ -82,7 +82,8 @@ https://github.com/cooklang/spec/blob/main/EBNF.md
(define metadata-chars (char-set-difference text-chars (char-set #\:)))
(define-grammar cook
- (nl ((+ ,newline-chars)))
+ (nl ((: ,newline-chars)))
+ (empty-line ((: bol ,nl)))
(whitespace ((+ ,char-set:whitespace)))
(any-text-item ((: (=> c (+ ,any-text-chars)))
@@ -128,18 +129,19 @@ https://github.com/cooklang/spec/blob/main/EBNF.md
,cookware
,timer
,text-item)))
- ,nl)
+ (or ,empty-line
+ (: (* ,empty-line) eos)))
(make-step s)))
(metadata ((: bol ">>" (* ,whitespace)
(=> k ,meta-key)
(* ,whitespace) ":" (* ,whitespace)
- (=> v ,any-text-item) (* ,whitespace) ,nl)
+ (=> v ,any-text-item) (* ,whitespace) eol)
(make-metadata-line k v)))
- (recipe ((* (or (=> m (+ ,metadata))
- (=> c (+ ,comment)))
- (=> s (+ ,step)))
+ (recipe ((* (or (: (=> m (+ ,metadata)) ,nl)
+ (=> c (+ ,comment))
+ (: (=> s (+ ,step)) (or eos (* ,empty-line)))))
(list 'recipe (metadata-line-list->hash-table m) s))))
(define (parse-cook str)