ChordPro

enum ChordPro

The ChordPro file parser

Parse a ‘ChordPro’ file

  • Parse a ChordPro file

    Declaration

    Swift

    static func parse(text: String, transpose: Int, instrument: Instrument) -> Song

    Parameters

    text

    The text of the file

    transponse

    The optional transpose of the song

    Return Value

    A Song item

Process a directive

  • Process a directive

    Declaration

    Swift

    private static func processDirective(
        text: String,
        song: inout Song,
        currentSection: inout Song.Section
    )

    Parameters

    text

    The text to process

    song

    The Song

    currentSection

    The current section of the song

Process a section

  • Process a section

    Declaration

    Swift

    private static func processSection(label: String, type: Environment, song: inout Song, currentSection: inout Song.Section)

    Parameters

    label

    The label of the section

    type

    The type of section

    song

    The song

    currentSection

    The current section of the song

Process a chord definition

  • Process a chord definition

    Declaration

    Swift

    private static func processDefine(text: String, song: inout Song)

    Parameters

    text

    The chord definition

    song

    The song

Process a tab environment

  • Process a tab environment

    Declaration

    Swift

    private static func processTab(text: String, song: inout Song, currentSection: inout Song.Section)

    Parameters

    text

    The text to process

    song

    The Song

    currentSection

    The current section of the song

Process a grid environment

  • Process a grid environment

    Declaration

    Swift

    private static func processGrid(text: String, song: inout Song, currentSection: inout Song.Section)

    Parameters

    text

    The text to process

    song

    The Song

    currentSection

    The current section of the song

Process a line

  • Process a line

    Declaration

    Swift

    private static func processLine(text: String, song: inout Song, currentSection: inout Song.Section)

    Parameters

    text

    The text to process

    song

    The Song

    currentSection

    The current section of the song

Process a chord

  • Process a chord

    Declaration

    Swift

    private static func processChord(chord: String, song: inout Song) -> ChordDefinition

    Parameters

    chord

    The chord as String

    song

    The Song

    Return Value

    The processed chord as String

‘ChordPro’ directives

  • The directives Chord Provider supports

    See more

    Declaration

    Swift

    enum Directive : String, CaseIterable

‘ChordPro’ section environments

  • The environment of a section of the song

    See more

    Declaration

    Swift

    enum Environment : String

Regex definitions

  • The regex for a directive with an optional label

    /// ## Examples
    
    {title: The title of the song}
    {chorus}
    {start_of_verse}
    {start_of_verse: Last Verse}
    

    Declaration

    Swift

    static let directiveRegex: Regex<Regex<(Substring, ChordPro.Directive, String?)>.RegexOutput>
  • The regex for a normal line with optionalchords and/or lyrics

    /// ## Example
    
    [A]I sing you a [G]song!!
    

    Declaration

    Swift

    static let lineRegex: Regex<Regex<(Substring, Regex<OneOrMore<Substring>.RegexOutput>.RegexOutput?, Regex<OneOrMore<Substring>.RegexOutput>.RegexOutput?)>.RegexOutput>