7 unstable releases
Uses new Rust 2024
| 0.4.0 | Dec 29, 2025 |
|---|---|
| 0.3.0 | Jun 8, 2021 |
| 0.2.0 | Aug 21, 2018 |
| 0.1.5 | Aug 20, 2018 |
#589 in Parser implementations
Used in 2 crates
105KB
3K
SLoC
rust-abc-2
ABC Parser written in rust using PEG.
Usage
Add the package to your cargo dependencies.
[dependencies]
abc-parser = "0.4"
Then you can use the PEG generated rules through the abc module.
use abc_parser::abc;
use abc_parser::datatypes::*;
let parsed = abc::tune_book("X:1\nT:Example\nK:D\n").unwrap();
assert_eq!(
parsed,
TuneBook::new(
vec![],
None,
vec![Tune::new(
TuneHeader::new(vec![
HeaderLine::Field(InfoField::new('X', "1".to_string()), None),
HeaderLine::Field(InfoField::new('T', "Example".to_string()), None),
HeaderLine::Field(InfoField::new('K', "D".to_string()), None)
]),
None
)]
)
)
Feature List
These are roughly taken in order from the abc standard.
- Comments
- Comment lines with preceding whitespace
- Info fields
- Inline fields
- Remarks
- Macros
- Redefining Symbols
- Multiple Voices
- Clefs and Transposition
- Field continuation
- Notes
- Pitch
- Accidentals
- Lengths
- Ties
- Broken Rhythm
- Splitting grace notes e.g. A{g}<A
- Rests
- Beams
- Bars
- First and second repeats
- Shortened e.g. |1 and :|2
- Variant Endings
- Slurs
- Grace Notes
- Tuplets
- Decorations
- Symbol Lines
- Chords and Unisons
- Annotations
- Chord Symbols
- Lyrics
- Multiple Voices
- Voice grouping shorthand syntax
- Text Strings
- Reserved characters
- Stylesheet Directives
- Dialects
- Spacers
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
Dependencies
~1MB
~26K SLoC