grammar SSA

rule subtitles
  info?
  styles?
  event_section
  fonts?
  graphics?
  end_of_data

  <Titlekit::SSA::Subtitles>
end

rule info
  '[Script Info]' end_of_line lines* end_of_section <Titlekit::SSA::ScriptInfo>
end

rule styles
  '[V4 Styles]' end_of_line lines* end_of_section <Titlekit::SSA::V4PStyles>
end

rule event_section
  '[Events]' end_of_line line events end_of_section
end

rule events
  line* <Titlekit::SSA::Events>
end

rule event
  'Dialogue'
end

rule fonts
  '[Fonts]' end_of_line lines* end_of_section
end

rule graphics
  '[Graphics]' end_of_line lines* end_of_section
end

rule lines
  line+
end

rule line
  string (end_of_line / end_of_file)
end

rule end_of_section
  end_of_line+ / end_of_file
end

rule end_of_line
  "\r\n" / "\n" / "\r"
end

rule end_of_data
  end_of_line+ / end_of_file
end

rule end_of_file
  !.
end

rule number
  [0-9]+
end

rule string
  (!end_of_line .)+
end

end