~emersion/public-inbox

Multiline strings v1 PROPOSED

Hubert Hirtz: 1
 Multiline strings

 1 files changed, 15 insertions(+), 5 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/public-inbox/patches/14363/mbox | git am -3
Learn more about email & git
View this thread in the archives

[RFC PATCH] Multiline strings Export this patch

---
Thoughts about the design of the feature?  This would be useful eg for
the MOTD in ellidri, and also in eventual build scripts.

Newlines would be kept, but not the whitespace around (as shown in the
changes already done to the grammar).

 README.md | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 55d8919..1a36a3b 100644
--- a/README.md
+++ b/README.md
@@ -2,15 +2,21 @@

A simple configuration file format.

The config file has one directive per line. Directives have a name, followed
by parameters separated by space characters. Parameters may be quoted.
Directives may have children in blocks delimited by "{" and "}". Lines
beginning with "#" are comments.
The config file has one directive per line. Directives have a name, followed by
parameters separated by space characters. Parameters may be quoted.  Directives
may have children in blocks delimited by "{" and "}".  Multiline strings are
enclosed between "[" and "]".  Lines beginning with "#" are comments.

Example:

```
train "Shinkansen" {
    description [
        Shinkansen trains are electric multiple units, offering fast
        acceleration, deceleration and reduced damage to the track because of
        the use of lighter vehicles compared to locomotives or power cars.
    ]

	model "E5" {
		max-speed 320km/h
		weight 453.5t
@@ -38,12 +44,16 @@ Grammar in [ABNF]:
```abnf
config = *directive

directive = directive-name [ 1*WSP directive-params ] [ 1*WSP block ] newline
directive = directive-name [ 1*WSP directive-params ] [ 1*WSP directive-block ] newline
directive-name = word
directive-params = [ word ] / word 1*( 1*WSP word )
directive-block = block / multiline-string

block = "{" newline *directive "}"

multiline-string = "[" newline 1*( string-line newline ) "]"
string-line = *( **TBD** )

word = atom / dquote-word / squote-word
atom = 1*( ACHAR / esc-pair )
dquote-word = DQUOTE *( DQCHAR / esc-pair ) DQUOTE
--
2.28.0
Both Caddy and POSIX sh just allow quoted strings to span over multiple
lines, so I was considering not adding any new syntax and simply remove
the restriction that quoted strings must be single-line. What do you
think?