;; *************************************
;; *                                   *
;; *        WORK IN PROGRESS           *
;; *                                   *
;; *************************************


document = instruction *( newline instruction )


;; Whitespace

ignored-whitespace = whitespace
retained-whitespace = whitespace

whitespace = *( SP / HTAB )

SP   = U+0020  ; " " (Space)
HTAB = U+0009  ; "  " (Horizontal tab)


;; Newline

newline = LF / CR LF

LF = U+000A  ; "\n" (Line feed)
CR = U+000D  ; "\r" (Carriage return)


;; Comment

comment = comment-operator ignored-whitespace optional-token ignored-whitespace

comment-operator = GREATER-THAN-SIGN

GREATER-THAN-SIGN = U+003E  ; ">"


;; Fieldset entry

fieldset-entry = unescaped-name fieldset-entry-operator value

fieldset-entry-operator = EQUALS-SIGN

EQUALS-SIGN = U+003D  ; "="


;; Name

name-instruction = name name-operator

name = escaped-name / unescaped-name

escaped-name = ignored-whitespace 1*BACKTICK ignored-whitespace required-token ignored-whitespace 1*BACKTICK ignored-whitespace  ; Note: The number of backticks at the start and end must be the same
unescaped-name = ignored-whitespace required-token ignored-whitespace

name-operator = COLON

BACKTICK = U+0060  ; "`"
COLON = U+003A     ; ":"


;; Line continuation

line-continuation = ( line-continuation-operator / newline-continuation-operator ) value

newline-continuation-operator = VERTICAL-BAR
line-continuation-operator = BACKSLASH

VERTICAL-BAR = U+007C  ; "|"
BACKSLASH    = U+005C  ; "\"


;; List item

list-item = list-item-operator value

list-item-operator = DASH

DASH = U+002D  ; "-"


;; Section

section = section-operator TODO

section-operator = 1*HASH

HASH = U+0023


;; Token

optional-token = *non-eol
required-token = 1*non-eol

non-eol =  %x09
non-eol =/ %x20-10FFFF


;; Value

value = ignored-whitespace optional-token ignored-whitespace
