Skip to content

Grammar

EBNF reference

https://en.wikipedia.org/wiki/Extended_Backus–Naur_form

Table of symbols

UsageNotationMeaning
definition=
alternation|
optional?none or once
optional repetition*none or more
required with optional repetition+once or more
grouping( ... )
regex/ ... /
terminal string' ... '

Musicline's EBNF

ebnf
Musicline-0.2.0     = line*
line                = hws* (comment | event)? newline
comment             = hash nonnewline*
event               = (event-shortform | event-longform) hws*
event-shortform     = point (hws+ note-data-shortform)?
note-data-shortform = (nondigit-nonws | escape) hws* note-data
event-longform      = point hws+
                      voice hws+
                      type_data
point               = nonnegative-number
voice               = nonnegative-int (underscore nonnegative-int)*
type_data           = | marker-type hws+ marker-data
                      | muted-type  hws+ note-data
                      | note-type   hws+ note-data
                      | rest-type
                      | tail-type
                      | tempo-type  hws+ tempo-data
marker-data         = nonws+
note-data           = nonws (hws* nonws)*
tempo-data          = nonnegative-number
nonnegative-number  = nonnegative-int | nonnegative-real
nonnegative-real    = | nonnegative-int period digit*
                      | period digit+
nonnegative-int     = zero | positive-int
positive-int        = nonzero-digit digit*
digit               = zero | nonzero-digit

marker-type         = 'marker'
muted-type          = 'muted'
note-type           = 'note'
rest-type           = 'rest'
tail-type           = 'tail'
tempo-type          = 'tempo'
escape              = '\'
hash                = '#'
period              = '.'
underscore          = '_'
zero                = '0'
nonzero-digit       = /[1-9]/
nondigit-nonws      = /[^0-9\s]/
newline             = /\n/
nonnewline          = /[^\n]/
hws                 = /\h/
nonws               = /\S/