summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2024-08-11 00:41:02 +0200
committerEkaitz Zarraga <ekaitz@elenq.tech>2024-08-11 00:41:02 +0200
commit7ec53b944c73708344f736b974801713693483ec (patch)
treed9d0f2223dac70478eb4e36daee7797f8caba381
parent472a3f33ef5785dfb600a9adf0f9862081786d64 (diff)
Start newline control
-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)