shrub/pkg/base-dev/lib/story.hoon

78 lines
1.6 KiB
Plaintext
Raw Normal View History

2022-01-26 19:37:02 +03:00
/- *story
|%
++ tako-to-text
|= [=tako:clay]
2022-01-30 23:59:58 +03:00
^- tape
"commit: {<`@uv`tako>}\0a"
::
2022-01-26 19:37:02 +03:00
++ proses-to-text
2022-01-30 23:59:58 +03:00
|= [=proses]
^- tape
2022-01-26 19:37:02 +03:00
=/ proses-list=(list prose) ~(tap in proses)
2022-01-30 23:59:58 +03:00
?: ?=(~ proses-list) ""
2022-01-26 19:37:02 +03:00
?: ?=([prose ~] proses-list)
2022-01-30 23:59:58 +03:00
(prose-to-text i.proses-list)
2022-01-26 19:37:02 +03:00
%- tail
2022-01-30 23:59:58 +03:00
%^ spin ;;((list prose) t.proses-list) :: XX WHY DO WE NEED ;;
(prose-to-text i.proses-list)
|= [prz=prose state=tape]
2022-01-26 19:37:02 +03:00
^- [prose tape]
2022-01-30 23:59:58 +03:00
:- prz
2022-01-26 19:37:02 +03:00
;: welp
state
2022-01-30 23:59:58 +03:00
"|||"
"\0a"
(prose-to-text prz)
==
::
++ prose-to-text
|= pro=prose
=/ [title=@t body=@t] pro
^- tape
;: welp
2022-01-26 19:37:02 +03:00
"{(trip title)}"
"\0a\0a"
"{(trip body)}"
"\0a"
==
2022-01-31 00:01:00 +03:00
::
:: Parsers
::
++ parse-commit
;~ sfix
;~ pfix (jest 'commit: ')
(cook @uv ;~(pfix (jest '0v') viz:ag))
==
::
(just '\0a')
==
::
++ parse-title
;~ sfix
(cook crip (star prn))
(jest '\0a\0a')
==
::
++ parse-body-single
%- star
;~ less
;~(pose (jest '|||\0a') (jest '---\0a'))
(cook crip ;~(sfix (star prn) (just '\0a')))
==
::
++ parse-prose-single ;~(plug parse-title parse-body-single)
++ parse-rest-proses (star ;~(pfix (jest '|||\0a') parse-prose-single))
++ parse-proses ;~(plug parse-prose-single parse-rest-proses)
++ parse-chapter ;~(plug parse-commit parse-proses)
++ parse-story (star ;~(sfix parse-chapter (jest '---\0a')))
::
:: Parse prose: a title, followed by a body
::
:: Parse proses: a prose, followed by zero or more proses, representing conflicts
::
:: Parse chapters (story entries): a commit followed by one or more proses
::
:: Parse story: zero or more chapters
::
::
2022-01-26 19:37:02 +03:00
--