ChordPro
actor ChordPro
The ChordPro
file parser
-
Parse a ChordPro file
Declaration
Swift
static func parse(id: UUID, text: String, transpose: Int, instrument: Instrument, fileURL: URL?) -> Song
Parameters
text
The text of the file
transponse
The optional transpose of the song
Return Value
A
Song
item
-
Process a directive
Declaration
Parameters
text
The text to process
song
The
Song
currentSection
The current
section
of thesong
-
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 thesong
-
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
Declaration
Parameters
text
The text to process
song
The
Song
currentSection
The current
section
of thesong
-
Process a grid environment
Declaration
Parameters
text
The text to process
song
The
Song
currentSection
The current
section
of thesong
-
Process a strum environment
Declaration
Parameters
text
The text to process
song
The
Song
currentSection
The current
section
of thesong
-
Process a line
Declaration
Parameters
text
The text to process
song
The
Song
currentSection
The current
section
of thesong
-
Process a chord
Declaration
Swift
private static func processChord(chord: String, song: inout Song) -> ChordDefinition
Parameters
chord
The
chord
as Stringsong
The
Song
Return Value
The processed
chord
as String
-
The directives Chord Provider supports
See moreDeclaration
Swift
enum Directive : String, CaseIterable
-
The environment of a section of the song
See moreDeclaration
Swift
enum Environment : String
-
All the directives we know about
Declaration
Swift
static let directives: [String]
-
The regex for a
directive
with an optionallabel
/// ## Examples {title: The title of the song} {chorus} {start_of_verse} {start_of_verse: Last Verse}
Note
This needs an extension forChoiceOf
Declaration
Swift
static let directiveRegex: Regex<Regex<(Substring, ChordPro.Directive, String?)>.RegexOutput>
-
The regex for a normal line with optional
chords
and/orlyrics
/// ## 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>
-
Regex for brackets for chords and directives
Declaration
Swift
static let bracketRegex: Regex<Regex<Capture<(Substring, Regex<OneOrMore<Substring>.RegexOutput>.RegexOutput)>.RegexOutput>.RegexOutput>
-
Regex for a chord
Declaration
Swift
static let chordRegex: Regex<Regex<Regex<Regex<(Substring, Regex<OneOrMore<Substring>.RegexOutput>.RegexOutput)>.RegexOutput>.RegexOutput>.RegexOutput>