diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2024-08-11 22:03:00 +0200 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2024-08-11 22:03:00 +0200 |
commit | e31c5559b8e58965a6d50fc767a8401d0bafc7d1 (patch) | |
tree | 6ad47b4495513cc52aea3a7f87ff58adbc217fb9 | |
parent | 4ebc2d7b6ea132071ff892eaa46028f5a1bd8840 (diff) |
Make parse work with many empty lines
-rw-r--r-- | cook/parse.scm | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/cook/parse.scm b/cook/parse.scm index 05b3a2a..098b866 100644 --- a/cook/parse.scm +++ b/cook/parse.scm @@ -89,7 +89,6 @@ https://github.com/cooklang/spec/blob/main/EBNF.md (define-grammar cook (nl ((: ,newline-chars))) - (empty-line ((: bol (* ,whitespace-chars) ,nl))) (whitespace ((=> x (+ ,whitespace-chars)) (list->string x))) @@ -147,6 +146,8 @@ https://github.com/cooklang/spec/blob/main/EBNF.md (concatenate s))) (step ((: (=> s ,step-line) (=> ns (* ,step-line))) + ;; TODO It's not converting the end of the step-line to a + ;; space (make-step (concatenate (append (list s) ns))))) (metadata ((: bol ">>" (* ,whitespace) @@ -155,12 +156,14 @@ https://github.com/cooklang/spec/blob/main/EBNF.md (=> v ,any-text-item) (* ,whitespace) eol) (make-metadata-line k v))) - (recipe ((* (or (: (=> m (+ ,metadata)) ,nl) - (=> c (+ ,comment)) - (: (=> s (+ ,step)) (or eos (* ,empty-line))))) - (list 'recipe - (metadata-line-list->hash-table (or m '())) - s)))) + (element ((or ,metadata ,comment ,step))) + + (recipe ((=> els + (* (: ,element ,(parse-ignore + (parse-seq + (parse-repeat nl) + (parse-optional parse-end)))))) + (concatenate els)))) (define (parse-cook str) (parse-fully recipe str)) |