# Slightly simplified version of the ebnf grammar used in
# the python grammar description... Only real difference
# is that we do not allow for breaking across lines (I'm just lazy)

declarationset      :=  (nullline/declaration)+
declaration         :=  ts , name ,ts,':',ts, element_token, ( fo_added_token / seq_added_token )*, ts,'\n'
fo_added_token      :=  (ts,'/',ts, element_token)+
seq_added_token     :=  (ts, element_token)+
element_token       :=  (literal/optionalgroup/group/name),ts, occurence_indicator?
group               :=  '(',ts, element_token, ( fo_added_token / seq_added_token )*, ts, ')'
optionalgroup       :=  '[',ts, element_token, ( fo_added_token / seq_added_token )*, ts, ']'

occurence_indicator :=  '+'/'*'
name                :=  [a-zA-Z_],[a-zA-Z0-9_]*
<ts>                :=  [ \011\013\014]+ / ('#',-'\n'+)*
<nullline>          :=  ts,'\n'
literal             :=  ("'",(CHARNOSNGLQUOTE/ESCAPEDCHAR)*,"'")  /  ('"',(CHARNODBLQUOTE/ESCAPEDCHAR)*,'"')

ESCAPEDCHAR         :=  '\\',( SPECIALESCAPEDCHAR / OCTALESCAPEDCHAR )
SPECIALESCAPEDCHAR  :=  [\\abfnrtv]
OCTALESCAPEDCHAR    :=  [0-7],[0-7]?,[0-7]?
CHARNODBLQUOTE      :=  -[\\"]+
CHARNOSNGLQUOTE     :=  -[\\']+
