~emersion/scfg

A simple configuration file format
readme: add copyright line
Include comments in grammar
tools: add tools section and tree-sitter link

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~emersion/scfg
read/write
git@git.sr.ht:~emersion/scfg

You can also use your local clone with git send-email.

#scfg

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.

Example:

train "Shinkansen" {
	model "E5" {
		max-speed 320km/h
		weight 453.5t

		lines-served "Tōhoku" "Hokkaido"
	}

	model "E7" {
		max-speed 275km/h
		weight 540t

		lines-served "Hokuriku" "Jōetsu"
	}
}

#Implementations

#Tools

#Specification (draft)

Grammar in ABNF:

config = *WSP [ 1*newline ] *directive

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

block = "{" 1*newline *directive "}"

word = atom / dquote-word / squote-word
atom = 1*( ACHAR / esc-pair )
dquote-word = DQUOTE *( DQCHAR / esc-pair ) DQUOTE
squote-word = "'" *SQCHAR "'"
esc-pair = "\" VCHAR

newline = *WSP LF *WSP [ comment ]
comment = "#" *VCHAR newline

ACHAR = %x21 / %x23-26 / %x28-5B / %x5D-7A / %x7C / %x7E / %x80-10FFFF
	; any Unicode code point, excluding CTL, DQUOTE, "\", LF, "'", "{", "}", WSP
DQCHAR = ACHAR / "'" / "{" / "}" / WSP
	; any Unicode code point, excluding CTL, DQUOTE, "\", LF
SQCHAR = %x09 / %x20-26 / %x28-7E / %x80-10FFFF
	; any Unicode code point, excluding CTL, "'", LF
VCHAR = SQCHAR / "'"
	; any Unicode code point, excluding CTL, LF

#License

This specification text is licensed with CC-BY-SA 4.0.

Copyright (C) 2024 The scfg Contributors