diff options
-rw-r--r-- | cook/parse.scm | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/cook/parse.scm b/cook/parse.scm index 2953b70..b5f994d 100644 --- a/cook/parse.scm +++ b/cook/parse.scm @@ -77,7 +77,10 @@ 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 (char-set-difference text-chars (char-set #\{ #\}))) +(define component-chars (char-set-difference text-chars + (char-set #\{ #\}))) +(define component-word-chars (char-set-difference component-chars + char-set:whitespace)) (define quantity-chars (char-set-difference text-chars (char-set #\} #\%))) (define metadata-chars (char-set-difference text-chars (char-set #\:))) @@ -110,13 +113,17 @@ https://github.com/cooklang/spec/blob/main/EBNF.md ((=> q ,quantity) (make-amount q #f))) - (no-word-component ((: (=> x (? ,component-chars)) - "{" (? (=> a ,amount)) "}") - (make-component (list->string x) a))) - (component ((: (=> x (+ ,word)) (? (:"{" (=> a ,amount) "}"))) - (make-component x a)) - ((: (=> x (+ ,component-chars)) "{" (? (=> a ,amount)) "}") - (make-component (list->string x) a))) + (no-word-component ((: "{" (? (=> a ,amount)) "}") + (make-component #f a))) + + (component-word ((=> w (+ ,component-word-chars)) + (list->string w))) + (component ((: (=> cw ,component-word) + (? (: (=> cc (* ,component-chars)) + "{" (? (=> a ,amount)) "}"))) + (make-component + (string-append cw (if cc (list->string cc) "")) + a))) (timer ((: "~" (=> c (or ,component ,no-word-component))) (component->timer c))) |