abc-parser

Crates.ioabc-parser
lib.rsabc-parser
version0.3.0
sourcesrc
created_at2018-08-20 20:49:51.706531
updated_at2021-06-08 05:37:38.972741
descriptionAn ABC music notation parser. Turns ABC text into Rust data structures and back.
homepage
repositoryhttps://gitlab.com/Askaholic/rust-abc-2
max_upload_size
id80476
size57,396
(Askaholic)

documentation

README

rust-abc-2

ABC Parser written in rust using PEG.

Usage

Add the package to your cargo dependencies.

[dependencies]
abc-parser = "0.2"

Then you can use the PEG generated rules through the abc module.

extern crate abc_parser;

use abc_parser::datatypes::*;
use abc_parser::abc;

let parsed = abc::tune_book("X:1\nT:Example\nK:D\n").unwrap();
assert_eq!(
    parsed,
    TuneBook::new(None, vec![
        Tune::new(
            TuneHeader::new(vec![
                InfoField::new('X', "1".to_string()),
                InfoField::new('T', "Example".to_string()),
                InfoField::new('K', "D".to_string())
            ]),
            None
        )
    ])
)

There is a good chance that the dev branch may have more recently added features which arent complete but won't (probably) break the existing functionality. You can also tell cargo to install directly from the dev branch like this:

[dependencies]
abc-parser = { git = "https://gitlab.com/Askaholic/rust-abc-2", branch = "dev" }

Feature List

These are roughly taken in order from the abc standard.

  • Info fields
  • Field continuation
  • Notes
    • Pitch
    • Accidentals
    • Lengths
    • Ties
    • Broken Rhythm
  • Rests
  • Clefs and Transposition
  • Beams
  • Bars
  • Variant Endings
  • Slurs
  • Grace Notes
  • Tuplets
  • Decorations
  • Symbol Lines
  • Redefining Symbols
  • Chords and Unisons
  • Chord Symbols
  • Annotations
  • Lyrics
  • Multiple Voices
  • Text Strings
  • Macros
  • Stylesheet Directives
  • Dialects

History

The first version was an attempt to write the parser by hand, but using PEG is much more maintainable. The older repo is here: https://gitlab.com/Askaholic/rust-abc

Commit count: 92

cargo fmt