summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cook/parse.scm11
1 files changed, 9 insertions, 2 deletions
diff --git a/cook/parse.scm b/cook/parse.scm
index 4f9eea8..54ea23c 100644
--- a/cook/parse.scm
+++ b/cook/parse.scm
@@ -104,7 +104,8 @@ https://github.com/cooklang/spec/blob/main/EBNF.md
(define text-chars (char-set-difference any-text-chars
(char-set #\@ #\# #\~)))
(define unit-chars (char-set-difference text-chars (char-set #\})))
-(define component-chars text-chars)
+(define component-chars (char-set-difference char-set:full
+ (char-set #\@ #\# #\~)))
(define component-word-chars (char-set-difference component-chars
punctuation-chars
newline-chars
@@ -120,6 +121,9 @@ https://github.com/cooklang/spec/blob/main/EBNF.md
(define string-trim-whitespace (string-trimmer-from-sets whitespace-chars))
+(define (string-split-newline str)
+ (string-split str (lambda (x) (char-set-contains? newline-chars x))))
+
(define-grammar cook
(one-nl (,(parse-map
(parse-sre `(: eol (+ ,newline-chars) bol))
@@ -172,7 +176,10 @@ https://github.com/cooklang/spec/blob/main/EBNF.md
(? (: (=> cc (* ,component-chars))
(=> a ,amount-block))))
(make-component
- (string-append cw (if cc (list->string cc) ""))
+ (string-join
+ (string-split-newline
+ (string-append cw (if cc (list->string cc) "")))
+ " ")
a)))
(timer ((: "~" (=> c (or ,component ,no-word-component)))