diff options
-rw-r--r-- | cook/parse-internals.sld | 6 | ||||
-rw-r--r-- | cook/parse.scm | 14 | ||||
-rw-r--r-- | cook/parse.sld | 3 |
3 files changed, 18 insertions, 5 deletions
diff --git a/cook/parse-internals.sld b/cook/parse-internals.sld index 99160fd..94986b6 100644 --- a/cook/parse-internals.sld +++ b/cook/parse-internals.sld @@ -1,13 +1,13 @@ (define-library (cook parse-internals) - (import (srfi 1) + (import (scheme base) + (srfi 1) (srfi 9) (srfi 69) (chibi) (chibi char-set ascii) (chibi char-set) (chibi parse) - (chibi regexp) - (chibi parse common)) + (chibi regexp)) (export amount? amount-quantity amount-unit diff --git a/cook/parse.scm b/cook/parse.scm index b18afba..bfb50a7 100644 --- a/cook/parse.scm +++ b/cook/parse.scm @@ -65,6 +65,18 @@ https://github.com/cooklang/spec/blob/main/EBNF.md meta-lines) metadata)) +(define (merge-step-strings lis) + (reduce-right + (lambda (el acc) + (cond + ((char? el) + (if (and (< 0 (length acc)) (string? (car acc))) + (cons (string-append (string el) (car acc)) (cdr acc)) + (append (list (string el)) acc))) + (else + (append (list el) acc)))) + '() + lis)) (define whitespace-chars (char-set #\space)) @@ -146,7 +158,7 @@ https://github.com/cooklang/spec/blob/main/EBNF.md (append (concatenate s) (if n '(#\space) '())))) (step ((: (=> s ,step-line) (=> ns (* ,step-line))) - (make-step (concatenate (append (list s) ns))))) + (make-step (merge-step-strings (concatenate (append (list s) ns)))))) (metadata ((: bol ">>" (* ,whitespace) (=> k ,meta-key) diff --git a/cook/parse.sld b/cook/parse.sld index e9805c3..ab7730d 100644 --- a/cook/parse.sld +++ b/cook/parse.sld @@ -1,5 +1,6 @@ (define-library (cook parse) - (import (srfi 1) + (import (scheme base) + (srfi 1) (srfi 9) (srfi 69) (chibi) |